Assigning new ids to cards each time they change zones, except for transfering or taking control.
This commit is contained in:
@@ -434,19 +434,23 @@ public class Filters {
|
||||
}
|
||||
|
||||
public static Filter sameCard(final PhysicalCard card) {
|
||||
final int cardId = card.getCardId();
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return (physicalCard == card);
|
||||
return (physicalCard.getCardId() == cardId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Filter in(final Collection<PhysicalCard> cards) {
|
||||
final Set<Integer> cardIds = new HashSet<Integer>();
|
||||
for (PhysicalCard card : cards)
|
||||
cardIds.add(card.getCardId());
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return cards.contains(physicalCard);
|
||||
return cardIds.contains(physicalCard.getCardId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +32,10 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
_blueprint = blueprint;
|
||||
}
|
||||
|
||||
public void setCardId(int cardId) {
|
||||
_cardId = cardId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlueprintId() {
|
||||
return _blueprintId;
|
||||
|
||||
@@ -352,6 +352,8 @@ public class GameState {
|
||||
}
|
||||
|
||||
private void addCardToZone(LotroGame game, PhysicalCard card, Zone zone, boolean end) {
|
||||
assignNewCardId(card);
|
||||
|
||||
List<PhysicalCardImpl> zoneCards = getZoneCards(card.getOwner(), card.getBlueprint().getCardType(), zone);
|
||||
if (end)
|
||||
zoneCards.add((PhysicalCardImpl) card);
|
||||
@@ -380,6 +382,13 @@ public class GameState {
|
||||
}
|
||||
}
|
||||
|
||||
private void assignNewCardId(PhysicalCard card) {
|
||||
_allCards.remove(card.getCardId());
|
||||
int newCardId = nextCardId();
|
||||
((PhysicalCardImpl) card).setCardId(newCardId);
|
||||
_allCards.put(newCardId, ((PhysicalCardImpl) card));
|
||||
}
|
||||
|
||||
private void removeAllTokens(PhysicalCard card) {
|
||||
Map<Token, Integer> map = _cardTokens.get(card);
|
||||
if (map != null) {
|
||||
|
||||
Reference in New Issue
Block a user