mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Use timestamps
This commit is contained in:
@@ -8,7 +8,6 @@ import forge.game.card.Card;
|
|||||||
import forge.game.event.GameEventCardStatsChanged;
|
import forge.game.event.GameEventCardStatsChanged;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.zone.ZoneType;
|
|
||||||
|
|
||||||
public class LifeExchangeVariantEffect extends SpellAbilityEffect {
|
public class LifeExchangeVariantEffect extends SpellAbilityEffect {
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,15 @@ public class MustBlockEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
final boolean mustBlockAll = sa.hasParam("BlockAllDefined");
|
final boolean mustBlockAll = sa.hasParam("BlockAllDefined");
|
||||||
|
|
||||||
|
long ts = game.getNextTimestamp();
|
||||||
|
|
||||||
for (final Card c : tgtCards) {
|
for (final Card c : tgtCards) {
|
||||||
if ((!sa.usesTargeting()) || c.canBeTargetedBy(sa)) {
|
if ((!sa.usesTargeting()) || c.canBeTargetedBy(sa)) {
|
||||||
if (mustBlockAll) {
|
if (mustBlockAll) {
|
||||||
c.addMustBlockCards(cards);
|
c.addMustBlockCards(ts, cards);
|
||||||
} else {
|
} else {
|
||||||
final Card attacker = cards.get(0);
|
final Card attacker = cards.get(0);
|
||||||
c.addMustBlockCard(attacker);
|
c.addMustBlockCard(ts, attacker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,12 +79,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final Card c : tgtCards) {
|
for (final Card c : tgtCards) {
|
||||||
if (mustBlockAll) {
|
c.removeMustBlockCards(ts);
|
||||||
c.removeMustBlockCards(cards);
|
|
||||||
} else {
|
|
||||||
final Card attacker = cards.get(0);
|
|
||||||
c.removeMustBlockCard(attacker);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,8 +108,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
|
|
||||||
// cards attached or otherwise linked to this card
|
// cards attached or otherwise linked to this card
|
||||||
private CardCollection hauntedBy, devouredCards, exploitedCards, delvedCards, convokedCards, imprintedCards, encodedCards;
|
private CardCollection hauntedBy, devouredCards, exploitedCards, delvedCards, convokedCards, imprintedCards, encodedCards;
|
||||||
private CardCollection mustBlockCards, gainControlTargets, chosenCards;
|
private CardCollection gainControlTargets, chosenCards;
|
||||||
private CardCollection mergedCards;
|
private CardCollection mergedCards;
|
||||||
|
private Map<Long, CardCollection> mustBlockCards = Maps.newHashMap();
|
||||||
private List<Card> blockedThisTurn = Lists.newArrayList();
|
private List<Card> blockedThisTurn = Lists.newArrayList();
|
||||||
private List<Card> blockedByThisTurn = Lists.newArrayList();
|
private List<Card> blockedByThisTurn = Lists.newArrayList();
|
||||||
|
|
||||||
@@ -1313,22 +1314,22 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
//MustBlockCards are cards that this Card must block if able in an upcoming combat.
|
//MustBlockCards are cards that this Card must block if able in an upcoming combat.
|
||||||
//This is cleared at the end of each turn.
|
//This is cleared at the end of each turn.
|
||||||
public final CardCollectionView getMustBlockCards() {
|
public final CardCollectionView getMustBlockCards() {
|
||||||
return CardCollection.getView(mustBlockCards);
|
return CardCollection.getView(Iterables.concat(mustBlockCards.values()));
|
||||||
}
|
}
|
||||||
public final void addMustBlockCard(final Card c) {
|
public final void addMustBlockCard(long ts, final Card c) {
|
||||||
mustBlockCards = view.addCard(mustBlockCards, c, TrackableProperty.MustBlockCards);
|
mustBlockCards.put(ts, new CardCollection(c));
|
||||||
|
view.setCards(null, Iterables.concat(mustBlockCards.values()), TrackableProperty.MustBlockCards);
|
||||||
}
|
}
|
||||||
public final void addMustBlockCards(final Iterable<Card> attackersToBlock) {
|
public final void addMustBlockCards(long ts, final Iterable<Card> attackersToBlock) {
|
||||||
mustBlockCards = view.addCards(mustBlockCards, attackersToBlock, TrackableProperty.MustBlockCards);
|
mustBlockCards.put(ts, new CardCollection(attackersToBlock));
|
||||||
|
view.setCards(null, Iterables.concat(mustBlockCards.values()), TrackableProperty.MustBlockCards);
|
||||||
}
|
}
|
||||||
public final void removeMustBlockCard(final Card c) {
|
public final void removeMustBlockCards(long ts) {
|
||||||
mustBlockCards = view.removeCard(mustBlockCards, c, TrackableProperty.MustBlockCards);
|
mustBlockCards.remove(ts);
|
||||||
}
|
view.setCards(null, Iterables.concat(mustBlockCards.values()), TrackableProperty.MustBlockCards);
|
||||||
public final void removeMustBlockCards(final Iterable<Card> attackersToBlock) {
|
|
||||||
mustBlockCards = view.removeCards(mustBlockCards, attackersToBlock, TrackableProperty.MustBlockCards);
|
|
||||||
}
|
}
|
||||||
public final void clearMustBlockCards() {
|
public final void clearMustBlockCards() {
|
||||||
mustBlockCards = view.clearCards(mustBlockCards, TrackableProperty.MustBlockCards);
|
view.setCards(null, null, TrackableProperty.MustBlockCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setMustAttackEntity(final GameEntity e) {
|
public final void setMustAttackEntity(final GameEntity e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user