Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shinoi2 committed Mar 7, 2024
2 parents 1a23f5e + 71c50cb commit ff7ddcc
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 68 deletions.
75 changes: 25 additions & 50 deletions fireplace/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,31 @@ def do(self, source, target, tags):
target.tags[tag] = False


class SetAttribute(TargetedAction):
TARGET = ActionArg()
KEY = ActionArg()
VALUE = ActionArg()

def do(self, source, target, key, value):
setattr(target, key, value)


class DelAttribute(TargetedAction):
TARGET = ActionArg()
KEY = ActionArg()

def do(self, source, target, key):
delattr(target, key)


class GetAttribute(TargetedAction):
TARGET = ActionArg()
KEY = ActionArg()

def do(self, source, target, key):
return getattr(target, key)


class Silence(TargetedAction):
"""
Silence minion targets.
Expand Down Expand Up @@ -2168,53 +2193,3 @@ def do(self, source, target):
source.game.queue_actions(source, [CastSpell(target)])
else:
source.game.queue_actions(source, [Summon(source.controller, target)])


class GriftahAction(TargetedAction):
def picker(self, source, player):
if player.hero.data.card_class != CardClass.NEUTRAL:
# use hero class for Discover if not neutral (eg. Ragnaros)
discover_class = player.hero.data.card_class
elif source.data.card_class != CardClass.NEUTRAL:
# use card class for neutral hero classes
discover_class = source.data.card_class
else:
# use random class for neutral hero classes with neutral cards
discover_class = random_class()
picker = RandomCollectible() * 3
picker = picker.copy_with_weighting(1, card_class=CardClass.NEUTRAL)
picker = picker.copy_with_weighting(4, card_class=discover_class)
return picker.evaluate(source)

def do(self, source, player):
self.player = player
self.source = source
self.min_count = 1
self.max_count = 1
self.choosed_cards = []
self.player.choice = self
self.do_step1()
source.game.manager.targeted_action(self, source, player)

def do_step1(self):
self.cards = self.picker(self.source, self.player)

def do_step2(self):
self.cards = self.picker(self.source, self.player)

def done(self):
random.shuffle(self.choosed_cards)
self.source.controller.give(self.choosed_cards[0])
self.source.controller.opponent.give(self.choosed_cards[1])

def choose(self, card):
if card not in self.cards:
raise InvalidAction("%r is not a valid choice (one of %r)" % (card, self.cards))
else:
self.choosed_cards.append(card)
if len(self.choosed_cards) == 1:
self.do_step2()
elif len(self.choosed_cards) == 2:
self.player.choice = None
self.done()
self.trigger_choice_callback()
9 changes: 7 additions & 2 deletions fireplace/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def clear_progress(self):


class PlayableCard(BaseCard, Entity, TargetableByAuras):
windfury = int_property("windfury")
windfury = boolean_property("windfury")
mega_windfury = boolean_property("mega_windfury")
has_choose_one = boolean_property("has_choose_one")
playable_zone = Zone.HAND
lifesteal = boolean_property("lifesteal")
Expand Down Expand Up @@ -772,7 +773,11 @@ def can_attack(self, target=None):

@property
def max_attacks(self):
return self.windfury + 1
if self.mega_windfury:
return 4
if self.windfury:
return 2
return 1

@property
def exhausted(self):
Expand Down
5 changes: 2 additions & 3 deletions fireplace/cards/brawl/pick_your_fate.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,10 @@ class TB_PickYourFate_3:


class TB_PickYourFate_3_Ench:
events = Play(CONTROLLER, MINION).on(Buff(Play.CARD, "TB_PickYourFate_Windfury"))
events = Play(CONTROLLER, MINION).on(Buff(Play.CARD, "TB_PickYourFate_Windfury", windfury=True))


class TB_PickYourFate_Windfury:
windfury = SET(1)
TB_PickYourFate_Windfury = buff(windfury=True)


class TB_PickYourFate_4:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/classic/neutral_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ class EX1_412:
enrage = Refresh(SELF, buff="EX1_412e")


class EX1_412e:
tags = {GameTag.ATK: +1}
windfury = SET(1)
EX1_412e = buff(atk=1, windfury=True)


class EX1_506:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/debug/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class XXX_051:

class XXX_052:
"""Grant Mega-Windfury"""
play = SetTag(TARGET, {GameTag.WINDFURY: 3})
play = SetTag(TARGET, {GameTag.MEGA_WINDFURY: True})


class XXX_053:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/cards/gvg/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GVG_111:


class GVG_111t:
tags = {GameTag.WINDFURY: 3}
tags = {GameTag.MEGA_WINDFURY: True}


class GVG_112:
Expand Down
3 changes: 1 addition & 2 deletions fireplace/cards/tgt/neutral_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class AT_083:
inspire = Buff(SELF, "AT_083e")


class AT_083e:
windfury = SET(1)
AT_083e = buff(windfury=True)


class AT_084:
Expand Down
16 changes: 15 additions & 1 deletion fireplace/cards/troll/neutral_legendary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@
class TRL_096:
"""Griftah"""
# [x]<b>Battlecry:</b> <b>Discover</b> two cards. Give one to your opponent at random.
play = GriftahAction(CONTROLLER)
play = DISCOVER(RandomCollectible()).then(
SetAttribute(SELF, "_card1", Discover.CARD),
DISCOVER(RandomCollectible()).then(
SetAttribute(SELF, "_card2", Discover.CARD),
COINFLIP & (
Give(CONTROLLER, GetAttribute(SELF, "_card1")),
Give(OPPONENT, GetAttribute(SELF, "_card2")),
) | (
Give(OPPONENT, GetAttribute(SELF, "_card1")),
Give(CONTROLLER, GetAttribute(SELF, "_card2")),
),
DelAttribute(SELF, "_card1"),
DelAttribute(SELF, "_card2"),
)
)


class TRL_537:
Expand Down
4 changes: 1 addition & 3 deletions fireplace/cards/ungoro/adapt_buff.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class UNG_999t2e:
UNG_999t6e = buff(taunt=True)


class UNG_999t7e:
"""Lightning Speed"""
windfury = SET(1)
UNG_999t7e = buff(windfury=True)


class UNG_999t8e:
Expand Down
2 changes: 1 addition & 1 deletion fireplace/dsl/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __neg__(self) -> "Selector":
# Note that here we define negation in terms of subtraction, and
# not the other way around, because selectors are implemented using
# concrete set operations instead of boolean manipulation
return self.__class__() - self
return Selector() - self

def __sub__(self, other: SelectorLike) -> "Selector":
return SetOpSelector(operator.sub, self, other)
Expand Down
1 change: 1 addition & 0 deletions fireplace/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class PlayerManager(Manager):
GameTag.IMMUNE_WHILE_ATTACKING: "immune_while_attacking",
GameTag.INSPIRE: "has_inspire",
GameTag.MAGNETIC: "has_magnetic",
GameTag.MEGA_WINDFURY: "mega_windfury",
GameTag.MULTI_CLASS_GROUP: "multi_class_group",
GameTag.NUM_ATTACKS_THIS_TURN: "num_attacks",
GameTag.NUM_TURNS_IN_PLAY: "turns_in_play",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def test_mimirons_head():
assert len(game.player1.field) == 1
voltron = game.player1.field[0]
assert voltron.id == "GVG_111t"
assert voltron.windfury == 3
assert voltron.mega_windfury
assert voltron.charge
for i in range(4):
assert voltron.can_attack()
Expand Down

0 comments on commit ff7ddcc

Please sign in to comment.