Merge pull request #8503 from weirddan455/battlemage

Fixed kicker costs not getting reset correctly (fixes #8495)
This commit is contained in:
Oleg Agafonov 2021-12-04 20:07:49 +04:00 committed by GitHub
commit 86023e4164
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -1,5 +1,6 @@
package mage.abilities.condition.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.keyword.KickerAbility;
@ -21,9 +22,9 @@ public class KickedCostCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
for (Ability ability: card.getAbilities()) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject instanceof Card) {
for (Ability ability : ((Card) sourceObject).getAbilities(game)) {
if (ability instanceof KickerAbility) {
return ((KickerAbility) ability).isKicked(game, source, kickerCostText);
}

View file

@ -115,18 +115,11 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
});
}
public void resetKicker(Game game, Ability source) {
private void resetKicker() {
for (OptionalAdditionalCost cost : kickerCosts) {
cost.reset();
}
String key = getActivationKey(source, "", game);
for (Iterator<String> iterator = activations.keySet().iterator(); iterator.hasNext(); ) {
String activationKey = iterator.next();
if (activationKey.startsWith(key)
&& activations.get(activationKey) > 0) {
activations.put(key, 0);
}
}
activations.clear();
}
private int getKickedCounterStrict(Game game, Ability source, String needKickerCost) {
@ -241,7 +234,7 @@ public class KickerAbility extends StaticAbility implements OptionalAdditionalSo
if (ability instanceof SpellAbility) {
Player player = game.getPlayer(ability.getControllerId());
if (player != null) {
this.resetKicker(game, ability);
this.resetKicker();
for (OptionalAdditionalCost kickerCost : kickerCosts) {
boolean again = true;
while (player.canRespond() && again) {