Implemented Alena, Kessig Trapper

This commit is contained in:
Evan Kranzler 2020-08-24 12:52:25 -04:00
parent bd413d2749
commit 6ee21293d0
2 changed files with 123 additions and 0 deletions

View file

@ -0,0 +1,122 @@
package mage.cards.a;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.MageObjectReference;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.keyword.PartnerAbility;
import mage.abilities.mana.DynamicManaAbility;
import mage.constants.*;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.watchers.Watcher;
/**
* @author TheElk801
*/
public final class AlenaKessigTrapper extends CardImpl {
public AlenaKessigTrapper(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SCOUT);
this.power = new MageInt(4);
this.toughness = new MageInt(3);
// First strike
this.addAbility(FirstStrikeAbility.getInstance());
// {T}: Add an amount of {R} equal to the greatest power among creatures you control that entered the battlefield this turn.
this.addAbility(new DynamicManaAbility(
Mana.RedMana(1), AlenaKessigTrapperValue.instance, new TapSourceCost(), "Add an amount of {R} " +
"equal to the greatest power among creatures you control that entered the battlefield this turn."
), new AlenaKessigTrapperWatcher());
// Partner
this.addAbility(PartnerAbility.getInstance());
}
private AlenaKessigTrapper(final AlenaKessigTrapper card) {
super(card);
}
@Override
public AlenaKessigTrapper copy() {
return new AlenaKessigTrapper(this);
}
}
enum AlenaKessigTrapperValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
AlenaKessigTrapperWatcher watcher = game.getState().getWatcher(AlenaKessigTrapperWatcher.class);
if (watcher == null) {
return 0;
}
return watcher.getPower(sourceAbility.getControllerId(), game);
}
@Override
public AlenaKessigTrapperValue copy() {
return instance;
}
@Override
public String getMessage() {
return "";
}
}
class AlenaKessigTrapperWatcher extends Watcher {
private final Set<MageObjectReference> enteredThisTurn = new HashSet<>();
public AlenaKessigTrapperWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) {
enteredThisTurn.add(new MageObjectReference(event.getTargetId(), game));
}
}
@Override
public void reset() {
enteredThisTurn.clear();
super.reset();
}
int getPower(UUID playerId, Game game) {
return enteredThisTurn
.stream()
.filter(Objects::nonNull)
.map(mor -> mor.getPermanent(game))
.filter(Objects::nonNull)
.filter(MageObject::isCreature)
.filter(permanent -> permanent.isControlledBy(playerId))
.map(MageObject::getPower)
.mapToInt(MageInt::getValue)
.max()
.orElse(0);
}
}

View file

@ -27,6 +27,7 @@ public final class CommanderLegends extends ExpansionSet {
this.ratioBoosterMythic = 8;
this.maxCardNumberInBooster = 361;
cards.add(new SetCardInfo("Alena, Kessig Trapper", 160, Rarity.UNCOMMON, mage.cards.a.AlenaKessigTrapper.class));
cards.add(new SetCardInfo("Command Tower", 350, Rarity.COMMON, mage.cards.c.CommandTower.class));
cards.add(new SetCardInfo("Commander's Sphere", 306, Rarity.COMMON, mage.cards.c.CommandersSphere.class));
cards.add(new SetCardInfo("Keeper of the Accord", 27, Rarity.RARE, mage.cards.k.KeeperOfTheAccord.class));