Example #1
0
def check_race(race):
    """
        check to see if the player supplied a valid race
    """
    if db.get_race(race):
        return True
    else:
        return False
Example #2
0
    def calc_stats(self, equipment):
        """
            Calculate the players statistics based on class, race and
            equipment worn.
            args: equipment is a mud.entity.player.Equipment object.
                  used to get equipment stats. This is an interdep and
                  its lame i know, but it works so nener nener.
        """
        
        race = db.get_race(self.race)
        job = db.get_job(self.job)
        
        ## Calculate statistics
        ## STR DEX CON AGI INT WIS CHA 
        self.str, self.dex, self.con, self.agi, \
           self.int, self.wis, self.cha = race.get_stats()
           
        ## TODO: Saves arent even used yet
        self.svm, self.svc, self.svf, self.svp, self.svd = race.get_saves() 

        ## Apply stats from items, save flat hp/mp bonus for addition 
        ## after stats are applied to the values.
        hp_from_gear = 0
        mp_from_gear = 0
        ac_from_gear = 0
        
        
        ## Calculate HP per the CON score
        class_hp = (job.hp_per_con_min, job.hp_per_con_max)
        hp_per_con = ((class_hp[1] - class_hp[0]) / 50) * self.level
        hp_per_con += class_hp[0]
        self.hp_max = self.con * hp_per_con
        self.hp = 1

        ## Calculate AC per the AGI score 
        ## TODO: Dex should be used as well, need some mitigation 
        ## stuff too.                                   
        class_ac = (job.ac_per_agi_min, job.ac_per_agi_max)
        ac_per_agi = ((class_ac[1] - class_ac[0]) / 50) * self.level
        agi_ac = self.agi * ac_per_agi
        self.ac = int(agi_ac) ## + (self.get_skill('defense').value / 5)

        ## See if class is a caster, and if so int or wis. Then calculate the 
        ## base hp for the player.
        base_mp = 0
        if job.mp_per_int_min:
            mp_int = (job.mp_per_int_min, job.mp_per_int_max)
            mp_per_int = (( mp_int[1] - mp_int[0])/50)*self.level
            base_mp += self.int * mp_per_int
        else:
            self.mp = 0
        #elif pclass.mp_wis:
        #    mp_per_wis = (( pclass.mp_wis[1] - pclass.mp_wis[0])/50)*self.level
        #    base_mp += self.wis * mp_per_wis
        #else:
        #    base_mp = 0
        #    self.mp = 0
        self.mp_max = base_mp