Esempio n. 1
0
class Effect(Tag):
    def __init__(self, event, action, selector, condition=None):
        self.event = event
        if isinstance(action, Status):
            from hearthbreaker.tags.action import Give
            self.action = Give(action)
        else:
            self.action = action
        self.selector = selector
        self.owner = None
        self.condition = condition

    def apply(self):
        self.event.bind(self.owner, self._find_target)

    def unapply(self):
        self.event.unbind(self.owner, self._find_target)

    def set_owner(self, owner):
        self.owner = owner

    def _find_target(self, focus=None, other=None, *args):
        if not self.condition or self.condition.evaluate(self.owner, focus, other, *args):
            targets = self.selector.choose_targets(self.owner, focus)
            for target in targets:
                self.action.act(self.owner, target)

    def __to_json__(self):
        if self.condition:
            return {
                'event': self.event,
                'action': self.action,
                'selector': self.selector,
                'condition': self.condition,
            }
        return {
            'event': self.event,
            'action': self.action,
            'selector': self.selector,
        }

    @staticmethod
    def from_json(action, event, selector, condition=None):
            action = Action.from_json(**action)
            event = Event.from_json(**event)
            selector = Selector.from_json(**selector)
            if condition:
                condition = Condition.from_json(**condition)
            return Effect(event, action, selector, condition)
Esempio n. 2
0
 def __init__(self, event, action, selector):
     self.event = event
     if isinstance(action, Status):
         from hearthbreaker.tags.action import Give
         self.action = Give(action)
     else:
         self.action = action
     self.selector = selector
     self.target = None
Esempio n. 3
0
class Effect(JSONObject):
    def __init__(self, event, action, selector):
        self.event = event
        if isinstance(action, ReversibleAction):
            from hearthbreaker.tags.action import Give
            self.action = Give(action)
        else:
            self.action = action
        self.selector = selector
        self.target = None

    def apply(self):
        self.event.bind(self.target, self._find_target)
        self.action.track_changes(self.target.player)

    def unapply(self):
        self.event.unbind(self.target, self._find_target)

    def set_target(self, target):
        self.target = target

    def _find_target(self, focus=None, other=None, *args):
        targets = self.selector.get_targets(self.target, focus)
        for target in targets:
            self.action.act(self.target, target)

    def __to_json__(self):
        return {
            'event': self.event,
            'action': self.action,
            'selector': self.selector,
        }

    @staticmethod
    def from_json(game, action, event, selector):
            action = Action.from_json(**action)
            event = Event.from_json(**event)
            selector = Selector.from_json(**selector)
            return Effect(event, action, selector)
Esempio n. 4
0
 def __init__(self):
     super().__init__("Houndmaster",
                      4,
                      CHARACTER_CLASS.HUNTER,
                      CARD_RARITY.FREE,
                      minion_type=MINION_TYPE.NONE,
                      battlecry=Battlecry(
                          Give([
                              Buff(ChangeHealth(2)),
                              Buff(ChangeAttack(2)),
                              Buff(Taunt())
                          ]),
                          MinionSelector(IsType(MINION_TYPE.BEAST),
                                         picker=UserPicker())))
Esempio n. 5
0
 def __init__(self):
     super().__init__("Cenarius",
                      9,
                      CHARACTER_CLASS.DRUID,
                      CARD_RARITY.LEGENDARY,
                      choices=[
                          Choice(
                              IncreaseStats(),
                              Give([
                                  Buff(ChangeAttack(2)),
                                  Buff(ChangeHealth(2)),
                                  Buff(Taunt())
                              ]), MinionSelector()),
                          Choice(SummonTreants(), Summon(Treant(), 2),
                                 PlayerSelector())
                      ])
Esempio n. 6
0
 def __init__(self):
     super().__init__("Edwin VanCleef",
                      3,
                      CHARACTER_CLASS.ROGUE,
                      CARD_RARITY.LEGENDARY,
                      battlecry=Battlecry(
                          Give([
                              Buff(
                                  ChangeAttack(
                                      Attribute("cards_played",
                                                PlayerSelector()), 2)),
                              Buff(
                                  ChangeHealth(
                                      Attribute("cards_played",
                                                PlayerSelector()), 2))
                          ]), SelfSelector()))
Esempio n. 7
0
 def __init__(self):
     super().__init__(
         "Void Terror",
         3,
         CHARACTER_CLASS.WARLOCK,
         CARD_RARITY.RARE,
         minion_type=MINION_TYPE.DEMON,
         battlecry=(Battlecry(
             Give([
                 Buff(
                     ChangeHealth(
                         Attribute("health", MinionSelector(Adjacent())))),
                 Buff(
                     ChangeAttack(
                         Attribute("attack", MinionSelector(Adjacent()))))
             ]),
             SelfSelector()), Battlecry(Kill(),
                                        MinionSelector(Adjacent()))))
Esempio n. 8
0
 def __init__(self):
     super().__init__(
         "Void Terror",
         3,
         CHARACTER_CLASS.WARLOCK,
         CARD_RARITY.RARE,
         minion_type=MINION_TYPE.DEMON,
         battlecry=(Battlecry(
             Give([
                 Add(
                     CHARACTER_STATUS.ATTACK(
                         Attribute("attack", MinionSelector(Adjacent())))),
                 Add(
                     CHARACTER_STATUS.HEALTH(
                         Attribute("health", MinionSelector(Adjacent()))))
             ]),
             SelfSelector()), Battlecry(Kill(),
                                        MinionSelector(Adjacent()))))
Esempio n. 9
0
 def create_minion(self, player):
     return Minion(6, 9, effects=[Effect(Damaged(), ActionTag(Give(Buff(DoubleAttack())), SelfSelector()))])
Esempio n. 10
0
 def create_minion(self, player):
     return Minion(2, 3, effects=[Effect(DidDamage(), ActionTag(Give(Frozen()), TargetSelector()))])
Esempio n. 11
0
 def create_minion(self, player):
     return Minion(3, 3, effects=[Effect(TurnEnded(HasSecret()), ActionTag(Give(ChangeAttack(2)), SelfSelector())),
                                  Effect(TurnEnded(HasSecret()), ActionTag(Give(ChangeHealth(2)), SelfSelector()))])
Esempio n. 12
0
 def create_minion(self, player):
     return Minion(5, 5, effects=[Effect(ArmorIncreased(), ActionTag(Give(ChangeAttack(1)), SelfSelector()))])
Esempio n. 13
0
 def create_minion(self, player):
     return Minion(4, 4, effects=[Effect(CharacterDamaged(And(IsHero(), OwnersTurn())),
                                         ActionTag(Give([Buff(ChangeAttack(2)), Buff(ChangeHealth(2))]),
                                         SelfSelector()))])
Esempio n. 14
0
 def create_minion(self, player):
     return Minion(6, 3, effects=[Effect(MinionSummoned(IsType(MINION_TYPE.MECH)), ActionTag(Give(DivineShield()),
                                         SelfSelector()))])
Esempio n. 15
0
 def __init__(self):
     super().__init__("Aldor Peacekeeper", 3, CHARACTER_CLASS.PALADIN, CARD_RARITY.RARE,
                      battlecry=Battlecry(Give(SetAttack(1)), MinionSelector(condition=None, players=EnemyPlayer())))
Esempio n. 16
0
 def __init__(self):
     super().__init__("Shrinkmeister", 2, CHARACTER_CLASS.PRIEST, CARD_RARITY.COMMON,
                      battlecry=Battlecry(Give(BuffUntil(ChangeAttack(-2), TurnEnded(player=CurrentPlayer()))),
                                          MinionSelector(players=BothPlayer(), picker=UserPicker())))
Esempio n. 17
0
 def __init__(self):
     super().__init__("Temple Enforcer", 6, CHARACTER_CLASS.PRIEST, CARD_RARITY.COMMON,
                      battlecry=Battlecry(Give(ChangeHealth(3)), MinionSelector(picker=UserPicker())))
Esempio n. 18
0
 def __init__(self):
     super().__init__("Upgraded Repair Bot", 5, CHARACTER_CLASS.PRIEST, CARD_RARITY.RARE,
                      minion_type=MINION_TYPE.MECH,
                      battlecry=Battlecry(Give(ChangeHealth(4)), MinionSelector(IsType(MINION_TYPE.MECH),
                                                                                picker=UserPicker())))
Esempio n. 19
0
 def create_minion(self, player):
     return Minion(2, 3, effects=[Effect(MinionPlaced(AttackLessThanOrEqualTo(3)),
                                         ActionTag(Give(Charge()), TargetSelector()))])
Esempio n. 20
0
 def create_minion(self, player):
     return Minion(2, 4, effects=[Effect(CharacterDamaged(player=BothPlayer(),
                                                          condition=IsMinion()), ActionTag(Give(ChangeAttack(1)),
                                                                                           SelfSelector()))])
Esempio n. 21
0
 def __init__(self):
     super().__init__("Cruel Taskmaster", 2, CHARACTER_CLASS.WARRIOR, CARD_RARITY.COMMON,
                      battlecry=Battlecry([Damage(1), Give(ChangeAttack(2))], MinionSelector(players=BothPlayer(),
                                                                                             picker=UserPicker())))
Esempio n. 22
0
 def __init__(self):
     super().__init__("Screwjank Clunker", 4, CHARACTER_CLASS.WARRIOR, CARD_RARITY.RARE,
                      minion_type=MINION_TYPE.MECH,
                      battlecry=Battlecry(Give([Buff(ChangeHealth(2)), Buff(ChangeAttack(2))]),
                                          MinionSelector(IsType(MINION_TYPE.MECH), picker=UserPicker())))
Esempio n. 23
0
 def __init__(self):
     super().__init__("Windspeaker", 4, CHARACTER_CLASS.SHAMAN, CARD_RARITY.COMMON,
                      battlecry=Battlecry(Give(Windfury()), MinionSelector(picker=UserPicker())))
Esempio n. 24
0
 def __init__(self):
     super().__init__("Bolvar Fordragon", 5, CHARACTER_CLASS.PALADIN, CARD_RARITY.LEGENDARY,
                      effects=[Effect(MinionDied(), ActionTag(Give(ChangeAttack(1)), SelfSelector()))])
Esempio n. 25
0
 def create_minion(self, player):
     return Minion(3,
                   4,
                   deathrattle=Deathrattle(
                       Give(Add(CHARACTER_STATUS.HEALTH, 3)),
                       MinionSelector(picker=RandomPicker())))
Esempio n. 26
0
 def __init__(self):
     super().__init__("Argent Protector", 2, CHARACTER_CLASS.PALADIN, CARD_RARITY.COMMON,
                      battlecry=Battlecry(Give(DivineShield()), MinionSelector()))
Esempio n. 27
0
 def __init__(self):
     super().__init__("Fireguard Destroyer", 4, CHARACTER_CLASS.SHAMAN, CARD_RARITY.COMMON, overload=1,
                      battlecry=Battlecry(Give(Buff(ChangeAttack(RandomAmount(1, 4)))), SelfSelector()))
Esempio n. 28
0
 def __init__(self):
     super().__init__("Quartermaster", 5, CHARACTER_CLASS.PALADIN, CARD_RARITY.EPIC,
                      battlecry=Battlecry(Give([Buff(ChangeAttack(2)), Buff(ChangeHealth(2))]),
                                          MinionSelector(HasCardName("Silver Hand Recruit"))))
Esempio n. 29
0
 def create_minion(self, player):
     return Minion(1, 3, effects=[Effect(SpellCast(), ActionTag(Give(ChangeAttack(1)), SelfSelector()))])
Esempio n. 30
0
 def create_minion(self, player):
     return Minion(0, 1, stealth=True,
                   effects=[Effect(TurnEnded(), ActionTag(Give(ChangeHealth(1)),
                                                          MinionSelector(picker=RandomPicker())))])
Esempio n. 31
0
 def create_minion(self, player):
     return Minion(2, 4, effects=[Effect(CardPlayed(HasOverload()), ActionTag(Give(ChangeAttack(1)),
                                                                              SelfSelector())),
                                  Effect(CardPlayed(HasOverload()), ActionTag(Give(ChangeHealth(1)),
                                                                              SelfSelector()))])
Esempio n. 32
0
 def create_minion(self, player):
     return Minion(3,
                   4,
                   deathrattle=Deathrattle(
                       Give(ChangeHealth(3)),
                       MinionSelector(picker=RandomPicker())))
Esempio n. 33
0
 def create_minion(self, player):
     return Minion(2, 2,
                   effects=[Effect(MinionDied(IsType(MINION_TYPE.BEAST)),
                                   ActionTag(Give(ChangeAttack(2)), SelfSelector())),
                            Effect(MinionDied(IsType(MINION_TYPE.BEAST)),
                                   ActionTag(Give(ChangeHealth(1)), SelfSelector()))])