mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Reverting my previous attempt at fixing Morbid + Awaken, wasn't a very good idea (broke a lot of stuff). Will see if I can come up with a better solution.
This commit is contained in:
@@ -251,7 +251,7 @@ public class GameAction {
|
||||
|
||||
// "enter the battlefield as a copy" - apply code here
|
||||
// but how to query for input here and continue later while the callers assume synchronous result?
|
||||
zoneTo.add(copied, position); // the modified state of the card is also reported here (e.g. for Morbid + Awaken)
|
||||
zoneTo.add(copied, position);
|
||||
|
||||
if (fromBattlefield) {
|
||||
c.setZone(zoneTo);
|
||||
|
||||
@@ -1443,7 +1443,7 @@ public class CardFactoryUtil {
|
||||
|
||||
// Count$Morbid.<True>.<False>
|
||||
if (sq[0].startsWith("Morbid")) {
|
||||
final CardCollection res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c, true);
|
||||
final CardCollection res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c);
|
||||
if (res.size() > 0) {
|
||||
return doXMath(Integer.parseInt(sq[1]), m, c);
|
||||
}
|
||||
|
||||
@@ -151,33 +151,18 @@ public final class CardUtil {
|
||||
* @param from zone coming from
|
||||
* @param valid a isValid expression
|
||||
* @param src a Card object
|
||||
* @param checkLatestState a boolean, true if the latest state of the card as it left the original zone needs to be checked
|
||||
* @return a CardCollection that matches the given criteria
|
||||
*/
|
||||
public static CardCollection getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
|
||||
return getThisTurnEntered(to, from, valid, src, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* getThisTurnEntered.
|
||||
*
|
||||
* @param to zone going to
|
||||
* @param from zone coming from
|
||||
* @param valid a isValid expression
|
||||
* @param src a Card object
|
||||
* @param checkLatestState a boolean, true if the latest state of the card as it left the original zone needs to be checked
|
||||
* @return a CardCollection that matches the given criteria
|
||||
*/
|
||||
public static CardCollection getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src, final boolean checkLatestState) {
|
||||
CardCollection res = new CardCollection();
|
||||
final Game game = src.getGame();
|
||||
if (to != ZoneType.Stack) {
|
||||
for (Player p : game.getPlayers()) {
|
||||
res.addAll(p.getZone(to).getCardsAddedThisTurn(from, checkLatestState));
|
||||
res.addAll(p.getZone(to).getCardsAddedThisTurn(from));
|
||||
}
|
||||
}
|
||||
else {
|
||||
res.addAll(game.getStackZone().getCardsAddedThisTurn(from, checkLatestState));
|
||||
res.addAll(game.getStackZone().getCardsAddedThisTurn(from));
|
||||
}
|
||||
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
||||
return res;
|
||||
|
||||
@@ -50,8 +50,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
|
||||
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
||||
protected final transient MapOfLists<ZoneType, Card> cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
||||
protected final transient MapOfLists<ZoneType, Card> latestStateCardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
||||
protected final transient MapOfLists<ZoneType, Card> latestStateCardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
||||
|
||||
public Zone(final ZoneType zone0, Game game0) {
|
||||
zoneType = zone0;
|
||||
@@ -75,16 +73,11 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
}
|
||||
|
||||
public void add(final Card c, final Integer index) {
|
||||
add(c, null, null);
|
||||
}
|
||||
|
||||
public void add(final Card c, final Integer index, final Card latestState) {
|
||||
// Immutable cards are usually emblems and effects
|
||||
if (!c.isImmutable()) {
|
||||
final Zone oldZone = game.getZoneOf(c);
|
||||
final ZoneType zt = oldZone == null ? ZoneType.Stack : oldZone.getZoneType();
|
||||
cardsAddedThisTurn.add(zt, c);
|
||||
latestStateCardsAddedThisTurn.add(zt, latestState != null ? latestState : c);
|
||||
}
|
||||
|
||||
c.setTurnInZone(game.getPhaseHandler().getTurn());
|
||||
@@ -164,42 +157,18 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
return cardsAddedThisTurn;
|
||||
}
|
||||
|
||||
public final MapOfLists<ZoneType, Card> getCardsAddedThisTurn(boolean latestState) {
|
||||
if (latestState) {
|
||||
return latestStateCardsAddedThisTurn;
|
||||
} else {
|
||||
return cardsAddedThisTurn;
|
||||
}
|
||||
}
|
||||
|
||||
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn() {
|
||||
return cardsAddedLastTurn;
|
||||
}
|
||||
|
||||
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn(boolean latestState) {
|
||||
if (latestState) {
|
||||
return latestStateCardsAddedLastTurn;
|
||||
} else {
|
||||
return cardsAddedLastTurn;
|
||||
}
|
||||
}
|
||||
|
||||
public final CardCollectionView getCardsAddedThisTurn(final ZoneType origin) {
|
||||
return getCardsAddedThisTurn(origin, false);
|
||||
}
|
||||
|
||||
public final CardCollectionView getCardsAddedThisTurn(final ZoneType origin, boolean latestState) {
|
||||
//System.out.print("Request cards put into " + getZoneType() + " from " + origin + ".Amount: ");
|
||||
return getCardsAdded(latestState ? latestStateCardsAddedThisTurn : cardsAddedThisTurn, origin);
|
||||
return getCardsAdded(cardsAddedThisTurn, origin);
|
||||
}
|
||||
|
||||
public final CardCollectionView getCardsAddedLastTurn(final ZoneType origin) {
|
||||
return getCardsAddedLastTurn(origin, false);
|
||||
}
|
||||
|
||||
public final CardCollectionView getCardsAddedLastTurn(final ZoneType origin, boolean latestState) {
|
||||
//System.out.print("Last turn - Request cards put into " + getZoneType() + " from " + origin + ".Amount: ");
|
||||
return getCardsAdded(latestState ? latestStateCardsAddedLastTurn : cardsAddedLastTurn, origin);
|
||||
return getCardsAdded(cardsAddedLastTurn, origin);
|
||||
}
|
||||
|
||||
private static CardCollectionView getCardsAdded(final MapOfLists<ZoneType, Card> cardsAdded, final ZoneType origin) {
|
||||
@@ -218,15 +187,10 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
||||
|
||||
public final void resetCardsAddedThisTurn() {
|
||||
cardsAddedLastTurn.clear();
|
||||
latestStateCardsAddedLastTurn.clear();
|
||||
for (final Entry<ZoneType, Collection<Card>> entry : cardsAddedThisTurn.entrySet()) {
|
||||
cardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (final Entry<ZoneType, Collection<Card>> entry : latestStateCardsAddedThisTurn.entrySet()) {
|
||||
latestStateCardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
||||
}
|
||||
cardsAddedThisTurn.clear();
|
||||
latestStateCardsAddedThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user