mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08: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,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…
Add table
Add a link
Reference in a new issue