mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +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
|
@ -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,12 +20,11 @@
|
|||
* 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.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);
|
||||
|
@ -63,12 +59,12 @@ public class AngelicArbiter extends CardImpl {
|
|||
|
||||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
|
||||
// Each opponent who cast a spell this turn can't attack with creatures.
|
||||
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