mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Test and fix for Dungeon Geists
This commit is contained in:
parent
57ac5ea930
commit
a2301a1f66
2 changed files with 52 additions and 11 deletions
|
@ -45,7 +45,6 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.watchers.WatcherImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -121,16 +120,28 @@ class DungeonGeistsEffect extends ReplacementEffectImpl<DungeonGeistsEffect> {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
//don't replace untap event if control of this has been lost
|
||||
Watcher watcher = game.getState().getWatchers().get("ControlLost", source.getSourceId());
|
||||
if (watcher == null || !watcher.conditionMet()) {
|
||||
if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
if (event.getTargetId().equals(targetPointer.getFirst(source))) {
|
||||
return true;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.LOST_CONTROL) {
|
||||
if (event.getPlayerId().equals(source.getControllerId()) && event.getTargetId().equals(source.getSourceId())) {
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
|
||||
if (event.getTargetId().equals(targetPointer.getFirst(source))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,13 +159,16 @@ class DungeonGeistsWatcher extends WatcherImpl<DungeonGeistsWatcher> {
|
|||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_CONTROL && event.getPlayerId().equals(controllerId) && event.getTargetId().equals(sourceId)) {
|
||||
condition = true;
|
||||
game.replaceEvent(event);
|
||||
return;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
condition = false;
|
||||
}
|
||||
condition = true;
|
||||
game.replaceEvent(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,4 +69,31 @@ public class DungeonGeistsTest extends CardTestPlayerBase {
|
|||
assertTapped("Craw Wurm", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithBlink() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 4);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||
addCard(Constants.Zone.HAND, playerA, "Dungeon Geists");
|
||||
addCard(Constants.Zone.HAND, playerA, "Cloudshift");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Elite Vanguard");
|
||||
|
||||
addTarget(playerA, "Craw Wurm"); // first target Craw Wurm
|
||||
addTarget(playerA, "Elite Vanguard"); // after Cloudshift effect (return back to battlefield) target Elite Vanguard
|
||||
|
||||
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists");
|
||||
castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Dungeon Geists");
|
||||
setStopAt(2, Constants.PhaseStep.DRAW);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
assertPermanentCount(playerA, "Dungeon Geists", 1);
|
||||
assertPermanentCount(playerB, "Craw Wurm", 1);
|
||||
assertPermanentCount(playerB, "Elite Vanguard", 1);
|
||||
assertTapped("Dungeon Geists", false);
|
||||
assertTapped("Elite Vanguard", true);
|
||||
assertTapped("Craw Wurm", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue