* Split cards - added cost modification effects support for fused spells (#227, #2242, #6603, #6549);

This commit is contained in:
Oleg Agafonov 2020-06-10 08:28:18 +04:00
parent 2096229af8
commit b38ac2f575
6 changed files with 149 additions and 45 deletions

View file

@ -124,24 +124,28 @@ public class Spell extends StackObjImpl implements Card {
}
public boolean activate(Game game, boolean noMana) {
setDoneActivatingManaAbilities(false); // Used for e.g. improvise
if (!spellAbilities.get(0).activate(game, noMana)) {
setDoneActivatingManaAbilities(false); // used for e.g. improvise
if (!ability.activate(game, noMana)) {
return false;
}
if (spellAbilities.size() > 1) {
// if there are more abilities (fused split spell) or first ability added new abilities (splice), activate the additional abilities
boolean ignoreAbility = true;
// spell can contains multiple abilities to activate (fused split, splice)
for (SpellAbility spellAbility : spellAbilities) {
if (ability.equals(spellAbility)) {
// activated first
continue;
}
boolean payNoMana = noMana;
for (SpellAbility spellAbility : spellAbilities) {
if (ignoreAbility) {
ignoreAbility = false;
} else {
// costs for spliced abilities were added to main spellAbility, so pay no mana for spliced abilities
payNoMana |= spellAbility.getSpellAbilityType() == SpellAbilityType.SPLICE;
if (!spellAbility.activate(game, payNoMana)) {
return false;
}
}
// costs for spliced abilities were added to main spellAbility, so pay no mana for spliced abilities
payNoMana |= spellAbility.getSpellAbilityType() == SpellAbilityType.SPLICE;
// costs for fused ability pay on first spell activate, so all parts must be without mana
// see https://github.com/magefree/mage/issues/6603
payNoMana |= ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED;
if (!spellAbility.activate(game, payNoMana)) {
return false;
}
}
setDoneActivatingManaAbilities(true); // can be activated again maybe during the resolution of the spell (e.g. Metallic Rebuke)

View file

@ -2699,11 +2699,7 @@ public abstract class PlayerImpl implements Player, Serializable {
(event.isWinnable() ? "(You called " + event.getChosenName() + ")" : null),
"Heads", "Tails", source, game
));
} else if (canChooseHeads) {
event.setResult(true);
} else {
event.setResult(false);
}
} else event.setResult(canChooseHeads);
game.informPlayers(getLogName() + " chose to keep " + CardUtil.booleanToFlipName(event.getResult()));
}
if (event.isWinnable()) {
@ -2935,7 +2931,7 @@ public abstract class PlayerImpl implements Player, Serializable {
*/
protected boolean canPlay(ActivatedAbility ability, ManaOptions available, MageObject sourceObject, Game game) {
if (!(ability instanceof ActivatedManaAbilityImpl)) {
ActivatedAbility copy = ability.copy(); // Copy is needed because cost reduction effects modify e.g. the mana to activate/cast the ability
ActivatedAbility copy = ability.copy(); // copy is needed because cost reduction effects modify e.g. the mana to activate/cast the ability
if (!copy.canActivate(playerId, game).canActivate()) {
return false;
}