mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Merge branch 'thisTurnEnteredProperty' into 'master'
CardProperty: ThisTurnEntered and ThisTurnEnteredFrom for better check Closes #1711 and #1710 See merge request core-developers/forge!3777
This commit is contained in:
@@ -1039,17 +1039,21 @@ public class CardProperty {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (property.startsWith("ThisTurnEntered")) {
|
||||
final String restrictions = property.split("ThisTurnEntered_")[1];
|
||||
final String[] res = restrictions.split("_");
|
||||
final ZoneType destination = ZoneType.smartValueOf(res[0]);
|
||||
ZoneType origin = null;
|
||||
if (res.length > 1 && res[1].equals("from")) {
|
||||
origin = ZoneType.smartValueOf(res[2]);
|
||||
} else if (property.equals("ThisTurnEntered")) {
|
||||
// only check if it entered the Zone this turn
|
||||
if (card.getTurnInZone() != game.getPhaseHandler().getTurn()) {
|
||||
return false;
|
||||
}
|
||||
List<Card> cards = CardUtil.getThisTurnEntered(destination,
|
||||
origin, "Card", source);
|
||||
if (!cards.contains(card)) {
|
||||
} else if (property.startsWith("ThisTurnEnteredFrom")) {
|
||||
final String restrictions = property.split("ThisTurnEnteredFrom_")[1];
|
||||
final String[] res = restrictions.split("_");
|
||||
final ZoneType origin = ZoneType.smartValueOf(res[0]);
|
||||
|
||||
if (card.getTurnInZone() != game.getPhaseHandler().getTurn()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (card.getZone().isCardAddedThisTurn(card, origin)) {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("DiscardedThisTurn")) {
|
||||
|
||||
@@ -211,6 +211,13 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
return getCardsAdded(cardsAddedLastTurn, origin);
|
||||
}
|
||||
|
||||
public final boolean isCardAddedThisTurn(final Card card, final ZoneType origin) {
|
||||
if (!cardsAddedThisTurn.containsKey(origin)) {
|
||||
return false;
|
||||
}
|
||||
return cardsAddedThisTurn.get(origin).contains(card);
|
||||
}
|
||||
|
||||
private static List<Card> getCardsAdded(final MapOfLists<ZoneType, Card> cardsAdded, final ZoneType origin) {
|
||||
if (origin != null) {
|
||||
final Collection<Card> cards = cardsAdded.get(origin);
|
||||
|
||||
Reference in New Issue
Block a user