Esempio n. 1
0
 def __init__(self):
   self.level = 1
   self.hp = 10
   self.max_hp = 10
   self.strength = 10
   self.agility = 10
   self.vitality = 10
   self.inventory = []
   self.weapon_loc = -1
   self.armor_loc = -1
   self.weapon = Weapon(0,"None")
   self.armor = Armor(0,"None")
   self.gold = 0
   self.recalculate()
Esempio n. 2
0
class Character(object):
    def __init__(self):
      self.level = 1
      self.hp = 10
      self.max_hp = 10
      self.strength = 10
      self.agility = 10
      self.vitality = 10
      self.inventory = []
      self.weapon_loc = -1
      self.armor_loc = -1
      self.weapon = Weapon(0,"None")
      self.armor = Armor(0,"None")
      self.gold = 0
      self.recalculate()

    def get(self,field):
        return self.__dict__[field]

    def give_item(self, item):
        self.inventory.append(item)

    def equip_weapon(self, weapon):
        self.weapon_loc = weapon
        self.weapon = self.inventory[weapon]
        self.recalculate()

    def equip_armor(self, armor):
        self.armor_loc = armor
        self.armor = self.inventory[armor]
        self.recalculate()

    def remove_weapon(self):
        self.weapon_loc = -1
        self.weapon = Weapon(0,"None")
        self.recalculate()

    def remove_armor(self):
        self.armor_loc = -1
        self.armor = Armor(0,"None")
        self.recalculate()

    def recalculate(self):
        if self.armor_loc == -1: rating = 0
        else:
           rating = self.armor.get_rating()
        self.thaco = 30 - self.strength
        self.ac = 20 - rating - self.agility
        self.max_hp = 2 * self.vitality

    def damage(self, points):
        self.hp = self.hp - points
        return self.hp <= 0

    def do_damage(self):
        return dice.roll(self.attack_damage)

    def get_gold(self):
        return self.gold

    def get_level(self):
        return self.level

    def get_thaco(self):
        return self.thaco
    
    def get_max_hp(self):
        return self.max_hp

    def get_hp(self):
        return self.hp

    def get_ac(self):
        return self.ac

    def get_exp(self):
        return self.exp

    def get_initiative(self):
        return dice.roll('1d20') + self.agility
Esempio n. 3
0
 def remove_armor(self):
     self.armor_loc = -1
     self.armor = Armor(0,"None")
     self.recalculate()