[LCI] Implement Enterprising Scallywag

This commit is contained in:
theelk801 2023-10-28 10:04:33 -04:00
parent 39b2e3401a
commit fb0917c4e6
5 changed files with 163 additions and 0 deletions

View file

@ -0,0 +1,46 @@
package mage.cards.e;
import mage.MageInt;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.condition.common.DescendedThisTurnCondition;
import mage.abilities.dynamicvalue.common.DescendedThisTurnCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.permanent.token.TreasureToken;
import mage.watchers.common.DescendedWatcher;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class EnterprisingScallywag extends CardImpl {
public EnterprisingScallywag(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.GOBLIN);
this.subtype.add(SubType.PIRATE);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// At the beginning of your end step, if you descended this turn, create a Treasure token.
this.addAbility(new BeginningOfEndStepTriggeredAbility(
new CreateTokenEffect(new TreasureToken()), TargetController.YOU,
DescendedThisTurnCondition.instance, false
).addHint(DescendedThisTurnCount.getHint()), new DescendedWatcher());
}
private EnterprisingScallywag(final EnterprisingScallywag card) {
super(card);
}
@Override
public EnterprisingScallywag copy() {
return new EnterprisingScallywag(this);
}
}

View file

@ -38,6 +38,7 @@ public final class TheLostCavernsOfIxalan extends ExpansionSet {
cards.add(new SetCardInfo("Deeproot Pilgrimage", 52, Rarity.RARE, mage.cards.d.DeeprootPilgrimage.class));
cards.add(new SetCardInfo("Didact Echo", 53, Rarity.COMMON, mage.cards.d.DidactEcho.class));
cards.add(new SetCardInfo("Dinotomaton", 144, Rarity.COMMON, mage.cards.d.Dinotomaton.class));
cards.add(new SetCardInfo("Enterprising Scallywag", 148, Rarity.UNCOMMON, mage.cards.e.EnterprisingScallywag.class));
cards.add(new SetCardInfo("Forest", 401, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Geological Appraiser", 150, Rarity.UNCOMMON, mage.cards.g.GeologicalAppraiser.class));
cards.add(new SetCardInfo("Get Lost", 14, Rarity.RARE, mage.cards.g.GetLost.class));

View file

@ -0,0 +1,23 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.common.DescendedWatcher;
/**
* @author TheElk801
*/
public enum DescendedThisTurnCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return DescendedWatcher.getDescendedCount(source.getControllerId(), game) > 0;
}
@Override
public String toString() {
return "you descended this turn";
}
}

View file

@ -0,0 +1,41 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.game.Game;
import mage.watchers.common.DescendedWatcher;
/**
* @author TheElk801
*/
public enum DescendedThisTurnCount implements DynamicValue {
instance;
private static final Hint hint = new ValueHint("Permanent cards put into your graveyard this turn", instance);
public static Hint getHint() {
return hint;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return DescendedWatcher.getDescendedCount(sourceAbility.getControllerId(), game);
}
@Override
public DescendedThisTurnCount copy() {
return this;
}
@Override
public String getMessage() {
return "the number of times you descended this turn";
}
@Override
public String toString() {
return "X";
}
}

View file

@ -0,0 +1,52 @@
package mage.watchers.common;
import mage.cards.Card;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.util.CardUtil;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public class DescendedWatcher extends Watcher {
private final Map<UUID, Integer> playerMap = new HashMap<>();
public DescendedWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.ZONE_CHANGE) {
return;
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Card card = game.getCard(zEvent.getTargetId());
if (card != null && zEvent.getToZone() == Zone.GRAVEYARD) {
playerMap.compute(card.getOwnerId(), CardUtil::setOrIncrementValue);
}
}
@Override
public void reset() {
super.reset();
playerMap.clear();
}
public static int getDescendedCount(UUID playerId, Game game) {
return game
.getState()
.getWatcher(DescendedWatcher.class)
.playerMap
.getOrDefault(playerId, 0);
}
}