mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Angelic Arbiter - Fixed that the dont't cast spell if you already attacked ability did not working properly (fixes #3339).
This commit is contained in:
parent
d98f73518a
commit
40c434f5df
1 changed files with 12 additions and 57 deletions
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.cards.a;
|
||||
|
||||
import mage.MageInt;
|
||||
|
@ -41,12 +40,9 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
||||
import mage.watchers.common.PlayerAttackedWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -55,7 +51,7 @@ import java.util.UUID;
|
|||
public class AngelicArbiter extends CardImpl {
|
||||
|
||||
public AngelicArbiter(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{5}{W}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{W}");
|
||||
this.subtype.add("Angel");
|
||||
|
||||
this.power = new MageInt(5);
|
||||
|
@ -68,7 +64,7 @@ public class AngelicArbiter extends CardImpl {
|
|||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterCantAttackTargetEffect(Duration.WhileOnBattlefield)));
|
||||
|
||||
// Each opponent who attacked with a creature this turn can't cast spells.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterEffect2()), new AngelicArbiterWatcher2());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterEffect2()), new PlayerAttackedWatcher());
|
||||
}
|
||||
|
||||
public AngelicArbiter(final AngelicArbiter card) {
|
||||
|
@ -82,47 +78,6 @@ public class AngelicArbiter extends CardImpl {
|
|||
|
||||
}
|
||||
|
||||
class AngelicArbiterWatcher2 extends Watcher {
|
||||
|
||||
private final Set<UUID> playersThatAttackedThisTurn = new HashSet<>();
|
||||
|
||||
public AngelicArbiterWatcher2() {
|
||||
super("PlayerAttacked", WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AngelicArbiterWatcher2(final AngelicArbiterWatcher2 watcher) {
|
||||
super(watcher);
|
||||
this.playersThatAttackedThisTurn.addAll(watcher.playersThatAttackedThisTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AngelicArbiterWatcher2 copy() {
|
||||
return new AngelicArbiterWatcher2(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DECLARED_ATTACKERS
|
||||
&& game.getActivePlayerId().equals(event.getPlayerId())
|
||||
&& game.getOpponents(controllerId).contains(event.getPlayerId())
|
||||
&& game.getCombat().getAttackerId().equals(event.getPlayerId())
|
||||
&& !game.getCombat().getAttackers().isEmpty()) {
|
||||
playersThatAttackedThisTurn.add(event.getPlayerId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
playersThatAttackedThisTurn.clear();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPlayerAttackedThisTurn(UUID playerId) {
|
||||
return playersThatAttackedThisTurn.contains(playerId);
|
||||
}
|
||||
}
|
||||
|
||||
class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect {
|
||||
|
||||
public AngelicArbiterCantAttackTargetEffect(Duration duration) {
|
||||
|
@ -185,8 +140,8 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
AngelicArbiterWatcher2 watcher = (AngelicArbiterWatcher2) game.getState().getWatchers().get(AngelicArbiterWatcher2.class.getSimpleName());
|
||||
if (watcher != null && watcher.hasPlayerAttackedThisTurn(event.getPlayerId())) {
|
||||
PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getNumberOfAttackersCurrentTurn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue