mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Merge pull request #2324 from Card-Forge/counterRemovedThisTurn
Game: add CountersRemovedThisTurn
This commit is contained in:
@@ -124,6 +124,7 @@ public class Game {
|
|||||||
private CardZoneTable untilHostLeavesPlayTriggerList = new CardZoneTable();
|
private CardZoneTable untilHostLeavesPlayTriggerList = new CardZoneTable();
|
||||||
|
|
||||||
private Table<CounterType, Player, List<Pair<Card, Integer>>> countersAddedThisTurn = HashBasedTable.create();
|
private Table<CounterType, Player, List<Pair<Card, Integer>>> countersAddedThisTurn = HashBasedTable.create();
|
||||||
|
private Multimap<CounterType, Pair<Card, Integer>> countersRemovedThisTurn = ArrayListMultimap.create();
|
||||||
|
|
||||||
private FCollection<CardDamageHistory> globalDamageHistory = new FCollection<>();
|
private FCollection<CardDamageHistory> globalDamageHistory = new FCollection<>();
|
||||||
private IdentityHashMap<Pair<Integer, Boolean>, Pair<Card, GameEntity>> damageThisTurnLKI = new IdentityHashMap<>();
|
private IdentityHashMap<Pair<Integer, Boolean>, Pair<Card, GameEntity>> damageThisTurnLKI = new IdentityHashMap<>();
|
||||||
@@ -1102,6 +1103,7 @@ public class Game {
|
|||||||
|
|
||||||
public void onCleanupPhase() {
|
public void onCleanupPhase() {
|
||||||
clearCounterAddedThisTurn();
|
clearCounterAddedThisTurn();
|
||||||
|
clearCounterRemovedThisTurn();
|
||||||
clearGlobalDamageHistory();
|
clearGlobalDamageHistory();
|
||||||
// some cards need this info updated even after a player lost, so don't skip them
|
// some cards need this info updated even after a player lost, so don't skip them
|
||||||
for (Player player : getRegisteredPlayers()) {
|
for (Player player : getRegisteredPlayers()) {
|
||||||
@@ -1142,6 +1144,24 @@ public class Game {
|
|||||||
countersAddedThisTurn.clear();
|
countersAddedThisTurn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCounterRemovedThisTurn(CounterType cType, Card card, Integer value) {
|
||||||
|
countersRemovedThisTurn.put(cType, Pair.of(CardUtil.getLKICopy(card), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCounterRemovedThisTurn(CounterType cType, String validCard, Card source, Player sourceController, CardTraitBase ctb) {
|
||||||
|
int result = 0;
|
||||||
|
for (Pair<Card, Integer> p : countersRemovedThisTurn.get(cType)) {
|
||||||
|
if (p.getKey().isValid(validCard.split(","), sourceController, source, ctb)) {
|
||||||
|
result += p.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearCounterRemovedThisTurn() {
|
||||||
|
countersRemovedThisTurn.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the damage instances done this turn.
|
* Gets the damage instances done this turn.
|
||||||
* @param isCombat if true only combat damage matters, pass null for both
|
* @param isCombat if true only combat damage matters, pass null for both
|
||||||
|
|||||||
@@ -958,6 +958,7 @@ public class AbilityUtils {
|
|||||||
* a {@link forge.game.spellability.SpellAbility} object.
|
* a {@link forge.game.spellability.SpellAbility} object.
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static PlayerCollection getDefinedPlayers(final Card card, final String def, final CardTraitBase sa) {
|
public static PlayerCollection getDefinedPlayers(final Card card, final String def, final CardTraitBase sa) {
|
||||||
final PlayerCollection players = new PlayerCollection();
|
final PlayerCollection players = new PlayerCollection();
|
||||||
String changedDef = (def == null) ? "You" : applyAbilityTextChangeEffects(def, sa); // default to Self
|
String changedDef = (def == null) ? "You" : applyAbilityTextChangeEffects(def, sa); // default to Self
|
||||||
@@ -2745,6 +2746,12 @@ public class AbilityUtils {
|
|||||||
|
|
||||||
return doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c, ctb);
|
return doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c, ctb);
|
||||||
}
|
}
|
||||||
|
if (sq[0].startsWith("CountersRemovedThisTurn")) {
|
||||||
|
final String[] parts = l[0].split(" ");
|
||||||
|
CounterType cType = CounterType.getType(parts[1]);
|
||||||
|
|
||||||
|
return doXMath(game.getCounterRemovedThisTurn(cType, parts[2], c, player, ctb), expr, c, ctb);
|
||||||
|
}
|
||||||
|
|
||||||
// count valid cards in any specified zone/s
|
// count valid cards in any specified zone/s
|
||||||
if (sq[0].startsWith("Valid")) {
|
if (sq[0].startsWith("Valid")) {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class RestartGameEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
game.getStack().reset();
|
game.getStack().reset();
|
||||||
game.clearCounterAddedThisTurn();
|
game.clearCounterAddedThisTurn();
|
||||||
|
game.clearCounterRemovedThisTurn();
|
||||||
game.setMonarch(null);
|
game.setMonarch(null);
|
||||||
game.setHasInitiative(null);
|
game.setHasInitiative(null);
|
||||||
game.setDayTime(null);
|
game.setDayTime(null);
|
||||||
|
|||||||
@@ -1589,6 +1589,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
// Play the Subtract Counter sound
|
// Play the Subtract Counter sound
|
||||||
getGame().fireEvent(new GameEventCardCounters(this, counterName, oldValue, newValue));
|
getGame().fireEvent(new GameEventCardCounters(this, counterName, oldValue, newValue));
|
||||||
|
|
||||||
|
getGame().addCounterRemovedThisTurn(counterName, this, delta);
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
int curCounters = oldValue;
|
int curCounters = oldValue;
|
||||||
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(this);
|
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user