mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
- Fixed #8166
This commit is contained in:
parent
b6acaed99d
commit
5a87664a55
2 changed files with 17 additions and 34 deletions
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
@ -20,9 +18,7 @@ import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.stack.StackObject;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,38 +67,15 @@ public final class DivineIntervention extends CardImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == GameEvent.EventType.COUNTER_REMOVED;
|
return event.getType() == GameEvent.EventType.COUNTERS_REMOVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getData().equals(CounterType.INTERVENTION.getName()) && event.getTargetId().equals(this.getSourceId())) {
|
return (event.getData().equals(CounterType.INTERVENTION.getName())
|
||||||
|
&& event.getTargetId().equals(this.getSourceId())
|
||||||
boolean onlyYouOnStack = true;
|
&& event.getPlayerId() != null
|
||||||
boolean onlyOpponentOnStack = true;
|
&& event.getPlayerId() == this.getControllerId()); // the controller of this removed the counter
|
||||||
UUID you = getControllerId();
|
|
||||||
boolean firstOnStack = false;
|
|
||||||
|
|
||||||
for (StackObject stackObject : game.getStack()) {
|
|
||||||
|
|
||||||
if (stackObject.getControllerId() != null && !firstOnStack) {
|
|
||||||
if (!Objects.equals(you, stackObject.getControllerId())) {
|
|
||||||
onlyYouOnStack = false;
|
|
||||||
} else if (Objects.equals(you, stackObject.getControllerId())) {
|
|
||||||
onlyOpponentOnStack = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
firstOnStack = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onlyYouOnStack && !onlyOpponentOnStack) {
|
|
||||||
return true;
|
|
||||||
} else if (!onlyYouOnStack && onlyOpponentOnStack) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -131,8 +104,10 @@ public final class DivineIntervention extends CardImpl {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (controller != null && sourcePermanent != null) {
|
if (controller != null
|
||||||
if (game.getState().getZone(sourcePermanent.getId()) == Zone.BATTLEFIELD && sourcePermanent.getCounters(game).getCount(CounterType.INTERVENTION) == 0) {
|
&& sourcePermanent != null) {
|
||||||
|
if (game.getState().getZone(sourcePermanent.getId()) == Zone.BATTLEFIELD
|
||||||
|
&& sourcePermanent.getCounters(game).getCount(CounterType.INTERVENTION) == 0) {
|
||||||
game.setDraw(controller.getId());
|
game.setDraw(controller.getId());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -747,11 +747,19 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED, objectId, source, getControllerOrOwner());
|
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED, objectId, source, getControllerOrOwner());
|
||||||
|
if (source != null
|
||||||
|
&& source.getControllerId() != null) {
|
||||||
|
event.setPlayerId(source.getControllerId()); // player who controls the source ability that removed the counter
|
||||||
|
}
|
||||||
event.setData(name);
|
event.setData(name);
|
||||||
game.fireEvent(event);
|
game.fireEvent(event);
|
||||||
finalAmount++;
|
finalAmount++;
|
||||||
}
|
}
|
||||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTERS_REMOVED, objectId, source, getControllerOrOwner());
|
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTERS_REMOVED, objectId, source, getControllerOrOwner());
|
||||||
|
if (source != null
|
||||||
|
&& source.getControllerId() != null) {
|
||||||
|
event.setPlayerId(source.getControllerId()); // player who controls the source ability that removed the counter
|
||||||
|
}
|
||||||
event.setData(name);
|
event.setData(name);
|
||||||
event.setAmount(finalAmount);
|
event.setAmount(finalAmount);
|
||||||
game.fireEvent(event);
|
game.fireEvent(event);
|
||||||
|
|
Loading…
Reference in a new issue