All pastes #1623701 Raw Edit

robertj

public text v1 · immutable
#1623701 ·published 2009-10-16 13:04 UTC
rendered paste body
from ent import Entfrom MudTime import Timerfrom stats import * class PrimitiveCombatant(Ent):    def _setup(self):        Ent._setup(self)        self._initStats()        self.channeling = False        self._doing = False        self._cooldown = False    def __set_doing(self, doing):        if self._doing:            self._doing.interrupt()        self._doing = doing    def __get_doing(self):        return self._doing    doing = property(__get_doing, __set_doing)    def alertHP(self, stat):        print "%s <%s/%s> " %(self.name, self.hp.value, self.max_hp.value)    def deathMonitor(self, hp_stat):        if hp_stat.value <= 0:            self.die()    def die(self):        self.emote("dies.")        self.stop()    def stop(self):        if self._cooldown:            self.cancelCooldown()        for x in self.effects.copy():            self.effects.remove(x)    def _initStats(self):        self.stats = StatCollection()        self.level = Level()        self.str = Str()        self.dex = Dex()        self.con = Con()        self.int = Int()        self.wis = Wis()        self.cha = Cha()        self.armor = Armor()        self.base_attack_power = CalculatedStat(lambda: (self.level.value * 2) + self.str.value, [self.level,self.str])        self.attack_power = AttackPower(self.base_attack_power)        self.base_max_hp = CalculatedStat(lambda: self.level.value * 10, [self.level])        self.max_hp = MaxHP(self.base_max_hp)        self.level.set(1)        self.hp = PrimitiveStat()        self.hp.set(self.max_hp.value)        self.hp.subscribe(self.alertHP)        self.hp.subscribe(self.deathMonitor)        self.cha.addToStatCollection(self.stats)        self.hp.addToStatCollection(self.stats)        self.abilities = []        self._cooldown = False    def extendCooldown(self, amount):        if self._cooldown:            return False        else:            self._cooldown = Timer(amount, self.cancelCooldown)            self._cooldown.start()            return True    def cancelCooldown(self):        self._cooldown.cancel()        self._cooldown = Falseclass Combatant(PrimitiveCombatant):    def __init__(self):        self._setup()