mirror of
https://github.com/correl/mage.git
synced 2024-12-27 11:07:39 +00:00
[NCC] Implemented Indulge // Excess
This commit is contained in:
parent
8ff9a221be
commit
41d6596bac
2 changed files with 157 additions and 0 deletions
156
Mage.Sets/src/mage/cards/i/IndulgeExcess.java
Normal file
156
Mage.Sets/src/mage/cards/i/IndulgeExcess.java
Normal file
|
@ -0,0 +1,156 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagedEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.CitizenGreenWhiteToken;
|
||||
import mage.game.permanent.token.TreasureToken;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class IndulgeExcess extends SplitCard {
|
||||
|
||||
public IndulgeExcess(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(
|
||||
ownerId, setInfo,
|
||||
new CardType[]{CardType.SORCERY}, new CardType[]{CardType.SORCERY},
|
||||
"{2}{R}", "{1}{R}", SpellAbilityType.SPLIT_AFTERMATH
|
||||
);
|
||||
|
||||
// Indulge
|
||||
// Whenever a creature you control attacks this turn, create a 1/1 green and white Citizen creature token that's tapped and attacking.
|
||||
this.getLeftHalfCard().getSpellAbility().addEffect(
|
||||
new CreateDelayedTriggeredAbilityEffect(new IndulgeTriggeredAbility())
|
||||
);
|
||||
|
||||
// Excess
|
||||
// Aftermath
|
||||
// Create a Treasure token for each creature you controlled that dealt combat damage to a player this turn.
|
||||
this.getRightHalfCard().getSpellAbility().addEffect(
|
||||
new CreateTokenEffect(new TreasureToken(), ExcessValue.instance)
|
||||
);
|
||||
this.getRightHalfCard().getSpellAbility().addWatcher(new ExcessWatcher());
|
||||
}
|
||||
|
||||
private IndulgeExcess(final IndulgeExcess card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndulgeExcess copy() {
|
||||
return new IndulgeExcess(this);
|
||||
}
|
||||
}
|
||||
|
||||
class IndulgeTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
IndulgeTriggeredAbility() {
|
||||
super(new CreateTokenEffect(
|
||||
new CitizenGreenWhiteToken(), 1, true, true
|
||||
), Duration.EndOfTurn, false, false);
|
||||
}
|
||||
|
||||
private IndulgeTriggeredAbility(final IndulgeTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndulgeTriggeredAbility copy() {
|
||||
return new IndulgeTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACKER_DECLARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return isControlledBy(game.getControllerId(event.getSourceId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "Whenever a creature you control attacks this turn, ";
|
||||
}
|
||||
}
|
||||
|
||||
enum ExcessValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
return ExcessWatcher.getCount(sourceAbility.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExcessValue copy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "creature you controlled that dealt combat damage to a player this turn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
class ExcessWatcher extends Watcher {
|
||||
|
||||
private final Map<UUID, Set<MageObjectReference>> map = new HashMap<>();
|
||||
|
||||
ExcessWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() != GameEvent.EventType.DAMAGED_PLAYER || !((DamagedEvent) event).isCombatDamage()) {
|
||||
return;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent == null) {
|
||||
return;
|
||||
}
|
||||
map.computeIfAbsent(
|
||||
permanent.getControllerId(), x -> new HashSet<>()
|
||||
).add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
map.clear();
|
||||
}
|
||||
|
||||
static int getCount(UUID playerId, Game game) {
|
||||
return game
|
||||
.getState()
|
||||
.getWatcher(ExcessWatcher.class)
|
||||
.map
|
||||
.getOrDefault(playerId, Collections.emptySet())
|
||||
.size();
|
||||
}
|
||||
}
|
|
@ -153,6 +153,7 @@ public final class NewCapennaCommander extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Idol of Oblivion", 368, Rarity.RARE, mage.cards.i.IdolOfOblivion.class));
|
||||
cards.add(new SetCardInfo("Incubation Druid", 296, Rarity.RARE, mage.cards.i.IncubationDruid.class));
|
||||
cards.add(new SetCardInfo("Indrik Stomphowler", 297, Rarity.UNCOMMON, mage.cards.i.IndrikStomphowler.class));
|
||||
cards.add(new SetCardInfo("Indulge // Excess", 46, Rarity.RARE, mage.cards.i.IndulgeExcess.class));
|
||||
cards.add(new SetCardInfo("Industrial Advancement", 47, Rarity.RARE, mage.cards.i.IndustrialAdvancement.class));
|
||||
cards.add(new SetCardInfo("Inferno Titan", 269, Rarity.MYTHIC, mage.cards.i.InfernoTitan.class));
|
||||
cards.add(new SetCardInfo("Inkfathom Witch", 342, Rarity.UNCOMMON, mage.cards.i.InkfathomWitch.class));
|
||||
|
|
Loading…
Reference in a new issue