mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Vizier of Deferment - Fixed null pointer exception.
This commit is contained in:
parent
2c6be695ba
commit
804fb12b1d
14 changed files with 110 additions and 105 deletions
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -42,8 +44,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
|
@ -51,11 +51,11 @@ import java.util.UUID;
|
|||
public class AngelsTrumpet extends CardImpl {
|
||||
|
||||
public AngelsTrumpet(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||
|
||||
// All creatures have vigilance.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(VigilanceAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent())));
|
||||
|
||||
|
||||
// At the beginning of each player's end step, tap all untapped creatures that player controls that didn't attack this turn. Angel's Trumpet deals damage to the player equal to the number of creatures tapped this way.
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(new AngelsTrumpetTapEffect(), TargetController.ANY, false), new AttackedThisTurnWatcher());
|
||||
}
|
||||
|
@ -71,21 +71,21 @@ public class AngelsTrumpet extends CardImpl {
|
|||
}
|
||||
|
||||
class AngelsTrumpetTapEffect extends OneShotEffect {
|
||||
|
||||
|
||||
AngelsTrumpetTapEffect() {
|
||||
super(Outcome.Tap);
|
||||
this.staticText = "tap all untapped creatures that player controls that didn't attack this turn. Angel's Trumpet deals damage to the player equal to the number of creatures tapped this way";
|
||||
}
|
||||
|
||||
|
||||
AngelsTrumpetTapEffect(final AngelsTrumpetTapEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AngelsTrumpetTapEffect copy() {
|
||||
return new AngelsTrumpetTapEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
|
@ -97,8 +97,8 @@ class AngelsTrumpetTapEffect extends OneShotEffect {
|
|||
continue;
|
||||
}
|
||||
// Creatures that attacked are safe.
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(creature.getId())) {
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game))) {
|
||||
continue;
|
||||
}
|
||||
// Tap the rest.
|
||||
|
@ -112,4 +112,4 @@ class AngelsTrumpetTapEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
|
@ -50,8 +52,6 @@ import mage.target.targetpointer.FixedTarget;
|
|||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
@ -59,7 +59,7 @@ import java.util.UUID;
|
|||
public class Berserk extends CardImpl {
|
||||
|
||||
public Berserk(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}");
|
||||
|
||||
// Cast Berserk only before the combat damage step. (Zone = all because it can be at least graveyard or hand)
|
||||
this.addAbility(new SimpleStaticAbility(Zone.ALL, new BerserkReplacementEffect()), new CombatDamageStepStartedWatcher());
|
||||
|
@ -196,9 +196,9 @@ class BerserkDelayedDestroyEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
Watcher watcher = game.getState().getWatchers().get("AttackedThisTurn");
|
||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(permanent.getId())) {
|
||||
if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
|
||||
return permanent.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -58,7 +57,7 @@ public class ChargingCinderhorn extends CardImpl {
|
|||
|
||||
public ChargingCinderhorn(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
|
||||
|
||||
|
||||
this.subtype.add("Elemental");
|
||||
this.subtype.add("Ox");
|
||||
this.power = new MageInt(4);
|
||||
|
@ -70,8 +69,8 @@ public class ChargingCinderhorn extends CardImpl {
|
|||
// At the beginning of each player's end step, if no creatures attacked this turn, put a fury counter on Charging Cinderhorn. Then Charging Cinderhorn deals damage equal to the number of fury counters on it to that player.
|
||||
ChargingCinderhornDamageTargetEffect effect = new ChargingCinderhornDamageTargetEffect();
|
||||
effect.setText("if no creatures attacked this turn, put a fury counter on {this}. Then {this} deals damage equal to the number of fury counters on it to that player");
|
||||
BeginningOfEndStepTriggeredAbility ability =
|
||||
new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, new ChargingCinderhornCondition(), false);
|
||||
BeginningOfEndStepTriggeredAbility ability
|
||||
= new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, new ChargingCinderhornCondition(), false);
|
||||
this.addAbility(ability, new AttackedThisTurnWatcher());
|
||||
}
|
||||
|
||||
|
@ -89,31 +88,27 @@ class ChargingCinderhornCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
Set<UUID> attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures();
|
||||
return attackedThisTurnCreatures.isEmpty();
|
||||
return watcher.getAttackedThisTurnCreatures().isEmpty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "no creatures attacked this turn";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class ChargingCinderhornDamageTargetEffect extends OneShotEffect{
|
||||
|
||||
public ChargingCinderhornDamageTargetEffect()
|
||||
{
|
||||
class ChargingCinderhornDamageTargetEffect extends OneShotEffect {
|
||||
|
||||
public ChargingCinderhornDamageTargetEffect() {
|
||||
super(Outcome.Damage);
|
||||
}
|
||||
|
||||
public ChargingCinderhornDamageTargetEffect(ChargingCinderhornDamageTargetEffect copy)
|
||||
{
|
||||
|
||||
public ChargingCinderhornDamageTargetEffect(ChargingCinderhornDamageTargetEffect copy) {
|
||||
super(copy);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
@ -42,9 +44,6 @@ import mage.game.permanent.Permanent;
|
|||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
import mage.watchers.common.BlockedThisTurnWatcher;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Quercitron
|
||||
|
@ -52,7 +51,7 @@ import java.util.UUID;
|
|||
public class DuelingGrounds extends CardImpl {
|
||||
|
||||
public DuelingGrounds(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}{W}");
|
||||
|
||||
// No more than one creature can attack each turn.
|
||||
this.addAbility(
|
||||
|
@ -101,10 +100,10 @@ class NoMoreThanOneCreatureCanAttackEachTurnEffect extends RestrictionEffect {
|
|||
if (!game.getCombat().getAttackers().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
Set<UUID> attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures();
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
Set<MageObjectReference> attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures();
|
||||
return attackedThisTurnCreatures.isEmpty()
|
||||
|| (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(attacker.getId()));
|
||||
|| (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(new MageObjectReference(attacker, game)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
*/
|
||||
package mage.cards.e;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
|
@ -42,17 +44,15 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
|
||||
*
|
||||
*/
|
||||
public class ErgRaiders extends CardImpl {
|
||||
|
||||
public ErgRaiders(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}");
|
||||
this.subtype.add("Human");
|
||||
this.subtype.add("Warrior");
|
||||
this.power = new MageInt(2);
|
||||
|
@ -60,7 +60,7 @@ public class ErgRaiders extends CardImpl {
|
|||
|
||||
// At the beginning of your end step, if Erg Raiders didn't attack this turn, Erg Raiders deals 2 damage to you unless it came under your control this turn.
|
||||
TriggeredAbility ability = new ConditionalTriggeredAbility(new BeginningOfEndStepTriggeredAbility(new DamageControllerEffect(2), TargetController.YOU, false),
|
||||
new ErgRaidersCondition(), "At the beginning of your end step, if {this} didn't attack this turn, {this} deals 2 damage to you unless it came under your control this turn.");
|
||||
new ErgRaidersCondition(), "At the beginning of your end step, if {this} didn't attack this turn, {this} deals 2 damage to you unless it came under your control this turn.");
|
||||
ability.addWatcher(new AttackedThisTurnWatcher());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ class ErgRaidersCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
// wasControlledFromStartOfControllerTurn should be checked during resolution I guess, but shouldn't be relevant
|
||||
return raiders.wasControlledFromStartOfControllerTurn() && !watcher.getAttackedThisTurnCreatures().contains(raiders.getId());
|
||||
return raiders.wasControlledFromStartOfControllerTurn() && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(raiders, game));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.cards.o;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.Mode;
|
||||
|
@ -66,7 +67,7 @@ import mage.watchers.common.AttackedThisTurnWatcher;
|
|||
public class OracleEnVec extends CardImpl {
|
||||
|
||||
public OracleEnVec(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
|
||||
this.subtype.add("Human");
|
||||
this.subtype.add("Wizard");
|
||||
this.power = new MageInt(1);
|
||||
|
@ -249,7 +250,7 @@ class OracleEnVecDestroyEffect extends OneShotEffect {
|
|||
|
||||
private final List<UUID> chosenCreatures;
|
||||
|
||||
OracleEnVecDestroyEffect(List<UUID> chosenCreatures) {
|
||||
OracleEnVecDestroyEffect(List<UUID> chosenCreatures) { // need to be changed to MageObjectReference
|
||||
super(Outcome.DestroyPermanent);
|
||||
this.chosenCreatures = chosenCreatures;
|
||||
this.staticText = "destroy each of the chosen creatures that didn't attack";
|
||||
|
@ -267,10 +268,11 @@ class OracleEnVecDestroyEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null) {
|
||||
for (UUID targetId : chosenCreatures) {
|
||||
if (!watcher.getAttackedThisTurnCreatures().contains(targetId)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
|
||||
Effect effect = new DestroyTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(targetId));
|
||||
effect.apply(game, source);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
|
@ -54,7 +55,7 @@ import mage.watchers.common.AttackedThisTurnWatcher;
|
|||
public class SirensCall extends CardImpl {
|
||||
|
||||
public SirensCall(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}");
|
||||
|
||||
// Cast Siren's Call only during an opponent's turn, before attackers are declared.
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(null, null,
|
||||
|
@ -133,18 +134,19 @@ class SirensCallDestroyEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(game.getActivePlayerId());
|
||||
if (player != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(player.getId())) {
|
||||
|
||||
// Non Creature Cards are safe.
|
||||
if(!permanent.isCreature())
|
||||
continue;
|
||||
|
||||
|
||||
// Non Creature Cards are safe.
|
||||
if (!permanent.isCreature()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Walls are safe.
|
||||
if (permanent.getSubtype(game).contains("Wall")) {
|
||||
continue;
|
||||
}
|
||||
// Creatures that attacked are safe.
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(permanent.getId())) {
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) {
|
||||
continue;
|
||||
}
|
||||
// Creatures that weren't controlled since the beginning of turn are safe.
|
||||
|
|
|
@ -85,21 +85,27 @@ public class VizierOfDeferment extends CardImpl {
|
|||
if (ability instanceof EntersBattlefieldTriggeredAbility) {
|
||||
List<PermanentIdPredicate> creaturesThatCanBeTargeted = new ArrayList<>();
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that attacked or blocked this turn.");
|
||||
AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get("BlockedThisTurn");
|
||||
if (watcherAttacked != null) {
|
||||
for (UUID creatureId : watcherAttacked.getAttackedThisTurnCreatures()) {
|
||||
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(creatureId));
|
||||
for (MageObjectReference mor : watcherAttacked.getAttackedThisTurnCreatures()) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null) {
|
||||
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(permanent.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (watcherBlocked != null) {
|
||||
for (MageObjectReference mor : watcherBlocked.getBlockedThisTurnCreatures()) {
|
||||
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(mor.getPermanent(game).getId()));
|
||||
if (watcherBlocked != null) {
|
||||
for (MageObjectReference mor : watcherBlocked.getBlockedThisTurnCreatures()) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null) {
|
||||
creaturesThatCanBeTargeted.add(new PermanentIdPredicate(permanent.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.add(Predicates.or(creaturesThatCanBeTargeted));
|
||||
ability.getTargets().clear();
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
}
|
||||
filter.add(Predicates.or(creaturesThatCanBeTargeted));
|
||||
ability.getTargets().clear();
|
||||
ability.addTarget(new TargetCreaturePermanent(filter));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.cards.w;
|
|||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -52,7 +53,7 @@ import mage.watchers.common.AttackedThisTurnWatcher;
|
|||
public class WorldAtWar extends CardImpl {
|
||||
|
||||
public WorldAtWar(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{R}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{R}{R}");
|
||||
|
||||
// After the first postcombat main phase this turn, there's an additional combat phase followed by an additional main phase. At the beginning of that combat, untap all creatures that attacked this turn.
|
||||
this.getSpellAbility().addEffect(new WorldAtWarEffect());
|
||||
|
@ -167,11 +168,11 @@ class UntapAttackingThisTurnEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get("AttackedThisTurn");
|
||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
Set<UUID> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (UUID uuid : attackedThisTurn) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (MageObjectReference mor : attackedThisTurn) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null && permanent.isCreature()) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
|
@ -42,7 +43,7 @@ public enum TargetAttackedThisTurnCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanentOrLKIBattlefield(source.getTargets().getFirstTarget());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
return watcher.getAttackedThisTurnCreatures().contains(creature.getId());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
return watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,9 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -63,11 +62,11 @@ public class UntapAllThatAttackedEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get("AttackedThisTurn");
|
||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
Set<UUID> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (UUID uuid : attackedThisTurn) {
|
||||
Permanent permanent = game.getPermanent(uuid);
|
||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (MageObjectReference mor : attackedThisTurn) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null && permanent.isCreature()) {
|
||||
permanent.untap(game);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.constants.Duration;
|
||||
|
@ -59,8 +60,8 @@ public class AttacksIfAbleAllEffect extends RequirementEffect {
|
|||
if (eachCombat) {
|
||||
return true;
|
||||
}
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get("AttackedThisTurn");
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(permanent.getId());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,17 +20,17 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common.combat;
|
||||
|
||||
import mage.constants.Duration;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RequirementEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.common.AttackedThisTurnWatcher;
|
||||
|
@ -42,18 +42,18 @@ import mage.watchers.common.AttackedThisTurnWatcher;
|
|||
public class AttacksIfAbleSourceEffect extends RequirementEffect {
|
||||
|
||||
boolean eachCombat;
|
||||
|
||||
|
||||
public AttacksIfAbleSourceEffect(Duration duration) {
|
||||
this(duration, false);
|
||||
this(duration, false);
|
||||
}
|
||||
|
||||
|
||||
public AttacksIfAbleSourceEffect(Duration duration, boolean eachCombat) {
|
||||
super(duration);
|
||||
this.eachCombat = eachCombat;
|
||||
if (this.duration == Duration.EndOfTurn) {
|
||||
staticText = "{this} attacks " + (eachCombat ? "each combat" :"this turn") + " if able";
|
||||
staticText = "{this} attacks " + (eachCombat ? "each combat" : "this turn") + " if able";
|
||||
} else {
|
||||
staticText = "{this} attacks each " + (eachCombat ? "combat" :"turn") + " if able";
|
||||
staticText = "{this} attacks each " + (eachCombat ? "combat" : "turn") + " if able";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,8 @@ public class AttacksIfAbleSourceEffect extends RequirementEffect {
|
|||
if (eachCombat) {
|
||||
return true;
|
||||
}
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher)game.getState().getWatchers().get("AttackedThisTurn");
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(permanent.getId());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ package mage.watchers.common;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -40,11 +40,10 @@ import mage.watchers.Watcher;
|
|||
*/
|
||||
public class AttackedThisTurnWatcher extends Watcher {
|
||||
|
||||
// TODO: use MageObjectReference instead of UUID
|
||||
public final Set<UUID> attackedThisTurnCreatures = new HashSet<>();
|
||||
public final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
|
||||
|
||||
public AttackedThisTurnWatcher() {
|
||||
super("AttackedThisTurn", WatcherScope.GAME);
|
||||
super(AttackedThisTurnWatcher.class.getName(), WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) {
|
||||
|
@ -55,11 +54,11 @@ public class AttackedThisTurnWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
this.attackedThisTurnCreatures.add(event.getSourceId());
|
||||
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
public Set<UUID> getAttackedThisTurnCreatures() {
|
||||
|
||||
public Set<MageObjectReference> getAttackedThisTurnCreatures() {
|
||||
return this.attackedThisTurnCreatures;
|
||||
}
|
||||
|
||||
|
@ -74,4 +73,4 @@ public class AttackedThisTurnWatcher extends Watcher {
|
|||
this.attackedThisTurnCreatures.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue