Skip to content

Commit

Permalink
Rewrite Twinspell
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Apr 2, 2024
1 parent 1ecc607 commit eab329e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 64 deletions.
6 changes: 6 additions & 0 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ def do(self, source, card, target, index, choose):
# We need to fake a Summon broadcast.
summon_action = Summon(player, card)

if card.type == CardType.SPELL and card.twinspell:
source.game.queue_actions(card, [Give(player, card.twinspell_copy)])

if card.type in (CardType.MINION, CardType.WEAPON):
self.queue_broadcast(summon_action, (player, EventListener.ON, player, card))
self.broadcast(player, EventListener.ON, player, card, target)
Expand Down Expand Up @@ -1800,6 +1803,9 @@ def do(self, source, card, targets):
player = source.controller
old_choice = player.choice
player.choice = None

if card.twinspell:
source.game.queue_actions(card, [Give(player, card.twinspell_copy)])
if card.must_choose_one:
card = random.choice(card.choose_cards)
for target in targets:
Expand Down
11 changes: 11 additions & 0 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,12 +1139,23 @@ def can_attack(self, target=None):

class Spell(PlayableCard):
spelltype = enums.SpellType.INVALID
twinspell = boolean_property("twinspell")

def __init__(self, data):
self.immune_to_spellpower = False
self.receives_double_spelldamage_bonus = False
super().__init__(data)

@property
def twinspell_copy(self):
if self._twinspell_copy:
return cards.db.dbf[self._twinspell_copy]
return None

@twinspell_copy.setter
def twinspell_copy(self, value):
self._twinspell_copy = value

def dump(self):
data = super().dump()
data["spelltype"] = int(self.spelltype)
Expand Down
18 changes: 6 additions & 12 deletions fireplace/cards/dalaran/druid.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,11 @@ class DAL_256:
requirements = {
PlayReq.REQ_NUM_MINION_SLOTS: 1,
}
play = Give(CONTROLLER, "DAL_256ts"), Summon(CONTROLLER, "DAL_256t2") * 5
play = Summon(CONTROLLER, "DAL_256t2") * 5


class DAL_256ts:
requirements = {
PlayReq.REQ_NUM_MINION_SLOTS: 1,
}
play = Summon(CONTROLLER, "DAL_256t2") * 5
class DAL_256ts(DAL_256):
pass


class DAL_350:
Expand Down Expand Up @@ -99,14 +96,11 @@ class DAL_351:
requirements = {
PlayReq.REQ_MINION_TARGET: 0,
}
play = Give(CONTROLLER, "DAL_351ts"), Buff(FRIENDLY_MINIONS, "DAL_351e")
play = Buff(FRIENDLY_MINIONS, "DAL_351e")


class DAL_351ts:
requirements = {
PlayReq.REQ_MINION_TARGET: 0,
}
play = Buff(FRIENDLY_MINIONS, "DAL_351e")
class DAL_351ts(DAL_351):
pass


DAL_351e = buff(+1, +1)
Expand Down
18 changes: 6 additions & 12 deletions fireplace/cards/dalaran/hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ class DAL_373:
requirements = {
PlayReq.REQ_TARGET_TO_PLAY: 0,
}
play = Give(CONTROLLER, "DAL_373ts"), Hit(TARGET, 1)
play = Hit(TARGET, 1)


class DAL_373ts:
requirements = {
PlayReq.REQ_TARGET_TO_PLAY: 0,
}
play = Hit(TARGET, 1)
class DAL_373ts(DAL_373):
pass


class DAL_377:
Expand All @@ -96,14 +93,11 @@ class DAL_378:
requirements = {
PlayReq.REQ_NUM_MINION_SLOTS: 1,
}
play = Give(CONTROLLER, "DAL_378ts"), Summon(CONTROLLER, "DAL_378t1")
play = Summon(CONTROLLER, "DAL_378t1")


class DAL_378ts:
requirements = {
PlayReq.REQ_NUM_MINION_SLOTS: 1,
}
play = Summon(CONTROLLER, "DAL_378t1")
class DAL_378ts(DAL_378):
pass


class DAL_589:
Expand Down
26 changes: 6 additions & 20 deletions fireplace/cards/dalaran/mage.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,11 @@ class DAL_177:
PlayReq.REQ_TARGET_TO_PLAY: 0,
PlayReq.REQ_MINION_TARGET: 0,
}
play = (
Give(CONTROLLER, "DAL_177ts"),
Destroy(TARGET), Summon(CONTROLLER, RandomMinion(cost=COST(TARGET))) * 2
)
play = Destroy(TARGET), Summon(CONTROLLER, RandomMinion(cost=COST(TARGET))) * 2


class DAL_177ts:
requirements = {
PlayReq.REQ_TARGET_TO_PLAY: 0,
PlayReq.REQ_MINION_TARGET: 0,
}
play = Destroy(TARGET), Summon(CONTROLLER, RandomMinion(cost=COST(TARGET))) * 2
class DAL_177ts(DAL_177):
pass


class DAL_577:
Expand All @@ -85,18 +78,11 @@ class DAL_577:
PlayReq.REQ_TARGET_TO_PLAY: 0,
PlayReq.REQ_MINION_TARGET: 0,
}
play = (
Give(CONTROLLER, "DAL_577ts"),
Find(TARGET + FROZEN) & Hit(TARGET, 2) | Freeze(TARGET)
)
play = Find(TARGET + FROZEN) & Hit(TARGET, 2) | Freeze(TARGET)


class DAL_577ts:
requirements = {
PlayReq.REQ_TARGET_TO_PLAY: 0,
PlayReq.REQ_MINION_TARGET: 0,
}
play = Find(TARGET + FROZEN) & Hit(TARGET, 2) | Freeze(TARGET)
class DAL_577ts(DAL_577):
pass


class DAL_578:
Expand Down
26 changes: 6 additions & 20 deletions fireplace/cards/dalaran/paladin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@ class DAL_141:
requirements = {
PlayReq.REQ_SECRET_ZONE_CAP_FOR_NON_SECRET: 0,
}
play = (
Give(CONTROLLER, "DAL_141ts"),
CastSpell(RandomSpell(secret=True, card_class=CardClass.PALADIN))
)
play = CastSpell(RandomSpell(secret=True, card_class=CardClass.PALADIN))


class DAL_141ts:
requirements = {
PlayReq.REQ_SECRET_ZONE_CAP_FOR_NON_SECRET: 0,
}
play = CastSpell(RandomSpell(secret=True, card_class=CardClass.PALADIN))
class DAL_141ts(DAL_141):
pass


class DAL_568:
Expand All @@ -61,19 +55,11 @@ class DAL_568:
PlayReq.REQ_MINION_TARGET: 0,
PlayReq.REQ_FRIENDLY_TARGET: 0,
}
play = (
Give(CONTROLLER, "DAL_568ts"),
GiveLifesteal(TARGET)
)
play = GiveLifesteal(TARGET)


class DAL_568ts:
requirements = {
PlayReq.REQ_TARGET_TO_PLAY: 0,
PlayReq.REQ_MINION_TARGET: 0,
PlayReq.REQ_FRIENDLY_TARGET: 0,
}
play = GiveLifesteal(TARGET)
class DAL_568ts(DAL_568):
pass


class DAL_570:
Expand Down
2 changes: 2 additions & 0 deletions fireplace/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ class PlayerManager(Manager):
GameTag.NUM_ATTACKS_THIS_TURN: "num_attacks",
GameTag.NUM_TURNS_IN_PLAY: "turns_in_play",
GameTag.TAG_ONE_TURN_EFFECT: "one_turn_effect",
GameTag.TWINSPELL: "twinspell",
GameTag.TWINSPELL_COPY: "twinspell_copy",
GameTag.OVERLOAD: "overload",
GameTag.OVERKILL: "has_overkill",
GameTag.PARENT_CARD: "parent_card",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_dalaran.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,13 @@ def test_zayle():
game.start()
assert len(game.player1.starting_deck) == 30
assert len(game.player2.starting_deck) == 30


def test_twin_spell():
game = prepare_game()
twin_spell = game.player1.give("DAL_141")
game.player1.give("EX1_095").play()
while len(game.player1.hand) < game.player1.max_hand_size:
game.player1.give(WISP)
twin_spell.play()
assert game.player1.hand[-1].id == "DAL_141ts"

0 comments on commit eab329e

Please sign in to comment.