Skip to content

Commit

Permalink
[BLC] Implement Pyreswipe Hawk
Browse files Browse the repository at this point in the history
  • Loading branch information
theelk801 committed Aug 6, 2024
1 parent 65164ec commit 1cf91b0
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
99 changes: 99 additions & 0 deletions Mage.Sets/src/mage/cards/p/PyreswipeHawk.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package mage.cards.p;

import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.common.ExpendTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.common.TargetArtifactPermanent;

import java.util.UUID;

/**
* @author TheElk801
*/
public final class PyreswipeHawk extends CardImpl {

public PyreswipeHawk(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}{R}");

this.subtype.add(SubType.ELEMENTAL);
this.subtype.add(SubType.BIRD);
this.power = new MageInt(4);
this.toughness = new MageInt(4);

// Flying
this.addAbility(FlyingAbility.getInstance());

// Haste
this.addAbility(HasteAbility.getInstance());

// Whenever Pyreswipe Hawk attacks, it gets +X/+0 until end of turn, where X is the greatest mana value among artifacts you control.
this.addAbility(new AttacksTriggeredAbility(new BoostSourceEffect(
PyreswipeHawkValue.instance, StaticValue.get(0), Duration.EndOfTurn, "it"
)));

// Whenever you expend 6, gain control of up to one target artifact for as long as you control Pyreswipe Hawk.
Ability ability = new ExpendTriggeredAbility(
new GainControlTargetEffect(Duration.WhileControlled), ExpendTriggeredAbility.Expend.SIX
);
ability.addTarget(new TargetArtifactPermanent(0, 1));
this.addAbility(ability);
}

private PyreswipeHawk(final PyreswipeHawk card) {
super(card);
}

@Override
public PyreswipeHawk copy() {
return new PyreswipeHawk(this);
}
}

enum PyreswipeHawkValue implements DynamicValue {
instance;

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game
.getBattlefield()
.getActivePermanents(
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT,
sourceAbility.getControllerId(), sourceAbility, game
)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);
}

@Override
public PyreswipeHawkValue copy() {
return this;
}

@Override
public String getMessage() {
return "the greatest mana value among artifacts you control";
}

@Override
public String toString() {
return "X";
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/BloomburrowCommander.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ private BloomburrowCommander() {
cards.add(new SetCardInfo("Psychosis Crawler", 282, Rarity.RARE, mage.cards.p.PsychosisCrawler.class));
cards.add(new SetCardInfo("Pull from Tomorrow", 172, Rarity.RARE, mage.cards.p.PullFromTomorrow.class));
cards.add(new SetCardInfo("Putrefy", 257, Rarity.UNCOMMON, mage.cards.p.Putrefy.class));
cards.add(new SetCardInfo("Pyreswipe Hawk", 26, Rarity.RARE, mage.cards.p.PyreswipeHawk.class));
cards.add(new SetCardInfo("Raging Ravine", 324, Rarity.RARE, mage.cards.r.RagingRavine.class));
cards.add(new SetCardInfo("Rain of Riches", 200, Rarity.RARE, mage.cards.r.RainOfRiches.class));
cards.add(new SetCardInfo("Rampaging Baloths", 233, Rarity.MYTHIC, mage.cards.r.RampagingBaloths.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ public class ExpendTriggeredAbility extends TriggeredAbilityImpl {
private static final Hint hint = new ValueHint("Mana you expended this turn", ExpendValue.instance);

/**
* For memory-usage purpose, we only support expend 4 and expend 8 so far.
* For memory-usage purpose, we only support expend 4, expend 6, and expend 8 so far.
*/
public enum Expend {
FOUR(4),
SIX(6),
EIGHT(8);

private final int amount;
Expand Down Expand Up @@ -106,7 +107,7 @@ public String getMessage() {
/**
* Watcher for mana expended this turn.
* <p>
* Of note, to reduce memory usage, only tracks the events that did expend 4 and expend 8.
* Of note, to reduce memory usage, only tracks the events that did expend 4, expend 6, and expend 8.
* If expend N extends to more than a couple values, storing the full list (in order) of event id is advised.
*/
class ExpendWatcher extends Watcher {
Expand All @@ -116,6 +117,8 @@ class ExpendWatcher extends Watcher {

// Player id -> event id for the 4th mana expended this turn
private final Map<UUID, UUID> eventFor4thExpend = new HashMap<>();
// Player id -> event id for the 6th mana expended this turn
private final Map<UUID, UUID> eventFor6thExpend = new HashMap<>();
// Player id -> event id for the 8th mana expended this turn
private final Map<UUID, UUID> eventFor8thExpend = new HashMap<>();

Expand All @@ -141,6 +144,9 @@ public void watch(GameEvent event, Game game) {
case 4:
eventFor4thExpend.put(playerId, eventId);
break;
case 6:
eventFor6thExpend.put(playerId, eventId);
break;
case 8:
eventFor8thExpend.put(playerId, eventId);
break;
Expand All @@ -152,6 +158,7 @@ public void reset() {
super.reset();
manaExpended.clear();
eventFor4thExpend.clear();
eventFor6thExpend.clear();
eventFor8thExpend.clear();
}

Expand All @@ -164,6 +171,9 @@ public static boolean checkExpend(UUID playerId, GameEvent event, ExpendTriggere
case FOUR:
return watcher.eventFor4thExpend.containsKey(playerId)
&& watcher.eventFor4thExpend.get(playerId).equals(event.getId());
case SIX:
return watcher.eventFor6thExpend.containsKey(playerId)
&& watcher.eventFor6thExpend.get(playerId).equals(event.getId());
case EIGHT:
return watcher.eventFor8thExpend.containsKey(playerId)
&& watcher.eventFor8thExpend.get(playerId).equals(event.getId());
Expand Down

0 comments on commit 1cf91b0

Please sign in to comment.