mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Fixed optional costs. Now new implemenation of kicker should work.
This commit is contained in:
parent
a07c210ac0
commit
cc415c586d
2 changed files with 72 additions and 47 deletions
|
|
@ -164,12 +164,12 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
|||
logger.debug("activate failed - target");
|
||||
return false;
|
||||
}
|
||||
ArrayList<Cost> addedOptionalCosts = new ArrayList<Cost>();
|
||||
|
||||
for (Cost cost : optionalCosts) {
|
||||
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
||||
if (cost instanceof ManaCost) {
|
||||
cost.clearPaid();
|
||||
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
||||
manaCostsToPay.add((ManaCost) cost);
|
||||
addedOptionalCosts.add(cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import mage.ObjectColor;
|
|||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
@ -83,6 +84,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
boolean result = false;
|
||||
if (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY)) {
|
||||
if (ability.getTargets().stillLegal(ability, game)) {
|
||||
updateOptionalCosts();
|
||||
boolean replaced = resolveKicker(game);
|
||||
if (!replaced)
|
||||
result = ability.resolve(game);
|
||||
|
|
@ -90,9 +92,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
result = true;
|
||||
|
||||
if (!copiedSpell) {
|
||||
for (Effect effect: ability.getEffects()) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof PostResolveEffect) {
|
||||
((PostResolveEffect)effect).postResolve(card, ability, controllerId, game);
|
||||
((PostResolveEffect) effect).postResolve(card, ability, controllerId, game);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,9 +107,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
game.informPlayers(getName() + " has been fizzled.");
|
||||
counter(null, game);
|
||||
return false;
|
||||
}
|
||||
else if (card.getCardType().contains(CardType.ENCHANTMENT) && card.getSubtype().contains("Aura")) {
|
||||
} else if (card.getCardType().contains(CardType.ENCHANTMENT) && card.getSubtype().contains("Aura")) {
|
||||
if (ability.getTargets().stillLegal(ability, game)) {
|
||||
updateOptionalCosts();
|
||||
if (card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId)) {
|
||||
return ability.resolve(game);
|
||||
}
|
||||
|
|
@ -116,14 +118,37 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
//20091005 - 608.2b
|
||||
counter(null, game);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
updateOptionalCosts();
|
||||
|
||||
resolveKicker(game);
|
||||
result = card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* As we have ability in the stack, we need to update optional costs in original card.
|
||||
* This information will be used later by effects, e.g. to determine whether card was kicked or not.
|
||||
* E.g. Desolation Angel
|
||||
*/
|
||||
private void updateOptionalCosts() {
|
||||
Ability abilityOrig = card.getAbilities().get(ability.getId());
|
||||
for (Object object : ability.getOptionalCosts()) {
|
||||
Cost cost = (Cost) object;
|
||||
for (Cost costOrig : abilityOrig.getOptionalCosts()) {
|
||||
if (cost.getId().equals(costOrig.getId())) {
|
||||
if (cost.isPaid()) {
|
||||
costOrig.setPaid();
|
||||
} else {
|
||||
costOrig.clearPaid();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean resolveKicker(Game game) {
|
||||
boolean replaced = false;
|
||||
for (KickerAbility kicker: card.getAbilities().getKickerAbilities()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue