mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Ephara, God of the Polis - Fixed its watcher not able to handle copies of it correctly.
This commit is contained in:
parent
93b5fe7fe2
commit
da67a67eaa
2 changed files with 25 additions and 46 deletions
|
|
@ -44,12 +44,10 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.ColoredManaSymbol;
|
import mage.constants.ColoredManaSymbol;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.constants.WatcherScope;
|
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.common.PermanentsEnteredBattlefieldWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -58,7 +56,7 @@ import mage.watchers.Watcher;
|
||||||
public class EpharaGodOfThePolis extends CardImpl {
|
public class EpharaGodOfThePolis extends CardImpl {
|
||||||
|
|
||||||
public EpharaGodOfThePolis(UUID ownerId, CardSetInfo setInfo) {
|
public EpharaGodOfThePolis(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT,CardType.CREATURE},"{2}{W}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{W}{U}");
|
||||||
this.supertype.add("Legendary");
|
this.supertype.add("Legendary");
|
||||||
this.subtype.add("God");
|
this.subtype.add("God");
|
||||||
|
|
||||||
|
|
@ -75,8 +73,8 @@ public class EpharaGodOfThePolis extends CardImpl {
|
||||||
this.addAbility(new ConditionalTriggeredAbility(
|
this.addAbility(new ConditionalTriggeredAbility(
|
||||||
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), TargetController.ANY, false),
|
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), TargetController.ANY, false),
|
||||||
HadAnotherCreatureEnterTheBattlefieldCondition.getInstance(),
|
HadAnotherCreatureEnterTheBattlefieldCondition.getInstance(),
|
||||||
"At the beginning of each upkeep, if you had another creature enter the battlefield under your control last turn, draw a card."),
|
"At the beginning of each upkeep, if you had another creature enter the battlefield under your control last turn, draw a card."),
|
||||||
new CreatureEnteredBattlefieldLastTurnWatcher());
|
new PermanentsEnteredBattlefieldWatcher());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +90,7 @@ public class EpharaGodOfThePolis extends CardImpl {
|
||||||
|
|
||||||
class HadAnotherCreatureEnterTheBattlefieldCondition implements Condition {
|
class HadAnotherCreatureEnterTheBattlefieldCondition implements Condition {
|
||||||
|
|
||||||
private static HadAnotherCreatureEnterTheBattlefieldCondition fInstance = new HadAnotherCreatureEnterTheBattlefieldCondition();
|
private final static HadAnotherCreatureEnterTheBattlefieldCondition fInstance = new HadAnotherCreatureEnterTheBattlefieldCondition();
|
||||||
|
|
||||||
public static HadAnotherCreatureEnterTheBattlefieldCondition getInstance() {
|
public static HadAnotherCreatureEnterTheBattlefieldCondition getInstance() {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
|
|
@ -100,44 +98,10 @@ class HadAnotherCreatureEnterTheBattlefieldCondition implements Condition {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Watcher watcher = game.getState().getWatchers().get("CreatureEnteredBattlefieldLastTurnWatcher", source.getSourceId());
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
return watcher != null && watcher.conditionMet();
|
PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getName());
|
||||||
}
|
return sourcePermanent != null
|
||||||
}
|
&& watcher != null
|
||||||
|
&& watcher.AnotherCreatureEnteredBattlefieldUnderPlayersControlLastTurn(sourcePermanent, game);
|
||||||
class CreatureEnteredBattlefieldLastTurnWatcher extends Watcher {
|
|
||||||
|
|
||||||
private boolean anotherCreatureEntered = false;
|
|
||||||
|
|
||||||
public CreatureEnteredBattlefieldLastTurnWatcher() {
|
|
||||||
super("CreatureEnteredBattlefieldLastTurnWatcher", WatcherScope.CARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CreatureEnteredBattlefieldLastTurnWatcher(final CreatureEnteredBattlefieldLastTurnWatcher watcher) {
|
|
||||||
super(watcher);
|
|
||||||
this.anotherCreatureEntered = watcher.anotherCreatureEntered;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void watch(GameEvent event, Game game) {
|
|
||||||
if (!anotherCreatureEntered && event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
|
||||||
if (!event.getTargetId().equals(this.getSourceId()) && event.getPlayerId().equals(this.getControllerId())) {
|
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
|
||||||
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
|
|
||||||
anotherCreatureEntered = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reset() {
|
|
||||||
condition = anotherCreatureEntered;
|
|
||||||
anotherCreatureEntered = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CreatureEnteredBattlefieldLastTurnWatcher copy() {
|
|
||||||
return new CreatureEnteredBattlefieldLastTurnWatcher(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import mage.watchers.Watcher;
|
||||||
public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
||||||
|
|
||||||
private final HashMap<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
|
private final HashMap<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
|
||||||
|
private final HashMap<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
|
||||||
|
|
||||||
public PermanentsEnteredBattlefieldWatcher() {
|
public PermanentsEnteredBattlefieldWatcher() {
|
||||||
super(PermanentsEnteredBattlefieldWatcher.class.getName(), WatcherScope.GAME);
|
super(PermanentsEnteredBattlefieldWatcher.class.getName(), WatcherScope.GAME);
|
||||||
|
|
@ -29,6 +30,8 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
||||||
|
|
||||||
public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) {
|
public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
|
this.enteringBattlefield.putAll(watcher.enteringBattlefield);
|
||||||
|
this.enteringBattlefieldLastTurn.putAll(watcher.enteringBattlefieldLastTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -56,10 +59,22 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
|
enteringBattlefieldLastTurn.clear();
|
||||||
|
enteringBattlefieldLastTurn.putAll(enteringBattlefield);
|
||||||
enteringBattlefield.clear();
|
enteringBattlefield.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Permanent> getThisTurnEnteringPermanents(UUID playerId) {
|
public List<Permanent> getThisTurnEnteringPermanents(UUID playerId) {
|
||||||
return enteringBattlefield.get(playerId);
|
return enteringBattlefield.get(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean AnotherCreatureEnteredBattlefieldUnderPlayersControlLastTurn(Permanent sourcePermanent, Game game) {
|
||||||
|
for (Permanent permanent : enteringBattlefield.get(sourcePermanent.getControllerId())) {
|
||||||
|
if (!permanent.getId().equals(sourcePermanent.getId())
|
||||||
|
|| permanent.getZoneChangeCounter(game) != sourcePermanent.getZoneChangeCounter(game)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue