コード例 #1
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)
コード例 #2
0
    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
                    })
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
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)
コード例 #6
0
    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)
コード例 #7
0
 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)
コード例 #8
0
    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
コード例 #9
0
    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)
コード例 #10
0
 def property(self):
     return app().hero.attack
コード例 #11
0
 def property(self):
     return app().hero.health
コード例 #12
0
 def property(self):
     return app().hero.keys[self.key]
コード例 #13
0
 def move(self):
     app().hero.setLocation(self.loc)
コード例 #14
0
 def interact(self):
     app().getCell(self.location + self.offset,
                   self.floor).combat(self.location)
コード例 #15
0
 def interact(self):
     if app().hero.location - self.location == Point(1, 0):
         text, hotkeys = self.contentProvider.get(self)
         app().showDialog(text, hotkeys)
コード例 #16
0
 def property(self):
     return app().hero.handbook
コード例 #17
0
 def clearBlock():
     app().setCell(Empty(), cell.location, cell.floor)
     app().unblockActions()
     if completion:
         completion()
コード例 #18
0
 def clearBlock():
     app().setCell(Empty(), self.location, self.floor)
     app().unblockActions()
コード例 #19
0
 def finish(self):
     for part in self.parts:
         app().setCell(Empty(), self.location + part, self.floor)
コード例 #20
0
 def clearBlock():
     self.hidden = False
     app().unblockActions()
コード例 #21
0
 def property(self):
     return app().hero.defence
コード例 #22
0
 def interact(self):
     self.property.collect(self.quantity)
     app().hero.moveBy(self.location - app().hero.location)
     app().setCell(Empty(), self.location, self.floor)
コード例 #23
0
 def finish(self):
     app().setCell(Empty(), self.location, self.floor)
コード例 #24
0
 def property(self):
     return app().hero.flyingWand
コード例 #25
0
 def clearBlock(dt):
     self.move()
     app().unblockActions()
コード例 #26
0
 def interact(self):
     if app().hero.keys[self.key].value > 0:
         app().hero.keys[self.key].update(-1)
         self.open()
コード例 #27
0
 def move(self):
     app().moveByFloors(self.direction)
コード例 #28
0
 def interact(self):
     app().hero.moveBy(self.location - app().hero.location)
コード例 #29
0
 def purchase(item, quantity):
     self.purchases += 1
     app().hero.money.update(-money)
     item.update(quantity)
     return True