Commit 25d1d2bb authored by Peter Patel-Schneider's avatar Peter Patel-Schneider

Merge branch 'bugfix' into highlighting

Bring bug fix into highlight code
parents 11f9520c 8f2123f1
......@@ -4,6 +4,8 @@ import forge.game.Game;
import forge.game.ability.AbilityUtils;
import forge.game.ability.SpellAbilityEffect;
import forge.game.card.Card;
import forge.game.card.CardCollectionView;
import forge.game.card.CardLists;
import forge.game.card.CounterType;
import forge.game.player.Player;
import forge.game.player.PlayerController;
......@@ -69,11 +71,14 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
final Card card = sa.getHostCard();
final Game game = card.getGame();
final Player player = sa.getActivatingPlayer();
PlayerController pc = player.getController();
final String type = sa.getParam("CounterType");
final String num = sa.getParam("CounterNum");
int cntToRemove = 0;
if (!num.equals("All") && !num.equals("Remembered")) {
if (!num.equals("All") && !num.equals("Any") && !num.equals("Remembered")) {
cntToRemove = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
}
......@@ -96,6 +101,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
}
boolean rememberRemoved = sa.hasParam("RememberRemoved");
boolean rememberAmount = sa.hasParam("RememberAmount");
for (final Player tgtPlayer : getTargetPlayers(sa)) {
// Removing energy
......@@ -107,7 +113,23 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
}
}
for (final Card tgtCard : getTargetCards(sa)) {
CardCollectionView srcCards = null;
if (sa.hasParam("ValidSource")) {
srcCards = game.getCardsIn(ZoneType.Battlefield);
srcCards = CardLists.getValidCards(srcCards, sa.getParam("ValidSource"), player, card, sa);
if (num.equals("Any")) {
StringBuilder sb = new StringBuilder();
sb.append("Choose cards to take ").append(counterType.getName()).append(" counters from");
srcCards = player.getController().chooseCardsForEffect(srcCards, sa, sb.toString(), 0, srcCards.size(), true);
}
} else {
srcCards = getTargetCards(sa);
}
int totalRemoved = 0;
for (final Card tgtCard : srcCards) {
Card gameCard = game.getCardState(tgtCard, null);
// gameCard is LKI in that case, the card is not in game anymore
// or the timestamp did change
......@@ -123,14 +145,12 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
}
game.updateLastStateForCard(gameCard);
continue;
} else if (num.equals("All")) {
} else if (num.equals("All") || num.equals("Any")) {
cntToRemove = gameCard.getCounters(counterType);
} else if (sa.getParam("CounterNum").equals("Remembered")) {
} else if (num.equals("Remembered")) {
cntToRemove = gameCard.getCountersAddedBy(card, counterType);
}
PlayerController pc = sa.getActivatingPlayer().getController();
if (type.equals("Any")) {
while (cntToRemove > 0 && gameCard.hasCounters()) {
final Map<CounterType, Integer> tgtCounters = gameCard.getCounters();
......@@ -162,7 +182,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
cntToRemove = Math.min(cntToRemove, gameCard.getCounters(counterType));
if (zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Exile)) {
if (sa.hasParam("UpTo")) {
if (sa.hasParam("UpTo") || num.equals("Any")) {
Map<String, Object> params = Maps.newHashMap();
params.put("Target", gameCard);
params.put("CounterType", type);
......@@ -179,10 +199,17 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
}
}
game.updateLastStateForCard(gameCard);
totalRemoved += cntToRemove;
}
}
}
}
if (totalRemoved > 0 && rememberAmount) {
// TODO use SpellAbility Remember later
card.addRemembered(Integer.valueOf(totalRemoved));
}
}
}
Name:Galloping Lizrog
ManaCost:3 G U
Types:Creature Frog Lizard
PT:3/3
K:Trample
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | OptionalDecider$ You | Execute$ TrigRemoveCounters | TriggerDescription$ When CARDNAME enters the battlefield, you may remove any number of +1/+1 counters from among creatures you control. If you do, put twice that many +1/+1 counters on CARDNAME.
SVar:TrigRemoveCounters:DB$ RemoveCounter | ValidSource$ Creature.YouCtrl+counters_GE1_P1P1 | CounterType$ P1P1 | CounterNum$ Any | SubAbility$ DBPutCounters | RememberAmount$ True | StackDescription$ You may remove any number of +1/+1 counters from among creatures you control.
SVar:DBPutCounters:DB$PutCounter | Defined$ TriggeredCardLKICopy | CounterType$ P1P1 | CounterNum$ X | References$ X | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Count$RememberedNumber/Twice
Oracle:Trample\nWhen Galloping Lizrog enters the battlefield, you may remove any number of +1/+1 counters from among creatures you control. If you do, put twice that many +1/+1 counters on Galloping Lizrog.
......@@ -46,7 +46,9 @@ public class InputSelectEntitiesFromList<T extends GameEntity> extends InputSele
final PlayerZoneUpdates zonesToUpdate = new PlayerZoneUpdates();
for (final GameEntity c : validChoices) {
final Zone cz = (c instanceof Card) ? ((Card) c).getZone() : null ;
zonesToUpdate.add(new PlayerZoneUpdate(cz.getPlayer().getView(),cz.getZoneType()));
if ( cz != null ) {
zonesToUpdate.add(new PlayerZoneUpdate(cz.getPlayer().getView(),cz.getZoneType()));
}
}
FThreads.invokeInEdtNowOrLater(new Runnable() {
@Override public void run() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment