コード例 #1
0
    def create_weapon(self, player):
        def increase_durability(s):
            weapon.durability += 1

        weapon = Weapon(3, 2)
        player.game.players[0].bind("secret_revealed", increase_durability)
        player.game.players[1].bind("secret_revealed", increase_durability)
        weapon.bind_once("destroyed", lambda: player.game.players[0].unbind("secret_revealed", increase_durability))
        weapon.bind_once("destroyed", lambda: player.game.players[1].unbind("secret_revealed", increase_durability))
        return weapon
コード例 #2
0
    def create_weapon(self, player):
        def make_immune(ignored_target):
            player.hero.immune = True

        def end_immune():
            player.hero.immune = False

        def on_destroy():
            player.hero.unbind("attack", make_immune)
            player.hero.unbind("attack_completed", end_immune)

        weapon = Weapon(5, 2)
        player.hero.bind("attack", make_immune)
        player.hero.bind("attack_completed", end_immune)
        weapon.bind_once("destroyed", on_destroy)
        return weapon