def use(self, player, game): super().use(player, game) query = CardQuery(conditions=[IsMinion()]) new_minon = query.get_card(player, self) new_minon.add_buff(Buff(ManaChange(-3))) player.hand.append(new_minon) new_minon.attach(new_minon, player)
def __init__(self, card, count=1, add_to_deck=False): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.add_to_deck = add_to_deck self.count = count
def use(self, player, game): super().use(player, game) if self.target.health <= player.effective_spell_damage(2) and \ (isinstance(self.target, Minion) and not self.target.divine_shield): self.target.damage(player.effective_spell_damage(2), self) demons = CardQuery(conditions=[IsType(MINION_TYPE.DEMON)]) demons.get_card(player, player, self).summon(player, game, len(player.minions)) else: self.target.damage(player.effective_spell_damage(2), self)
def use(self, player, game): super().use(player, game) if self.target.health <= player.effective_spell_damage(2) and \ (isinstance(self.target, Minion) and not self.target.divine_shield): self.target.damage(player.effective_spell_damage(2), self) demons = CardQuery(conditions=[IsType(MINION_TYPE.DEMON)]) demons.get_card(player, self).summon(player, game, len(player.minions)) else: self.target.damage(player.effective_spell_damage(2), self)
class ApplySecret(Action): def __init__(self, source): self.source = source self._query = CardQuery(conditions=[IsSecret()], source=source) def act(self, actor, target, other=None): secret = self._query.get_card(target, target, actor) if secret: target.secrets.append(secret) secret.player = target if target is target.game.other_player: secret.player = target # To allow for Mad Scientist not to be redeemed or duplicated as a result of its death, # but still allow other minions that die during the same cycle to be duplicated. # Based on testing for patch 2.1.0.7785 if actor.dead: target.bind_once("after_death", secret.activate) else: secret.activate(target) def __to_json__(self): return { 'name': 'apply_secret', 'source': CARD_SOURCE.to_str(self.source) } def __from_json__(self, source): self.source = CARD_SOURCE.from_str(source) self._query = CardQuery(conditions=[IsSecret()], source=self.source) return self
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, actor) if target.is_card(): target.replace(card) elif target.is_minion(): minion = card.create_minion(target.player) minion.card = card target.replace(minion) elif target.is_hero(): hero = card.create_hero(target.player) hero.card = card target.player.trigger("minion_played", actor) hero.buffs = copy.deepcopy(actor.buffs) hero.health = actor.health target.replace(hero) if hero.health <= 0: hero.die(None) def __to_json__(self): return {'name': 'transform', 'card': self.card} def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class ReplaceHeroWithMinion(Action): # Used only for Jaraxxus currently def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, target.player, actor) hero = card.create_hero(target.player) hero.card = card target.player.trigger("minion_played", actor) hero.buffs = copy.deepcopy(actor.buffs) hero.health = actor.health target.replace(hero) if hero.health <= 0: hero.die(None) def __to_json__(self): return { 'name': 'replace_hero_with_minion', 'card': self.card } def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, target.player, actor) if target.is_card(): target.replace(card) elif target.is_minion(): minion = card.create_minion(target.player) minion.card = card target.replace(minion) elif target.is_hero(): hero = card.create_hero(target.player) hero.card = card target.player.trigger("minion_played", actor) hero.buffs = copy.deepcopy(actor.buffs) hero.health = actor.health target.replace(hero) if hero.health <= 0: hero.die(None) def __to_json__(self): return { 'name': 'transform', 'card': self.card } def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class ApplySecret(Action): def __init__(self, source): self.source = source self._query = CardQuery(conditions=[IsSecret()], source=source) def act(self, actor, target, other=None): secret = self._query.get_card(target, actor) if secret: target.secrets.append(secret) secret.player = target if target is target.game.other_player: secret.player = target # To allow for Mad Scientist not to be redeemed or duplicated as a result of its death, # but still allow other minions that die during the same cycle to be duplicated. # Based on testing for patch 2.1.0.7785 if actor.dead: target.bind_once("after_death", secret.activate) else: secret.activate(target) def __to_json__(self): return { 'name': 'apply_secret', 'source': CARD_SOURCE.to_str(self.source) } def __from_json__(self, source): self.source = CARD_SOURCE.from_str(source) self._query = CardQuery(conditions=[IsSecret()], source=self.source) return self
class ApplySecret(Action): def __init__(self, source): self.source = source self._query = CardQuery(conditions=[IsSecret()], source=source) def act(self, actor, target): secret = self._query.get_card(target) if secret: target.secrets.append(secret) secret.player = target if target is target.game.other_player: secret.player = target secret.activate(target) def __to_json__(self): return { 'name': 'apply_secret', 'source': CARD_SOURCE.to_str(self.source) } def __from_json__(self, source): self.source = CARD_SOURCE.from_str(source) self._query = CardQuery(conditions=[IsSecret()], source=self.source) return self
def create_minion(self, player): return Minion( 1, 1, deathrattle=Deathrattle( AddCard(CardQuery(conditions=[IsType(MINION_TYPE.BEAST)])), PlayerSelector()))
def create_minion(self, player): return Minion(5, 8, effects=[Effect(SpellCast(Not(HasCardName("Gallywix's Coin")), EnemyPlayer()), ActionTag(AddCard(CardQuery(source=CARD_SOURCE.LAST_CARD)), PlayerSelector(FriendlyPlayer()))), Effect(SpellCast(Not(HasCardName("Gallywix's Coin")), EnemyPlayer()), ActionTag(AddCard(GallywixsCoin()), PlayerSelector(EnemyPlayer())))])
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, target.player, actor) if target.is_card(): target.replace(card) elif target.is_minion(): minion = card.create_minion(target.player) minion.card = card target.replace(minion) elif target.is_hero(): hero = card.create_hero(target.player) target.replace(hero) def __to_json__(self): return { 'name': 'transform', 'card': self.card } def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, target.player, actor) if target.is_card(): target.replace(card) elif target.is_minion(): minion = card.create_minion(target.player) minion.card = card target.replace(minion) elif target.is_hero(): hero = card.create_hero(target.player) target.replace(hero) def __to_json__(self): return {'name': 'transform', 'card': self.card} def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
def __init__(self): from hearthbreaker.cards.minions.neutral import BluegillWarrior, ColdlightOracle, ColdlightSeer, \ GrimscaleOracle, MurlocRaider, MurlocTidecaller, MurlocTidehunter, MurlocWarleader, OldMurkEye, \ Puddlestomper murloc_list = [ BluegillWarrior(), ColdlightOracle(), ColdlightSeer(), GrimscaleOracle(), MurlocRaider(), MurlocTidecaller(), MurlocTidehunter(), MurlocWarleader(), OldMurkEye(), Puddlestomper(), SiltfinSpiritwalker() ] super().__init__("Neptulon", 7, CHARACTER_CLASS.SHAMAN, CARD_RARITY.LEGENDARY, overload=3, battlecry=Battlecry( AddCard( CardQuery(source=CARD_SOURCE.LIST, source_list=murloc_list), 4), PlayerSelector()))
class ReplaceHeroWithMinion(Action): # Used only for Jaraxxus currently def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target, other=None): card = self.card.get_card(target, target.player, actor) hero = card.create_hero(target.player) hero.card = card target.player.trigger("minion_played", actor) hero.buffs = copy.deepcopy(actor.buffs) hero.health = actor.health target.replace(hero) if hero.health <= 0: hero.die(None) def __to_json__(self): return {'name': 'replace_hero_with_minion', 'card': self.card} def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
def create_minion(self, player): return Minion(3, 4, deathrattle=Deathrattle( Summon( CardQuery(conditions=[IsType(MINION_TYPE.DEMON)], source=CARD_SOURCE.MY_HAND)), PlayerSelector()))
def create_minion(self, player): return Minion(9, 7, deathrattle=[ Deathrattle( AddCard(CardQuery(source=CARD_SOURCE.MINION, minion=SelfSelector()), add_to_deck=True), PlayerSelector()), Deathrattle(Remove(), SelfSelector()) ])
def create_minion(self, player): return Minion(7, 6, effects=[ Effect( Damaged(), ActionTag( AddCard( CardQuery(source=CARD_SOURCE.LIST, source_list=spare_part_list)), PlayerSelector())) ])
class AddCard(Action): def __init__(self, card, count=1, add_to_deck=False): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.add_to_deck = add_to_deck self.count = count def act(self, actor, target, other=None): if self.add_to_deck: for i in range(self.count): target.deck.put_back(self.card.get_card(target, target, actor)) else: for i in range(self.count): if len(target.hand) < 10: card = self.card.get_card(target, target, actor) if card: target.hand.append(copy.copy(card)) card.drawn = True def __to_json__(self): if self.add_to_deck: return { 'name': 'add_card', 'card': self.card, 'count': self.count, 'add_to_deck': self.add_to_deck, } return { 'name': 'add_card', 'card': self.card, 'count': self.count } def __from_json__(self, card, count=1, add_to_deck=False): self.card = CardQuery.from_json(**card) self.count = count self.add_to_deck = add_to_deck return self
class AddCard(Action): def __init__(self, card, count=1, add_to_deck=False): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.add_to_deck = add_to_deck self.count = count def act(self, actor, target, other=None): if self.add_to_deck: for i in range(self.count): target.deck.put_back(self.card.get_card(target, actor)) else: for i in range(self.count): if len(target.hand) < 10: card = self.card.get_card(target, actor) if card: target.hand.append(card) def __to_json__(self): if self.add_to_deck: return { 'name': 'add_card', 'card': self.card, 'count': self.count, 'add_to_deck': self.add_to_deck, } return { 'name': 'add_card', 'card': self.card, 'count': self.count } def __from_json__(self, card, count=1, add_to_deck=False): self.card = CardQuery.from_json(**card) self.count = count self.add_to_deck = add_to_deck return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target): card = self.card.get_card(target) if card is None: return if actor.is_minion() and actor.player is target: # Cenaurius and Dr. Boom are special snowflakes that summon minions on either side of themselves if self.count == 2: card.summon(target, target.game, actor.index) card.summon(target, target.game, actor.index + 1) else: if actor.removed: index = actor.index else: index = actor.index + 1 for summon in range(self.count): card.summon(target, target.game, index) index += 1 else: for summon in range(self.count): card.summon(target, target.game, len(target.minions)) def __to_json__(self): if self.count > 1: return { 'name': 'summon', 'card': self.card, 'count': self.count } return { 'name': 'summon', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target, other=None): card = self.card.get_card(target, actor) if card is None: return if actor.is_minion() and actor.player is target: # When a minion is summoned around another minion, they alternate between left and right, # starting on the right if actor.removed: c = 0 else: c = 1 for summon in range(self.count): index = actor.index + (c % 2) card.summon(target, target.game, index) if not actor.removed: c += 1 else: for summon in range(self.count): card.summon(target, target.game, len(target.minions)) def __to_json__(self): if self.count > 1: return { 'name': 'summon', 'card': self.card, 'count': self.count } return { 'name': 'summon', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target, other=None): card = self.card.get_card(target, target, actor) if card is None: return if actor.is_minion() and actor.player is target: # When a minion is summoned around another minion, they alternate between left and right, # starting on the right if actor.removed: c = 0 else: c = 1 for summon in range(self.count): index = actor.index + (c % 2) card.summon(target, target.game, index) if not actor.removed: c += 1 else: for summon in range(self.count): card.summon(target, target.game, len(target.minions)) def __to_json__(self): if self.count > 1: return { 'name': 'summon', 'card': self.card, 'count': self.count } return { 'name': 'summon', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
def __init__(self): super().__init__("Burrowing Mine", 0, CHARACTER_CLASS.WARRIOR, CARD_RARITY.COMMON, False, effects=[ Effect(Drawn(), ActionTag(Damage(10), HeroSelector())), Effect( Drawn(), ActionTag( Discard(query=CardQuery( source=CARD_SOURCE.LAST_DRAWN)), PlayerSelector())), Effect(Drawn(), ActionTag(Draw(), PlayerSelector())) ])
class Equip(Action): def __init__(self, weapon): if isinstance(weapon, CardQuery): self.weapon = weapon else: self.weapon = CardQuery(weapon.ref_name) def act(self, actor, target): card = self.weapon.get_card(target) weapon = card.create_weapon(target) weapon.equip(target) def __to_json__(self): return {'name': 'equip', 'weapon': self.weapon} def __from_json__(self, weapon): self.weapon = CardQuery.from_json(**weapon) return self
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target): card = self.card.get_card(target) minion = card.create_minion(target.player) minion.card = card target.replace(minion) def __to_json__(self): return {'name': 'transform', 'card': self.card} def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target): if actor.is_minion(): if actor.removed: index = actor.index else: index = actor.index + 1 else: for summon in range(self.count): index = len(target.minions) card = self.card.get_card(target) if card is None: return # TODO add explicit patters for multi minion summoning (if there is ever more than two) for summon in range(self.count): card.summon(target, target.game, index) if actor.is_minion(): index = actor.index # Move the later minions to the left of their originator def __to_json__(self): if self.count > 1: return { 'name': 'summon', 'card': self.card, 'count': self.count } return { 'name': 'summon', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class AddCard(Action): def __init__(self, card): if isinstance(card, hearthbreaker.game_objects.Card): self.card = CardQuery(card.name) else: self.card = card def act(self, actor, target): if len(target.hand) < 10: target.hand.append(self.card.get_card(target)) def __to_json__(self): return { 'name': 'add_card', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) return self
class AddCard(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target): for i in range(self.count): if len(target.hand) < 10: target.hand.append(self.card.get_card(target)) def __to_json__(self): return {'name': 'add_card', 'card': self.card, 'count': self.count} def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class Equip(Action): def __init__(self, weapon): if isinstance(weapon, CardQuery): self.weapon = weapon else: self.weapon = CardQuery(weapon.ref_name) def act(self, actor, target): card = self.weapon.get_card(target) weapon = card.create_weapon(target) weapon.equip(target) def __to_json__(self): return { 'name': 'equip', 'weapon': self.weapon } def __from_json__(self, weapon): self.weapon = CardQuery.from_json(**weapon) return self
class Transform(Action): def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) def act(self, actor, target): card = self.card.get_card(target) minion = card.create_minion(target.player) minion.card = card target.replace(minion) def __to_json__(self): return { 'name': 'transform', 'card': self.card } def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, hearthbreaker.game_objects.Card): self.card = CardQuery(card.name) else: self.card = card self.count = count def act(self, actor, target): if isinstance(actor, hearthbreaker.game_objects.Minion): if actor.removed: index = actor.index else: index = actor.index + 1 else: for summon in range(self.count): index = len(target.minions) card = self.card.get_card(target) for summon in range(self.count): card.summon(target, target.game, index) def __to_json__(self): if self.count > 1: return { 'name': 'summon', 'card': self.card, 'count': self.count } return { 'name': 'summon', 'card': self.card } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class Summon(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target): if actor.is_minion(): if actor.removed: index = actor.index else: index = actor.index + 1 else: for summon in range(self.count): index = len(target.minions) card = self.card.get_card(target) if card is None: return # TODO add explicit patters for multi minion summoning (if there is ever more than two) for summon in range(self.count): card.summon(target, target.game, index) if actor.is_minion(): index = actor.index # Move the later minions to the left of their originator def __to_json__(self): if self.count > 1: return {'name': 'summon', 'card': self.card, 'count': self.count} return {'name': 'summon', 'card': self.card} def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
class AddCard(Action): def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count def act(self, actor, target): for i in range(self.count): if len(target.hand) < 10: target.hand.append(self.card.get_card(target)) def __to_json__(self): return { 'name': 'add_card', 'card': self.card, 'count': self.count } def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
def __from_json__(self, card, count=1): self.card = CardQuery.from_json(**card) self.count = count return self
def __init__(self, card, count=1): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name) self.count = count
def __from_json__(self, query): self.query = CardQuery.from_json(**query) return self
def __init__(self, weapon): if isinstance(weapon, CardQuery): self.weapon = weapon else: self.weapon = CardQuery(weapon.ref_name)
def __from_json__(self, source): self.source = CARD_SOURCE.from_str(source) self._query = CardQuery(conditions=[IsSecret()], source=self.source) return self
def __from_json__(self, secrets): self.secrets = CardQuery.from_json(secrets) return self
def __init__(self, card): if isinstance(card, CardQuery): self.card = card else: self.card = CardQuery(card.ref_name)
def __from_json__(self, card, count=1, add_to_deck=False): self.card = CardQuery.from_json(**card) self.count = count self.add_to_deck = add_to_deck return self
def __from_json__(self, card): self.card = CardQuery.from_json(**card) return self
def use(self, player, game): super().use(player, game) query = CardQuery(conditions=[IsMinion()]) new_minon = query.get_card(player, player, self) new_minon.add_buff(Buff(ManaChange(-3))) player.hand.append(new_minon)
def __from_json__(self, weapon): self.weapon = CardQuery.from_json(**weapon) return self
def __init__(self, source): self.source = source self._query = CardQuery(conditions=[IsSecret()], source=source)
def __from_json__(self, card, count=1, add_to_deck=False): self.card = CardQuery.from_json(card) self.count = count self.add_to_deck = add_to_deck return self
def __from_json__(self, query, amount): self.amount = amount self.query = CardQuery.from_json(**query) return self
def __from_json__(self, query): self.query = CardQuery.from_json(query) return self
def use(self, player, game): super().use(player, game) query = CardQuery(conditions=[HasCardName("Malorne")]) new_minon = query.get_card(player, player, self) player.hand.append(new_minon)
def __init__(self, query=CardQuery(source=CARD_SOURCE.MY_HAND)): super().__init__() self.query = query
def __init__(self, card): if isinstance(card, hearthbreaker.game_objects.Card): self.card = CardQuery(card.name) else: self.card = card