Playing events from other zones should move the card to void. There are two void zones now - "VOID" and "VOID_FROM_HAND", that's because if a card is played from hand, it still counts for initiative purposes.

This commit is contained in:
marcins78
2013-01-08 12:21:30 +00:00
parent 73668d7043
commit 1b9d93c774
12 changed files with 31 additions and 18 deletions

View File

@@ -112,6 +112,8 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
final Zone playedFromZone = _cardToAttach.getZone();
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
if (playedFromZone == Zone.HAND)
game.getGameState().addCardToZone(game, _cardToAttach, Zone.VOID_FROM_HAND);
else
game.getGameState().addCardToZone(game, _cardToAttach, Zone.VOID);
if (playedFromZone == Zone.DECK)
game.getGameState().shuffleDeck(_cardToAttach.getOwner());
@@ -167,16 +169,14 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
} else {
if (!_cardDiscarded) {
_cardDiscarded = true;
if (_cardToAttach.getZone() != null)
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
game.getGameState().addCardToZone(game, _cardToAttach, Zone.DISCARD);
}
}
} else {
if (!_cardDiscarded) {
_cardDiscarded = true;
if (_cardToAttach.getZone() != null)
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
game.getGameState().addCardToZone(game, _cardToAttach, Zone.DISCARD);
}
}

View File

@@ -97,7 +97,11 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco
game.getGameState().sendMessage(_eventPlayed.getOwner() + " plays " + GameUtils.getCardLink(_eventPlayed) + " from " + playedFromZone.getHumanReadable());
game.getGameState().removeCardsFromZone(_eventPlayed.getOwner(), Collections.singleton(_eventPlayed));
game.getGameState().addCardToZone(game, _eventPlayed, Zone.VOID);
if (playedFromZone == Zone.HAND)
game.getGameState().addCardToZone(game, _eventPlayed, Zone.VOID_FROM_HAND);
else
game.getGameState().addCardToZone(game, _eventPlayed, Zone.VOID);
if (playedFromZone == Zone.DECK)
game.getGameState().shuffleDeck(_eventPlayed.getOwner());

View File

@@ -88,6 +88,8 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
game.getGameState().sendMessage(_permanentPlayed.getOwner() + " plays " + GameUtils.getCardLink(_permanentPlayed) + " from " + playedFromZone.getHumanReadable());
game.getGameState().removeCardsFromZone(_permanentPlayed.getOwner(), Collections.singleton(_permanentPlayed));
if (playedFromZone == Zone.HAND)
game.getGameState().addCardToZone(game, _permanentPlayed, Zone.VOID_FROM_HAND);
else
game.getGameState().addCardToZone(game, _permanentPlayed, Zone.VOID);
if (playedFromZone == Zone.DECK && !_skipShuffling)
game.getGameState().shuffleDeck(_permanentPlayed.getOwner());
@@ -137,8 +139,7 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
} else {
if (!_cardDiscarded) {
_cardDiscarded = true;
if (_permanentPlayed.getZone() != null)
game.getGameState().removeCardsFromZone(_permanentPlayed.getOwner(), Collections.singleton(_permanentPlayed));
game.getGameState().removeCardsFromZone(_permanentPlayed.getOwner(), Collections.singleton(_permanentPlayed));
game.getGameState().addCardToZone(game, _permanentPlayed, Zone.DISCARD);
}
}

View File

@@ -28,7 +28,8 @@ public class PutPlayedEventIntoHandEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return _action.getEventPlayed().getZone() == Zone.VOID;
Zone zone = _action.getEventPlayed().getZone();
return zone == Zone.VOID || zone == Zone.VOID_FROM_HAND;
}
@Override

View File

@@ -28,7 +28,8 @@ public class PutPlayedEventOnBottomOfDeckEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return _action.getEventPlayed().getZone() == Zone.VOID;
Zone zone = _action.getEventPlayed().getZone();
return zone == Zone.VOID || zone == Zone.VOID_FROM_HAND;
}
@Override

View File

@@ -28,7 +28,8 @@ public class PutPlayedEventOnTopOfDeckEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return _action.getEventPlayed().getZone() == Zone.VOID;
Zone zone = _action.getEventPlayed().getZone();
return zone == Zone.VOID || zone == Zone.VOID_FROM_HAND;
}
@Override

View File

@@ -28,7 +28,8 @@ public class RemovePlayedEventFromGameEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return _action.getEventPlayed().getZone() == Zone.VOID;
Zone zone = _action.getEventPlayed().getZone();
return zone == Zone.VOID || zone == Zone.VOID_FROM_HAND;
}
@Override

View File

@@ -30,7 +30,8 @@ public class StackPlayedEventOnACardEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return _stackOn.getZone().isInPlay() && _action.getEventPlayed().getZone() == Zone.VOID;
Zone zone = _action.getEventPlayed().getZone();
return _stackOn.getZone().isInPlay() && (zone == Zone.VOID || zone == Zone.VOID_FROM_HAND);
}
@Override

View File

@@ -13,7 +13,7 @@ public enum Zone implements Filterable {
ADVENTURE_DECK("adventureDeck", false, true, false),
// Nobody sees
VOID("void", false, false, false), DECK("deck", false, false, false), REMOVED("removed", false, false, false);
VOID("void", false, false, false), VOID_FROM_HAND("voidFromHand", false, false, false), DECK("deck", false, false, false), REMOVED("removed", false, false, false);
private String _humanReadable;
private boolean _public;

View File

@@ -22,6 +22,7 @@ public class GameState {
private Map<String, List<PhysicalCardImpl>> _stacked = new HashMap<String, List<PhysicalCardImpl>>();
private Map<String, List<PhysicalCardImpl>> _voids = new HashMap<String, List<PhysicalCardImpl>>();
private Map<String, List<PhysicalCardImpl>> _voidsFromHand = new HashMap<String, List<PhysicalCardImpl>>();
private Map<String, List<PhysicalCardImpl>> _removed = new HashMap<String, List<PhysicalCardImpl>>();
private List<PhysicalCardImpl> _inPlay = new LinkedList<PhysicalCardImpl>();
@@ -74,6 +75,7 @@ public class GameState {
_decks.put(playerId, new LinkedList<PhysicalCardImpl>());
_hands.put(playerId, new LinkedList<PhysicalCardImpl>());
_voids.put(playerId, new LinkedList<PhysicalCardImpl>());
_voidsFromHand.put(playerId, new LinkedList<PhysicalCardImpl>());
_removed.put(playerId, new LinkedList<PhysicalCardImpl>());
_discards.put(playerId, new LinkedList<PhysicalCardImpl>());
_deadPiles.put(playerId, new LinkedList<PhysicalCardImpl>());
@@ -342,6 +344,8 @@ public class GameState {
return _hands.get(playerId);
else if (zone == Zone.VOID)
return _voids.get(playerId);
else if (zone == Zone.VOID_FROM_HAND)
return _voidsFromHand.get(playerId);
else if (zone == Zone.REMOVED)
return _removed.get(playerId);
else if (zone == Zone.STACKED)
@@ -604,8 +608,8 @@ public class GameState {
return Collections.unmodifiableList(_hands.get(playerId));
}
public List<? extends PhysicalCard> getVoid(String playerId) {
return Collections.unmodifiableList(_voids.get(playerId));
public List<? extends PhysicalCard> getVoidFromHand(String playerId) {
return Collections.unmodifiableList(_voidsFromHand.get(playerId));
}
public List<? extends PhysicalCard> getRemoved(String playerId) {

View File

@@ -57,8 +57,7 @@ public class PlayCardEffect extends AbstractEffect {
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (_cardPlayed.getZone() != null)
game.getGameState().removeCardsFromZone(_cardPlayed.getOwner(), Collections.singleton(_cardPlayed));
game.getGameState().removeCardsFromZone(_cardPlayed.getOwner(), Collections.singleton(_cardPlayed));
if (_attachedToCard != null) {
game.getGameState().attachCard(game, _cardPlayed, _attachedToCard);
} else {

View File

@@ -924,7 +924,7 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
}
int freePeopleInitiativeHandSize = gameState.getHand(gameState.getCurrentPlayerId()).size()
+ gameState.getVoid(gameState.getCurrentPlayerId()).size();
+ gameState.getVoidFromHand(gameState.getCurrentPlayerId()).size();
int initiativeHandSize = 4;
for (Modifier modifier : getModifiers(gameState, ModifierEffect.INITIATIVE_MODIFIER))