Source

GtugGoSandbox / mapgame / engine.py

from models import *
from google.appengine.ext import db


def level_up(player):
    job = player.profession
    rules = db.Query(Rule)
    rules.filter('job_from =',job)
    rules.filter('value =',player.xp)
    rl = rules.get()
    player.profession = rl.job_to
    player.hp = player.hp + rl.hp_add
    player.put()

def generate_damage(player):
    profession = player.profession
    job = db.Query(Jobs)
    job.filter('name =',profession)
    job = job.get()
    jattr = db.Query(JobsAttrib)
    jattr.filter('job =',job)
    damage = 0
    for i in jattr:
        damage = damage + i.damage
    return damage

def generate_resistance(player):
    profession = player.profession
    job = db.Query(Jobs)
    job.filter('name =',profession)
    job = job.get()
    jattr = db.Query(JobsAttrib)
    jattr.filter('job =',job)
    resistance = 0
    for i in jattr:
        resistance = resistance + i.resistance
    return resistance