mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +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
|
// "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?
|
// 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) {
|
if (fromBattlefield) {
|
||||||
c.setZone(zoneTo);
|
c.setZone(zoneTo);
|
||||||
|
|||||||
@@ -1443,7 +1443,7 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
// Count$Morbid.<True>.<False>
|
// Count$Morbid.<True>.<False>
|
||||||
if (sq[0].startsWith("Morbid")) {
|
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) {
|
if (res.size() > 0) {
|
||||||
return doXMath(Integer.parseInt(sq[1]), m, c);
|
return doXMath(Integer.parseInt(sq[1]), m, c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,33 +151,18 @@ public final class CardUtil {
|
|||||||
* @param from zone coming from
|
* @param from zone coming from
|
||||||
* @param valid a isValid expression
|
* @param valid a isValid expression
|
||||||
* @param src a Card object
|
* @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
|
* @return a CardCollection that matches the given criteria
|
||||||
*/
|
*/
|
||||||
public static CardCollection getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) {
|
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();
|
CardCollection res = new CardCollection();
|
||||||
final Game game = src.getGame();
|
final Game game = src.getGame();
|
||||||
if (to != ZoneType.Stack) {
|
if (to != ZoneType.Stack) {
|
||||||
for (Player p : game.getPlayers()) {
|
for (Player p : game.getPlayers()) {
|
||||||
res.addAll(p.getZone(to).getCardsAddedThisTurn(from, checkLatestState));
|
res.addAll(p.getZone(to).getCardsAddedThisTurn(from));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.addAll(game.getStackZone().getCardsAddedThisTurn(from, checkLatestState));
|
res.addAll(game.getStackZone().getCardsAddedThisTurn(from));
|
||||||
}
|
}
|
||||||
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
res = CardLists.getValidCards(res, valid, src.getController(), src);
|
||||||
return res;
|
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> 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> 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) {
|
public Zone(final ZoneType zone0, Game game0) {
|
||||||
zoneType = zone0;
|
zoneType = zone0;
|
||||||
@@ -75,16 +73,11 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(final Card c, final Integer index) {
|
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
|
// Immutable cards are usually emblems and effects
|
||||||
if (!c.isImmutable()) {
|
if (!c.isImmutable()) {
|
||||||
final Zone oldZone = game.getZoneOf(c);
|
final Zone oldZone = game.getZoneOf(c);
|
||||||
final ZoneType zt = oldZone == null ? ZoneType.Stack : oldZone.getZoneType();
|
final ZoneType zt = oldZone == null ? ZoneType.Stack : oldZone.getZoneType();
|
||||||
cardsAddedThisTurn.add(zt, c);
|
cardsAddedThisTurn.add(zt, c);
|
||||||
latestStateCardsAddedThisTurn.add(zt, latestState != null ? latestState : c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.setTurnInZone(game.getPhaseHandler().getTurn());
|
c.setTurnInZone(game.getPhaseHandler().getTurn());
|
||||||
@@ -164,42 +157,18 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
return cardsAddedThisTurn;
|
return cardsAddedThisTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final MapOfLists<ZoneType, Card> getCardsAddedThisTurn(boolean latestState) {
|
|
||||||
if (latestState) {
|
|
||||||
return latestStateCardsAddedThisTurn;
|
|
||||||
} else {
|
|
||||||
return cardsAddedThisTurn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn() {
|
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn() {
|
||||||
return cardsAddedLastTurn;
|
return cardsAddedLastTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final MapOfLists<ZoneType, Card> getCardsAddedLastTurn(boolean latestState) {
|
|
||||||
if (latestState) {
|
|
||||||
return latestStateCardsAddedLastTurn;
|
|
||||||
} else {
|
|
||||||
return cardsAddedLastTurn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final CardCollectionView getCardsAddedThisTurn(final ZoneType origin) {
|
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: ");
|
//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) {
|
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: ");
|
//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) {
|
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() {
|
public final void resetCardsAddedThisTurn() {
|
||||||
cardsAddedLastTurn.clear();
|
cardsAddedLastTurn.clear();
|
||||||
latestStateCardsAddedLastTurn.clear();
|
|
||||||
for (final Entry<ZoneType, Collection<Card>> entry : cardsAddedThisTurn.entrySet()) {
|
for (final Entry<ZoneType, Collection<Card>> entry : cardsAddedThisTurn.entrySet()) {
|
||||||
cardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
cardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
for (final Entry<ZoneType, Collection<Card>> entry : latestStateCardsAddedThisTurn.entrySet()) {
|
|
||||||
latestStateCardsAddedLastTurn.addAll(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
cardsAddedThisTurn.clear();
|
cardsAddedThisTurn.clear();
|
||||||
latestStateCardsAddedThisTurn.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user