mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +00:00
Merge branch 'counterAddRemoveUpdate' into 'master'
Counter Effects: update Last State See merge request core-developers/forge!313
This commit is contained in:
@@ -2,6 +2,7 @@ package forge.game.ability.effects;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -35,6 +36,7 @@ public class CountersMultiplyEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = host.getGame();
|
||||
|
||||
final CounterType counterType = getCounterType(sa);
|
||||
final int n = Integer.valueOf(sa.getParamOrDefault("Multiplier", "2")) - 1;
|
||||
@@ -47,6 +49,7 @@ public class CountersMultiplyEffect extends SpellAbilityEffect {
|
||||
tgtCard.addCounter(e.getKey(), e.getValue() * n, host, false);
|
||||
}
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -24,6 +25,7 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = host.getGame();
|
||||
Player controller = host.getController();
|
||||
Map<GameEntity, CounterType> proliferateChoice = controller.getController().chooseProliferation(sa);
|
||||
if (proliferateChoice == null )
|
||||
@@ -31,8 +33,11 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
|
||||
for(Entry<GameEntity, CounterType> ge: proliferateChoice.entrySet()) {
|
||||
if( ge.getKey() instanceof Player )
|
||||
((Player) ge.getKey()).addCounter(ge.getValue(), 1, host, true);
|
||||
else if( ge.getKey() instanceof Card)
|
||||
((Card) ge.getKey()).addCounter(ge.getValue(), 1, host, true);
|
||||
else if( ge.getKey() instanceof Card) {
|
||||
Card c = (Card) ge.getKey();
|
||||
c.addCounter(ge.getValue(), 1, host, true);
|
||||
game.updateLastStateForCard(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
|
||||
final ZoneType zone = sa.hasParam("ValidZone") ? ZoneType.smartValueOf(sa.getParam("ValidZone")) : ZoneType.Battlefield;
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
|
||||
if (counterAmount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CardCollectionView cards = game.getCardsIn(zone);
|
||||
cards = CardLists.getValidCards(cards, valid, sa.getHostCard().getController(), sa.getHostCard());
|
||||
|
||||
@@ -59,6 +63,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
|
||||
// adding counters to something like re-suspend cards
|
||||
tgtCard.addCounter(CounterType.valueOf(type), counterAmount, host, false);
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
@@ -12,13 +13,13 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -180,22 +181,23 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
if (sa.hasParam("Tribute")) {
|
||||
// make a copy to check if it would be on the battlefield
|
||||
Card noTributeLKI = CardUtil.getLKICopy(tgtCard);
|
||||
// this check needs to check if this card would be on the battlefield
|
||||
noTributeLKI.setLastKnownZone(activator.getZone(ZoneType.Battlefield));
|
||||
|
||||
CardCollection preList = new CardCollection(noTributeLKI);
|
||||
game.getAction().checkStaticAbilities(false, Sets.newHashSet(noTributeLKI), preList);
|
||||
|
||||
// check if it can recive the Tribute
|
||||
if (!noTributeLKI.canReceiveCounters(counterType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String message = "Do you want to put " + counterAmount + " +1/+1 counters on " + tgtCard + " ?";
|
||||
Player chooser = pc.chooseSingleEntityForEffect(activator.getOpponents(), sa, "Choose an opponent");
|
||||
|
||||
// Check for effects like Solemnity
|
||||
boolean cantPayTribute = false;
|
||||
for (Card c : game.getCardsIn(ZoneType.Battlefield)) {
|
||||
for (StaticAbility stAb : c.getStaticAbilities()) {
|
||||
if (stAb.getParam("AddKeyword") != null && stAb.getParam("Affected") != null
|
||||
&& stAb.getParam("AddKeyword").contains("CARDNAME can't have counters put on it.")
|
||||
&& card.isValid(stAb.getParam("Affected").split(","), activator, card, sa)) {
|
||||
cantPayTribute = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!cantPayTribute && chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message)) {
|
||||
if (chooser.getController().confirmAction(sa, PlayerActionConfirmMode.Tribute, message)) {
|
||||
tgtCard.setTributed(true);
|
||||
} else {
|
||||
continue;
|
||||
@@ -243,6 +245,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
|
||||
tgtCard.addCounter(counterType, counterAmount, card, false);
|
||||
}
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
} else if (obj instanceof Player) {
|
||||
// Add Counters to players!
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -43,8 +44,13 @@ public class CountersPutOrRemoveEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
final int counterAmount = AbilityUtils.calculateAmount(source, sa.getParam("CounterNum"), sa);
|
||||
|
||||
|
||||
if (counterAmount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
CounterType ctype = null;
|
||||
if (sa.hasParam("CounterType")) {
|
||||
ctype = CounterType.valueOf(sa.getParam("CounterType"));
|
||||
@@ -60,6 +66,7 @@ public class CountersPutOrRemoveEffect extends SpellAbilityEffect {
|
||||
} else {
|
||||
addOrRemoveCounter(sa, tgtCard, ctype, counterAmount);
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,10 @@ public class CountersRemoveAllEffect extends SpellAbilityEffect {
|
||||
counterAmount = tgtCard.getCounters(CounterType.valueOf(type));
|
||||
}
|
||||
|
||||
tgtCard.subtractCounter(CounterType.valueOf(type), counterAmount);
|
||||
if (counterAmount > 0) {
|
||||
tgtCard.subtractCounter(CounterType.valueOf(type), counterAmount);
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
}
|
||||
if (sa.hasParam("RememberAmount")) {
|
||||
sa.getHostCard().setChosenNumber(numberRemoved);
|
||||
|
||||
@@ -114,6 +114,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
for (Map.Entry<CounterType, Integer> e : tgtCard.getCounters().entrySet()) {
|
||||
tgtCard.subtractCounter(e.getKey(), e.getValue());
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
continue;
|
||||
} else if (num.equals("All")) {
|
||||
cntToRemove = tgtCard.getCounters(counterType);
|
||||
@@ -139,13 +140,16 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
params.put("CounterType", chosenType);
|
||||
int chosenAmount = pc.chooseNumber(sa, prompt, 1, max, params);
|
||||
|
||||
tgtCard.subtractCounter(chosenType, chosenAmount);
|
||||
if (rememberRemoved) {
|
||||
for (int i = 0; i < chosenAmount; i++) {
|
||||
card.addRemembered(Pair.of(chosenType, i));
|
||||
if (chosenAmount > 0) {
|
||||
tgtCard.subtractCounter(chosenType, chosenAmount);
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
if (rememberRemoved) {
|
||||
for (int i = 0; i < chosenAmount; i++) {
|
||||
card.addRemembered(Pair.of(chosenType, i));
|
||||
}
|
||||
}
|
||||
cntToRemove -= chosenAmount;
|
||||
}
|
||||
cntToRemove -= chosenAmount;
|
||||
}
|
||||
} else {
|
||||
cntToRemove = Math.min(cntToRemove, tgtCard.getCounters(counterType));
|
||||
@@ -160,12 +164,15 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
|
||||
}
|
||||
|
||||
}
|
||||
if (rememberRemoved) {
|
||||
for (int i = 0; i < cntToRemove; i++) {
|
||||
card.addRemembered(Pair.of(counterType, i));
|
||||
if (cntToRemove > 0) {
|
||||
tgtCard.subtractCounter(counterType, cntToRemove);
|
||||
if (rememberRemoved) {
|
||||
for (int i = 0; i < cntToRemove; i++) {
|
||||
card.addRemembered(Pair.of(counterType, i));
|
||||
}
|
||||
}
|
||||
game.updateLastStateForCard(tgtCard);
|
||||
}
|
||||
tgtCard.subtractCounter(counterType, cntToRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user