Added short living lki. Soul Warden works. All tests passed.

This commit is contained in:
magenoxx 2012-06-04 21:19:11 +04:00
parent 5f3c38af69
commit 88a303a52f
5 changed files with 27 additions and 4 deletions

View file

@ -79,6 +79,7 @@ class TreacherousPitDwellerTriggeredAbility extends ZoneChangeTriggeredAbility<T
public TreacherousPitDwellerTriggeredAbility() {
super(Constants.Zone.GRAVEYARD, Constants.Zone.BATTLEFIELD, new TreacherousPitDwellerEffect(), ruleText, false);
zone = Constants.Zone.BATTLEFIELD;
addTarget(new TargetOpponent(true));
}

View file

@ -28,7 +28,6 @@
package mage.sets.magic2010;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
@ -42,6 +41,8 @@ import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -89,7 +90,7 @@ class SoulWardenAbility extends TriggeredAbilityImpl<SoulWardenAbility> {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.getCardType().contains(CardType.CREATURE) && !permanent.getId().equals(this.getSourceId())) {
if (permanent.getCardType().contains(CardType.CREATURE) && !permanent.getId().equals(this.getSourceId())) {
return true;
}
}

View file

@ -463,7 +463,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
// try LKI first
if (checkLKI) {
MageObject lkiTest = game.getLastKnownInformation(getSourceId(), zone);
MageObject lkiTest = game.getShortLivingLKI(getSourceId(), zone);
if (lkiTest != null) {
return true;
}

View file

@ -112,8 +112,10 @@ public interface Game extends MageItem, Serializable {
public boolean isSimulation();
public void setSimulation(boolean simulation);
public MageObject getLastKnownInformation(UUID objectId, Zone zone);
public MageObject getShortLivingLKI(UUID objectId, Zone zone);
public void rememberLKI(UUID objectId, Zone zone, MageObject object);
public void resetLKI();
public void resetShortLivingLKI();
public void setLosingPlayer(Player player);
public Player getLosingPlayer();
public void setStateCheckRequired();

View file

@ -98,6 +98,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
protected Map<UUID, Card> gameCards = new HashMap<UUID, Card>();
protected Map<UUID, MageObject> lki = new HashMap<UUID, MageObject>();
protected Map<UUID, MageObject> shortLivingLKI = new HashMap<UUID, MageObject>();
protected GameState state;
protected Date startTime;
@ -150,6 +151,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
this.simulation = game.simulation;
this.gameOptions = game.gameOptions;
this.lki.putAll(game.lki);
this.shortLivingLKI.putAll(game.shortLivingLKI);
if (logger.isDebugEnabled()) {
copyCount++;
copyTime += (System.currentTimeMillis() - t1);
@ -650,6 +652,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
}
resuming = false;
}
resetShortLivingLKI();
resuming = false;
if (isPaused() || isGameOver()) return;
if (allPassed()) {
@ -661,6 +664,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
fireUpdatePlayersEvent();
state.getRevealed().reset();
//resetLKI();
resetShortLivingLKI();
break;
} else {
//removeBookmark(bookmark);
@ -1295,6 +1299,15 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
return null;
}
@Override
public MageObject getShortLivingLKI(UUID objectId, Zone zone) {
MageObject object = shortLivingLKI.get(objectId);
if (object != null) {
return object.copy();
}
return null;
}
/**
* Remembers object state to be used as Last Known Information.
*
@ -1307,6 +1320,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
if (object instanceof Permanent || object instanceof StackObject) {
MageObject copy = object.copy();
lki.put(objectId, copy);
shortLivingLKI.put(objectId, copy);
}
}
@ -1318,6 +1332,11 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
lki.clear();
}
@Override
public void resetShortLivingLKI() {
shortLivingLKI.clear();
}
@Override
public void cheat(UUID ownerId, Map<Zone, String> commands) {
if (commands != null) {