* Kicker and Multikicker - Fixed a bug that the kicked status was not reset if needed (e.g. a Quag Vampires returning from exile of Fiend Hunter had again +1/+1 counters if he was kicked before).

This commit is contained in:
LevelX2 2013-07-22 08:34:01 +02:00
parent 1ab6b72e8a
commit 8259814afd
5 changed files with 42 additions and 14 deletions

View file

@ -106,7 +106,7 @@ class RumblingAftershocksTriggeredAbility extends TriggeredAbilityImpl<RumblingA
int damageAmount = 0;
for (Ability ability: (Abilities<Ability>) spell.getAbilities()) {
if (ability instanceof KickerAbility) {
damageAmount += ((KickerAbility) ability).getKickedCounter();
damageAmount += ((KickerAbility) ability).getKickedCounter(game);
}
}
if (damageAmount > 0) {

View file

@ -64,7 +64,7 @@ public class BoldDefense extends CardImpl<BoldDefense> {
ContinuousEffect effect = new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent(), false);
this.getSpellAbility().addEffect(new ConditionalContinousEffect(effect, KickedCondition.getInstance(), staticText));
this.getSpellAbility().addEffect(new ConditionalContinousEffect(effect, KickedCondition.getInstance(), staticText, true));
}
public BoldDefense(final BoldDefense card) {

View file

@ -59,7 +59,7 @@ public class KickedCondition implements Condition {
if (card != null) {
for (Ability ability: card.getAbilities()) {
if (ability instanceof KickerAbility) {
if(((KickerAbility) ability).isKicked()) {
if(((KickerAbility) ability).isKicked(game)) {
return true;
}
}

View file

@ -49,7 +49,7 @@ public class MultikickerCount implements DynamicValue {
if (card != null) {
for (Ability ability: card.getAbilities()) {
if (ability instanceof KickerAbility) {
count += ((KickerAbility) ability).getKickedCounter();
count += ((KickerAbility) ability).getKickedCounter(game);
}
}
}

View file

@ -42,6 +42,8 @@ import mage.abilities.costs.OptionalAdditionalSourceCosts;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.VariableManaCost;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
@ -90,6 +92,8 @@ public class KickerAbility extends StaticAbility<KickerAbility> implements Optio
protected String reminderText;
protected List<OptionalAdditionalCost> kickerCosts = new LinkedList<OptionalAdditionalCost>();
private int xManaValue = 0;
// needed to reset kicked status, if card changes zone after casting it
private int zoneChangeCounter = 0;
public KickerAbility(String manaString) {
this(KICKER_KEYWORD, KICKER_REMINDER_MANA);
@ -115,6 +119,7 @@ public class KickerAbility extends StaticAbility<KickerAbility> implements Optio
this.keywordText = ability.keywordText;
this.reminderText = ability.reminderText;
this.xManaValue = ability.xManaValue;
this.zoneChangeCounter = ability.zoneChangeCounter;
}
@ -139,25 +144,35 @@ public class KickerAbility extends StaticAbility<KickerAbility> implements Optio
for (OptionalAdditionalCost cost: kickerCosts) {
cost.reset();
}
zoneChangeCounter = 0;
}
public int getXManaValue() {
return xManaValue;
}
public int getKickedCounter() {
int counter = 0;
for (OptionalAdditionalCost cost: kickerCosts) {
counter += cost.getActivateCount();
public int getKickedCounter(Game game) {
if (isKicked(game)) {
int counter = 0;
for (OptionalAdditionalCost cost: kickerCosts) {
counter += cost.getActivateCount();
}
return counter;
}
return counter;
return 0;
}
public boolean isKicked() {
for (OptionalAdditionalCost cost: kickerCosts) {
if(cost.isActivated()) {
return true;
public boolean isKicked(Game game) {
Card card = game.getCard(sourceId);
// kicked status counts only if card not changed zone since it was kicked
if (card != null && card.getZoneChangeCounter() <= zoneChangeCounter +1) {
for (OptionalAdditionalCost cost: kickerCosts) {
if(cost.isActivated()) {
return true;
}
}
} else {
this.resetKicker();
}
return false;
}
@ -166,6 +181,19 @@ public class KickerAbility extends StaticAbility<KickerAbility> implements Optio
return kickerCosts;
}
private void activateKicker(OptionalAdditionalCost kickerCost, Game game) {
kickerCost.activate();
// remember zone change counter
if (zoneChangeCounter == 0) {
Card card = game.getCard(sourceId);
if (card != null) {
zoneChangeCounter = card.getZoneChangeCounter();
} else {
throw new IllegalArgumentException("Kicker source card not found");
}
}
}
@Override
public void addOptionalAdditionalCosts(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
@ -182,7 +210,7 @@ public class KickerAbility extends StaticAbility<KickerAbility> implements Optio
}
if (kickerCost.canPay(sourceId, controllerId, game) &&
player.chooseUse(Outcome.Benefit, new StringBuilder("Pay ").append(times).append(kickerCost.getText(false)).append(" ?").toString(), game)) {
kickerCost.activate();
this.activateKicker(kickerCost, game);
for (Iterator it = ((Costs) kickerCost).iterator(); it.hasNext();) {
Cost cost = (Cost) it.next();
if (cost instanceof ManaCostsImpl) {