[WHO] Implement Surge of Brilliance

This commit is contained in:
theelk801 2023-10-16 19:05:45 -04:00
parent dd1852352a
commit ffc20316e6
2 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,107 @@
package mage.cards.s;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.ForetellAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.util.CardUtil;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SurgeOfBrilliance extends CardImpl {
public SurgeOfBrilliance(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Paradox -- Draw a card for each spell you've cast this turn from anywhere other than your hand.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(SurgeOfBrillianceValue.instance));
this.getSpellAbility().setAbilityWord(AbilityWord.PARADOX);
this.getSpellAbility().addWatcher(new SurgeOfBrillianceWatcher());
// Foretell {1}{U}
this.addAbility(new ForetellAbility(this, "{1}{U}"));
}
private SurgeOfBrilliance(final SurgeOfBrilliance card) {
super(card);
}
@Override
public SurgeOfBrilliance copy() {
return new SurgeOfBrilliance(this);
}
}
enum SurgeOfBrillianceValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return SurgeOfBrillianceWatcher.getCount(sourceAbility.getControllerId(), game);
}
@Override
public SurgeOfBrillianceValue copy() {
return this;
}
@Override
public String getMessage() {
return "spell you've cast this turn from anywhere other than your hand";
}
@Override
public String toString() {
return "1";
}
}
class SurgeOfBrillianceWatcher extends Watcher {
private final Map<UUID, Integer> map = new HashMap<>();
SurgeOfBrillianceWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.SPELL_CAST) {
return;
}
Spell spell = game.getSpell(event.getSourceId());
if (spell != null && spell.getFromZone() != Zone.HAND) {
map.compute(event.getPlayerId(), CardUtil::setOrIncrementValue);
}
}
@Override
public void reset() {
super.reset();
map.clear();
}
static int getCount(UUID playerId, Game game) {
return game
.getState()
.getWatcher(SurgeOfBrillianceWatcher.class)
.map
.getOrDefault(playerId, 0);
}
}

View file

@ -181,6 +181,7 @@ public final class DoctorWho extends ExpansionSet {
cards.add(new SetCardInfo("Sundown Pass", 310, Rarity.RARE, mage.cards.s.SundownPass.class));
cards.add(new SetCardInfo("Sungrass Prairie", 311, Rarity.RARE, mage.cards.s.SungrassPrairie.class));
cards.add(new SetCardInfo("Sunken Hollow", 312, Rarity.RARE, mage.cards.s.SunkenHollow.class));
cards.add(new SetCardInfo("Surge of Brilliance", 57, Rarity.UNCOMMON, mage.cards.s.SurgeOfBrilliance.class));
cards.add(new SetCardInfo("Swamp", 200, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Swords to Plowshares", 212, Rarity.UNCOMMON, mage.cards.s.SwordsToPlowshares.class));
cards.add(new SetCardInfo("Talisman of Conviction", 247, Rarity.UNCOMMON, mage.cards.t.TalismanOfConviction.class));