mirror of
https://github.com/correl/mage.git
synced 2025-04-13 01:01:11 -09:00
[STX] Implemented Maelstrom Muse
This commit is contained in:
parent
c080a02d36
commit
6e83886923
2 changed files with 143 additions and 0 deletions
Mage.Sets/src/mage
142
Mage.Sets/src/mage/cards/m/MaelstromMuse.java
Normal file
142
Mage.Sets/src/mage/cards/m/MaelstromMuse.java
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
package mage.cards.m;
|
||||||
|
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.SpellAbility;
|
||||||
|
import mage.abilities.common.AttacksTriggeredAbility;
|
||||||
|
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||||
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
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 MaelstromMuse extends CardImpl {
|
||||||
|
|
||||||
|
public MaelstromMuse(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U/R}{R}");
|
||||||
|
|
||||||
|
this.subtype.add(SubType.DJINN);
|
||||||
|
this.subtype.add(SubType.WIZARD);
|
||||||
|
this.power = new MageInt(2);
|
||||||
|
this.toughness = new MageInt(4);
|
||||||
|
|
||||||
|
// Flying
|
||||||
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
|
|
||||||
|
// Whenever Maelstrom Muse attacks, the next instant or sorcery spell you cast this turn costs {X} less to cast, where X is Maelstrom Muse's power as this ability resolves.
|
||||||
|
this.addAbility(new AttacksTriggeredAbility(
|
||||||
|
new MaelstromMuseEffect(), false
|
||||||
|
), new MaelstromMuseWatcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
private MaelstromMuse(final MaelstromMuse card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaelstromMuse copy() {
|
||||||
|
return new MaelstromMuse(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MaelstromMuseEffect extends CostModificationEffectImpl {
|
||||||
|
|
||||||
|
private int spellsCast;
|
||||||
|
private int sourcePower = 0;
|
||||||
|
|
||||||
|
MaelstromMuseEffect() {
|
||||||
|
super(Duration.EndOfTurn, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||||
|
staticText = "the next instant or sorcery spell you cast this turn costs {X} less to cast, " +
|
||||||
|
"where X is {this}'s power as this ability resolves";
|
||||||
|
}
|
||||||
|
|
||||||
|
private MaelstromMuseEffect(final MaelstromMuseEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.spellsCast = effect.spellsCast;
|
||||||
|
this.sourcePower = effect.sourcePower;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Ability source, Game game) {
|
||||||
|
super.init(source, game);
|
||||||
|
MaelstromMuseWatcher watcher = game.getState().getWatcher(MaelstromMuseWatcher.class);
|
||||||
|
if (watcher != null) {
|
||||||
|
spellsCast = watcher.getCount(source.getControllerId());
|
||||||
|
}
|
||||||
|
Permanent permanent = source.getSourcePermanentOrLKI(game);
|
||||||
|
sourcePower = permanent != null ? Math.max(permanent.getPower().getValue(), 0) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
|
CardUtil.reduceCost(abilityToModify, sourcePower);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
|
MaelstromMuseWatcher watcher = game.getState().getWatcher(MaelstromMuseWatcher.class);
|
||||||
|
if (watcher == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (watcher.getCount(source.getControllerId()) > spellsCast) {
|
||||||
|
discard(); // only one use
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(abilityToModify instanceof SpellAbility)
|
||||||
|
|| !abilityToModify.isControlledBy(source.getControllerId())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Card spellCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||||
|
return spellCard != null && spellCard.isInstantOrSorcery();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MaelstromMuseEffect copy() {
|
||||||
|
return new MaelstromMuseEffect(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MaelstromMuseWatcher extends Watcher {
|
||||||
|
|
||||||
|
private final Map<UUID, Integer> playerMap = new HashMap<>();
|
||||||
|
|
||||||
|
MaelstromMuseWatcher() {
|
||||||
|
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.isInstantOrSorcery()) {
|
||||||
|
playerMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
super.reset();
|
||||||
|
playerMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCount(UUID playerId) {
|
||||||
|
return playerMap.getOrDefault(playerId, 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,6 +141,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Lorehold Command", 199, Rarity.RARE, mage.cards.l.LoreholdCommand.class));
|
cards.add(new SetCardInfo("Lorehold Command", 199, Rarity.RARE, mage.cards.l.LoreholdCommand.class));
|
||||||
cards.add(new SetCardInfo("Lorehold Excavation", 200, Rarity.UNCOMMON, mage.cards.l.LoreholdExcavation.class));
|
cards.add(new SetCardInfo("Lorehold Excavation", 200, Rarity.UNCOMMON, mage.cards.l.LoreholdExcavation.class));
|
||||||
cards.add(new SetCardInfo("Lorehold Pledgemage", 201, Rarity.COMMON, mage.cards.l.LoreholdPledgemage.class));
|
cards.add(new SetCardInfo("Lorehold Pledgemage", 201, Rarity.COMMON, mage.cards.l.LoreholdPledgemage.class));
|
||||||
|
cards.add(new SetCardInfo("Maelstrom Muse", 202, Rarity.UNCOMMON, mage.cards.m.MaelstromMuse.class));
|
||||||
cards.add(new SetCardInfo("Mage Hunter", 76, Rarity.UNCOMMON, mage.cards.m.MageHunter.class));
|
cards.add(new SetCardInfo("Mage Hunter", 76, Rarity.UNCOMMON, mage.cards.m.MageHunter.class));
|
||||||
cards.add(new SetCardInfo("Mage Hunters' Onslaught", 77, Rarity.COMMON, mage.cards.m.MageHuntersOnslaught.class));
|
cards.add(new SetCardInfo("Mage Hunters' Onslaught", 77, Rarity.COMMON, mage.cards.m.MageHuntersOnslaught.class));
|
||||||
cards.add(new SetCardInfo("Magma Opus", 203, Rarity.MYTHIC, mage.cards.m.MagmaOpus.class));
|
cards.add(new SetCardInfo("Magma Opus", 203, Rarity.MYTHIC, mage.cards.m.MagmaOpus.class));
|
||||||
|
|
Loading…
Add table
Reference in a new issue