def strike(dt): app().showSpark() self.health = max(self.health - analysis.heroDamage, 0) app().updateMonsterHealth(self.health) def hide(dt): nonlocal i app().hideSpark() if i == analysis.heroStrikes - 1: def clearBlock(dt): app().hero.money.update(self.money) app().showMonster(None) for door in self.guarded_doors: door.unguard() app().unblockActions() self.finish() for gift in self.gifts: app().setCell(self.gifts[gift], self.location + gift, self.floor) Clock.schedule_once(clearBlock, 0.15) else: app().hero.health.update(-analysis.monsterDamage) i += 1 Clock.schedule_once(strike, 0.15) Clock.schedule_once(hide, 0.15)
def get(self, cell): section = floor2section(cell.floor) money = round(150 * (1.0344)**self.purchases) health = (section) * 200 + 200 attack = section * 2 defence = section * 2 if app().hero.money.value >= money: def purchase(item, quantity): self.purchases += 1 app().hero.money.update(-money) item.update(quantity) return True return ( "Give me %d gold coins\nto increase one of your abilities" % money + LARGE_TEXT_GAP + "[ref=1]<1> Health +%d[/ref]" % health + SMALL_TEXT_GAP + "[ref=2]<2> Attack +%d[/ref]" % attack + SMALL_TEXT_GAP + "[ref=3]<3> Defence +%d[/ref]" % defence + SMALL_TEXT_GAP + "[ref=" + REF_KEY_ANY + "]<Any> No, thanks[/ref]", { "1": lambda: purchase(app().hero.health, health), "2": lambda: purchase(app().hero.attack, attack), "3": lambda: purchase(app().hero.defence, defence), REF_KEY_ANY: lambda: True }) else: return ("You need %d gold coins\nto make a purchase!" % money + LARGE_TEXT_GAP + "Press any key to continue", { REF_KEY_ANY: lambda: True })
def interact(self): app().hero.moveBy(self.location - app().hero.location) app().blockActions() def clearBlock(dt): self.move() app().unblockActions() Clock.schedule_once(clearBlock, 0.2)
def open(self): app().blockActions() def clearBlock(): app().setCell(Empty(), self.location, self.floor) app().unblockActions() _animate(self.texture, [(self.textureRow, i) for i in range(4)] + [EMPTY_TEXTURE], clearBlock)
def removeWall(cell, completion=None): app().blockActions() def clearBlock(): app().setCell(Empty(), cell.location, cell.floor) app().unblockActions() if completion: completion() _animate(cell.texture, [(8, i) for i in range(4)] + [EMPTY_TEXTURE], clearBlock)
def interact(self): if self.hidden: app().blockActions() def clearBlock(): self.hidden = False app().unblockActions() _animate(self.texture, [EMPTY_TEXTURE] + [(8, 3 - i) for i in range(4)], clearBlock)
def clearBlock(dt): app().hero.money.update(self.money) app().showMonster(None) for door in self.guarded_doors: door.unguard() app().unblockActions() self.finish() for gift in self.gifts: app().setCell(self.gifts[gift], self.location + gift, self.floor)
def __init__(self, monster): hero = app().hero self.heroDamage = max(hero.attack.value - monster.defence, 0) self.heroStrikes = -1 if self.heroDamage == 0 else ( (monster.health - 1) // self.heroDamage + 1) self.monsterDamage = max(monster.attack - hero.defence.value, 0) self.monsterTotalDamage = -1 if self.heroStrikes == -1 else ( self.heroStrikes - 1) * self.monsterDamage
def combat(self, attack_location): print("Attacking %s <%d, %d, %d, %d>" % (self.name, self.health, self.attack, self.defence, self.money)) analysis = CombatAnalysis(self) if analysis.monsterTotalDamage != -1 and analysis.monsterTotalDamage < app( ).hero.health.value: app().hero.moveBy(attack_location - app().hero.location) app().blockActions() app().showMonster(self) i = 0 def strike(dt): app().showSpark() self.health = max(self.health - analysis.heroDamage, 0) app().updateMonsterHealth(self.health) def hide(dt): nonlocal i app().hideSpark() if i == analysis.heroStrikes - 1: def clearBlock(dt): app().hero.money.update(self.money) app().showMonster(None) for door in self.guarded_doors: door.unguard() app().unblockActions() self.finish() for gift in self.gifts: app().setCell(self.gifts[gift], self.location + gift, self.floor) Clock.schedule_once(clearBlock, 0.15) else: app().hero.health.update(-analysis.monsterDamage) i += 1 Clock.schedule_once(strike, 0.15) Clock.schedule_once(hide, 0.15) Clock.schedule_once(strike, 0.15)
def property(self): return app().hero.attack
def property(self): return app().hero.health
def property(self): return app().hero.keys[self.key]
def move(self): app().hero.setLocation(self.loc)
def interact(self): app().getCell(self.location + self.offset, self.floor).combat(self.location)
def interact(self): if app().hero.location - self.location == Point(1, 0): text, hotkeys = self.contentProvider.get(self) app().showDialog(text, hotkeys)
def property(self): return app().hero.handbook
def clearBlock(): app().setCell(Empty(), cell.location, cell.floor) app().unblockActions() if completion: completion()
def clearBlock(): app().setCell(Empty(), self.location, self.floor) app().unblockActions()
def finish(self): for part in self.parts: app().setCell(Empty(), self.location + part, self.floor)
def clearBlock(): self.hidden = False app().unblockActions()
def property(self): return app().hero.defence
def interact(self): self.property.collect(self.quantity) app().hero.moveBy(self.location - app().hero.location) app().setCell(Empty(), self.location, self.floor)
def finish(self): app().setCell(Empty(), self.location, self.floor)
def property(self): return app().hero.flyingWand
def clearBlock(dt): self.move() app().unblockActions()
def interact(self): if app().hero.keys[self.key].value > 0: app().hero.keys[self.key].update(-1) self.open()
def move(self): app().moveByFloors(self.direction)
def interact(self): app().hero.moveBy(self.location - app().hero.location)
def purchase(item, quantity): self.purchases += 1 app().hero.money.update(-money) item.update(quantity) return True