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

@ -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,8 +98,9 @@ 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;
protected Date endTime;
protected UUID startingPlayerId;
@ -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) {