mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Refactor: moved ManaPaidSourceWatcher to default watchers, added additional checks;
This commit is contained in:
parent
24847c1fa7
commit
560b56a391
16 changed files with 36 additions and 25 deletions
|
@ -46,7 +46,7 @@ public final class BergStrider extends CardImpl {
|
||||||
Ability ability = new EntersBattlefieldTriggeredAbility(new TapTargetEffect());
|
Ability ability = new EntersBattlefieldTriggeredAbility(new TapTargetEffect());
|
||||||
ability.addEffect(new BergStriderEffect());
|
ability.addEffect(new BergStriderEffect());
|
||||||
ability.addTarget(new TargetPermanent(filter));
|
ability.addTarget(new TargetPermanent(filter));
|
||||||
this.addAbility(ability, new ManaPaidSourceWatcher());
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BergStrider(final BergStrider card) {
|
private BergStrider(final BergStrider card) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ public final class BlessingOfFrost extends CardImpl {
|
||||||
|
|
||||||
// Distribute X +1/+1 counters among any number of creatures you control, where X is the amount of {S} spent to cast this spell. Then draw a card for each creature you control with power 4 or greater.
|
// Distribute X +1/+1 counters among any number of creatures you control, where X is the amount of {S} spent to cast this spell. Then draw a card for each creature you control with power 4 or greater.
|
||||||
this.getSpellAbility().addEffect(new BlessingOfFrostEffect());
|
this.getSpellAbility().addEffect(new BlessingOfFrostEffect());
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlessingOfFrost(final BlessingOfFrost card) {
|
private BlessingOfFrost(final BlessingOfFrost card) {
|
||||||
|
|
|
@ -45,7 +45,6 @@ public final class BloodOnTheSnow extends CardImpl {
|
||||||
"Then return a creature or planeswalker card with mana value X or less"
|
"Then return a creature or planeswalker card with mana value X or less"
|
||||||
+ " from your graveyard to the battlefield, where X is the amount of {S} spent to cast this spell."
|
+ " from your graveyard to the battlefield, where X is the amount of {S} spent to cast this spell."
|
||||||
);
|
);
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BloodOnTheSnow(final BloodOnTheSnow card) {
|
private BloodOnTheSnow(final BloodOnTheSnow card) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class BorealOutrider extends CardImpl {
|
||||||
), BorealOutriderCondition.instance, "Whenever you cast a creature spell, " +
|
), BorealOutriderCondition.instance, "Whenever you cast a creature spell, " +
|
||||||
"if {S} of any of that spell's colors was spent to cast it, that creature " +
|
"if {S} of any of that spell's colors was spent to cast it, that creature " +
|
||||||
"enters the battlefield with an additional +1/+1 counter on it."
|
"enters the battlefield with an additional +1/+1 counter on it."
|
||||||
), new ManaPaidSourceWatcher());
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private BorealOutrider(final BorealOutrider card) {
|
private BorealOutrider(final BorealOutrider card) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ public final class DevourIntellect extends CardImpl {
|
||||||
TreasureSpentToCastCondition.instance,
|
TreasureSpentToCastCondition.instance,
|
||||||
"Target opponent discards a card. If mana from a Treasure was spent to cast this spell, instead that player reveals their hand, you choose a nonland card from it, then that player discards a card"
|
"Target opponent discards a card. If mana from a Treasure was spent to cast this spell, instead that player reveals their hand, you choose a nonland card from it, then that player discards a card"
|
||||||
));
|
));
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DevourIntellect(final DevourIntellect card) {
|
private DevourIntellect(final DevourIntellect card) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class ForswornPaladin extends CardImpl {
|
||||||
);
|
);
|
||||||
ability.addEffect(new ForswornPaladinEffect());
|
ability.addEffect(new ForswornPaladinEffect());
|
||||||
ability.addTarget(new TargetCreaturePermanent());
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
this.addAbility(ability, new ManaPaidSourceWatcher());
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ForswornPaladin(final ForswornPaladin card) {
|
private ForswornPaladin(final ForswornPaladin card) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ public final class GravenLore extends CardImpl {
|
||||||
|
|
||||||
// Scry X, where is the amount of {S} spent to cast this spell, then draw three cards.
|
// Scry X, where is the amount of {S} spent to cast this spell, then draw three cards.
|
||||||
this.getSpellAbility().addEffect(new GravenLoreEffect());
|
this.getSpellAbility().addEffect(new GravenLoreEffect());
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GravenLore(final GravenLore card) {
|
private GravenLore(final GravenLore card) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class HiredHexblade extends CardImpl {
|
||||||
"if mana from a Treasure was spent to cast it, you draw a card and you lose 1 life."
|
"if mana from a Treasure was spent to cast it, you draw a card and you lose 1 life."
|
||||||
);
|
);
|
||||||
ability.addEffect(new LoseLifeSourceControllerEffect(1));
|
ability.addEffect(new LoseLifeSourceControllerEffect(1));
|
||||||
this.addAbility(ability, new ManaPaidSourceWatcher());
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HiredHexblade(final HiredHexblade card) {
|
private HiredHexblade(final HiredHexblade card) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public final class JadedSellSword extends CardImpl {
|
||||||
ability.addEffect(new GainAbilitySourceEffect(
|
ability.addEffect(new GainAbilitySourceEffect(
|
||||||
HasteAbility.getInstance(), Duration.EndOfTurn
|
HasteAbility.getInstance(), Duration.EndOfTurn
|
||||||
));
|
));
|
||||||
this.addAbility(ability, new ManaPaidSourceWatcher());
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JadedSellSword(final JadedSellSword card) {
|
private JadedSellSword(final JadedSellSword card) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class KalainReclusivePainter extends CardImpl {
|
||||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new TreasureToken())));
|
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new TreasureToken())));
|
||||||
|
|
||||||
// Other creatures you control enter the battlefield with an additional +1/+1 counter on them for each mana from a Treasure spent to cast them.
|
// Other creatures you control enter the battlefield with an additional +1/+1 counter on them for each mana from a Treasure spent to cast them.
|
||||||
this.addAbility(new SimpleStaticAbility(new KalainReclusivePainterEffect()), new ManaPaidSourceWatcher());
|
this.addAbility(new SimpleStaticAbility(new KalainReclusivePainterEffect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private KalainReclusivePainter(final KalainReclusivePainter card) {
|
private KalainReclusivePainter(final KalainReclusivePainter card) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ public final class PriceOfLoyalty extends CardImpl {
|
||||||
).setText("It gains haste until end of turn."));
|
).setText("It gains haste until end of turn."));
|
||||||
this.getSpellAbility().addEffect(new PriceOfLoyaltyEffect());
|
this.getSpellAbility().addEffect(new PriceOfLoyaltyEffect());
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PriceOfLoyalty(final PriceOfLoyalty card) {
|
private PriceOfLoyalty(final PriceOfLoyalty card) {
|
||||||
|
|
|
@ -42,7 +42,6 @@ public final class SearchForGlory extends CardImpl {
|
||||||
this.getSpellAbility().addEffect(new GainLifeEffect(
|
this.getSpellAbility().addEffect(new GainLifeEffect(
|
||||||
SnowManaSpentValue.instance
|
SnowManaSpentValue.instance
|
||||||
).setText("You gain 1 life for each {S} spent to cast this spell"));
|
).setText("You gain 1 life for each {S} spent to cast this spell"));
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchForGlory(final SearchForGlory card) {
|
private SearchForGlory(final SearchForGlory card) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ public final class SpoilsOfTheHunt extends CardImpl {
|
||||||
));
|
));
|
||||||
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||||
this.getSpellAbility().addTarget(new TargetOpponentsCreaturePermanent());
|
this.getSpellAbility().addTarget(new TargetOpponentsCreaturePermanent());
|
||||||
this.getSpellAbility().addWatcher(new ManaPaidSourceWatcher());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpoilsOfTheHunt(final SpoilsOfTheHunt card) {
|
private SpoilsOfTheHunt(final SpoilsOfTheHunt card) {
|
||||||
|
|
|
@ -64,6 +64,8 @@ import mage.util.GameLog;
|
||||||
import mage.util.MessageToClient;
|
import mage.util.MessageToClient;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import mage.util.functions.CopyApplier;
|
import mage.util.functions.CopyApplier;
|
||||||
|
import mage.watchers.Watcher;
|
||||||
|
import mage.watchers.Watchers;
|
||||||
import mage.watchers.common.*;
|
import mage.watchers.common.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
@ -1185,18 +1187,29 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initGameDefaultWatchers() {
|
public void initGameDefaultWatchers() {
|
||||||
getState().addWatcher(new MorbidWatcher());
|
List<Watcher> newWatchers = new ArrayList<>();
|
||||||
getState().addWatcher(new CastSpellLastTurnWatcher());
|
newWatchers.add(new MorbidWatcher());
|
||||||
getState().addWatcher(new CastSpellYourLastTurnWatcher());
|
newWatchers.add(new CastSpellLastTurnWatcher());
|
||||||
getState().addWatcher(new PlayerLostLifeWatcher());
|
newWatchers.add(new CastSpellYourLastTurnWatcher());
|
||||||
getState().addWatcher(new PlayerLostLifeNonCombatWatcher());
|
newWatchers.add(new PlayerLostLifeWatcher());
|
||||||
getState().addWatcher(new BlockedAttackerWatcher());
|
newWatchers.add(new PlayerLostLifeNonCombatWatcher());
|
||||||
getState().addWatcher(new DamageDoneWatcher());
|
newWatchers.add(new BlockedAttackerWatcher());
|
||||||
getState().addWatcher(new PlanarRollWatcher());
|
newWatchers.add(new DamageDoneWatcher());
|
||||||
getState().addWatcher(new AttackedThisTurnWatcher());
|
newWatchers.add(new PlanarRollWatcher());
|
||||||
getState().addWatcher(new PlayersAttackedThisTurnWatcher());
|
newWatchers.add(new AttackedThisTurnWatcher());
|
||||||
getState().addWatcher(new CardsDrawnThisTurnWatcher());
|
newWatchers.add(new PlayersAttackedThisTurnWatcher());
|
||||||
getState().addWatcher(new ManaSpentToCastWatcher());
|
newWatchers.add(new CardsDrawnThisTurnWatcher());
|
||||||
|
newWatchers.add(new ManaSpentToCastWatcher());
|
||||||
|
newWatchers.add(new ManaPaidSourceWatcher());
|
||||||
|
|
||||||
|
// runtime check - allows only GAME scope (one watcher per game)
|
||||||
|
newWatchers.forEach(watcher -> {
|
||||||
|
if (watcher.getScope().equals(WatcherScope.GAME)) {
|
||||||
|
throw new IllegalStateException("Game default watchers must have GAME scope: " + watcher.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newWatchers.forEach(getState()::addWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initPlayerDefaultWatchers(UUID playerId) {
|
public void initPlayerDefaultWatchers(UUID playerId) {
|
||||||
|
|
|
@ -169,4 +169,7 @@ public abstract class Watcher implements Serializable {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WatcherScope getScope() {
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Default watcher, no needs to add it to ability
|
||||||
|
*
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public class ManaPaidSourceWatcher extends Watcher {
|
public class ManaPaidSourceWatcher extends Watcher {
|
||||||
|
|
Loading…
Reference in a new issue