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");
|
logger.debug("activate failed - target");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ArrayList<Cost> addedOptionalCosts = new ArrayList<Cost>();
|
|
||||||
for (Cost cost : optionalCosts) {
|
for (Cost cost : optionalCosts) {
|
||||||
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
if (cost instanceof ManaCost) {
|
||||||
if (cost instanceof ManaCost) {
|
cost.clearPaid();
|
||||||
|
if (game.getPlayer(this.controllerId).chooseUse(Outcome.Benefit, "Pay optional cost " + cost.getText() + "?", game)) {
|
||||||
manaCostsToPay.add((ManaCost) cost);
|
manaCostsToPay.add((ManaCost) cost);
|
||||||
addedOptionalCosts.add(cost);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import mage.ObjectColor;
|
||||||
import mage.abilities.Abilities;
|
import mage.abilities.Abilities;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
|
|
@ -78,51 +79,75 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
||||||
this.controllerId = spell.controllerId;
|
this.controllerId = spell.controllerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resolve(Game game) {
|
public boolean resolve(Game game) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
if (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY)) {
|
if (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY)) {
|
||||||
if (ability.getTargets().stillLegal(ability, game)) {
|
if (ability.getTargets().stillLegal(ability, game)) {
|
||||||
boolean replaced = resolveKicker(game);
|
updateOptionalCosts();
|
||||||
if (!replaced)
|
boolean replaced = resolveKicker(game);
|
||||||
result = ability.resolve(game);
|
if (!replaced)
|
||||||
else
|
result = ability.resolve(game);
|
||||||
result = true;
|
else
|
||||||
|
result = true;
|
||||||
|
|
||||||
if (!copiedSpell) {
|
if (!copiedSpell) {
|
||||||
for (Effect effect: ability.getEffects()) {
|
for (Effect effect : ability.getEffects()) {
|
||||||
if (effect instanceof PostResolveEffect) {
|
if (effect instanceof PostResolveEffect) {
|
||||||
((PostResolveEffect)effect).postResolve(card, ability, controllerId, game);
|
((PostResolveEffect) effect).postResolve(card, ability, controllerId, game);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//20091005 - 608.2b
|
//20091005 - 608.2b
|
||||||
game.informPlayers(getName() + " has been fizzled.");
|
game.informPlayers(getName() + " has been fizzled.");
|
||||||
counter(null, game);
|
counter(null, game);
|
||||||
return false;
|
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)) {
|
||||||
if (ability.getTargets().stillLegal(ability, game)) {
|
updateOptionalCosts();
|
||||||
if (card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId)) {
|
if (card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId)) {
|
||||||
return ability.resolve(game);
|
return ability.resolve(game);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//20091005 - 608.2b
|
//20091005 - 608.2b
|
||||||
counter(null, game);
|
counter(null, game);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
updateOptionalCosts();
|
||||||
resolveKicker(game);
|
|
||||||
result = card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId);
|
resolveKicker(game);
|
||||||
return result;
|
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) {
|
protected boolean resolveKicker(Game game) {
|
||||||
boolean replaced = false;
|
boolean replaced = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue