mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Fix #8485
This commit is contained in:
parent
7c67acf139
commit
639277402d
5 changed files with 40 additions and 43 deletions
|
@ -253,14 +253,6 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
setSourcePermanentTransformCount(game);
|
setSourcePermanentTransformCount(game);
|
||||||
|
|
||||||
/* 20130201 - 601.2b
|
|
||||||
* If the player wishes to splice any cards onto the spell (see rule 702.45), he
|
|
||||||
* or she reveals those cards in their hand.
|
|
||||||
*/
|
|
||||||
if (this.abilityType == AbilityType.SPELL) {
|
|
||||||
game.getContinuousEffects().applySpliceEffects(this, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if ability can be cast for no mana, clear the mana costs now, because additional mana costs must be paid.
|
// if ability can be cast for no mana, clear the mana costs now, because additional mana costs must be paid.
|
||||||
// For Flashback ability can be set X before, so the X costs have to be restored for the flashbacked ability
|
// For Flashback ability can be set X before, so the X costs have to be restored for the flashbacked ability
|
||||||
if (noMana) {
|
if (noMana) {
|
||||||
|
@ -277,12 +269,24 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fused or spliced spells contain multiple abilities (e.g. fused, left, right)
|
||||||
|
// optional costs and cost modification must be applied only to the first/main ability
|
||||||
|
boolean isMainPartAbility = !CardUtil.isFusedPartAbility(this, game);
|
||||||
|
|
||||||
|
/* 20220908 - 601.2b
|
||||||
|
* If the player wishes to splice any cards onto the spell (see rule 702.45), they
|
||||||
|
* reveal those cards in their hand.
|
||||||
|
*/
|
||||||
|
if (isMainPartAbility && this.abilityType == AbilityType.SPELL) {
|
||||||
|
game.getContinuousEffects().applySpliceEffects(this, game);
|
||||||
|
}
|
||||||
|
|
||||||
// 20130201 - 601.2b
|
// 20130201 - 601.2b
|
||||||
// If the spell has alternative or additional costs that will be paid as it's being cast such
|
// If the spell has alternative or additional costs that will be paid as it's being cast such
|
||||||
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
// as buyback, kicker, or convoke costs (see rules 117.8 and 117.9), the player announces his
|
||||||
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
||||||
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
||||||
if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) {
|
if (isMainPartAbility && !activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) {
|
||||||
if (getAbilityType() == AbilityType.SPELL
|
if (getAbilityType() == AbilityType.SPELL
|
||||||
&& ((SpellAbility) this).getSpellAbilityType() == SpellAbilityType.FACE_DOWN_CREATURE) {
|
&& ((SpellAbility) this).getSpellAbilityType() == SpellAbilityType.FACE_DOWN_CREATURE) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -385,12 +389,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fused spell contains 3 abilities (fused, left, right)
|
|
||||||
// fused cost added to fused ability, so no need cost modification for other parts
|
|
||||||
boolean needCostModification = !CardUtil.isFusedPartAbility(this, game);
|
|
||||||
|
|
||||||
//20101001 - 601.2e
|
//20101001 - 601.2e
|
||||||
if (needCostModification) {
|
if (isMainPartAbility) {
|
||||||
adjustCosts(game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
|
adjustCosts(game); // still needed for CostAdjuster objects (to handle some types of dynamic costs)
|
||||||
game.getContinuousEffects().costModification(this, game);
|
game.getContinuousEffects().costModification(this, game);
|
||||||
}
|
}
|
||||||
|
|
|
@ -765,15 +765,6 @@ public class ContinuousEffects implements Serializable {
|
||||||
public void applySpliceEffects(Ability abilityToModify, Game game) {
|
public void applySpliceEffects(Ability abilityToModify, Game game) {
|
||||||
// add effects from splice card to spell ability on activate/cast
|
// add effects from splice card to spell ability on activate/cast
|
||||||
|
|
||||||
// splice spell - spell can't be spliced again
|
|
||||||
if (CardUtil.isSpliceAbility(abilityToModify, game)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// fused spell - can be spliced only to main fused ability, not to parts
|
|
||||||
if (CardUtil.isFusedPartAbility(abilityToModify, game)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SpliceCardEffect> spliceEffects = getApplicableSpliceCardEffects(game, abilityToModify.getControllerId());
|
List<SpliceCardEffect> spliceEffects = getApplicableSpliceCardEffects(game, abilityToModify.getControllerId());
|
||||||
// get the applyable splice abilities
|
// get the applyable splice abilities
|
||||||
List<Ability> spliceAbilities = new ArrayList<>();
|
List<Ability> spliceAbilities = new ArrayList<>();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -9,6 +8,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.CostsImpl;
|
import mage.abilities.costs.CostsImpl;
|
||||||
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.SpliceCardEffectImpl;
|
import mage.abilities.effects.SpliceCardEffectImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -147,7 +147,12 @@ class SpliceOntoArcaneEffect extends SpliceCardEffectImpl {
|
||||||
splicedAbility.setSourceId(abilityToModify.getSourceId());
|
splicedAbility.setSourceId(abilityToModify.getSourceId());
|
||||||
spell.addSpellAbility(splicedAbility);
|
spell.addSpellAbility(splicedAbility);
|
||||||
for (Iterator it = ((SpliceOntoArcaneAbility) source).getSpliceCosts().iterator(); it.hasNext();) {
|
for (Iterator it = ((SpliceOntoArcaneAbility) source).getSpliceCosts().iterator(); it.hasNext();) {
|
||||||
spell.getSpellAbility().getCosts().add(((Cost) it.next()).copy());
|
Cost cost = (Cost) it.next();
|
||||||
|
if (cost instanceof ManaCost) {
|
||||||
|
spell.getSpellAbility().getManaCostsToPay().add((ManaCost) cost.copy());
|
||||||
|
} else {
|
||||||
|
spell.getSpellAbility().getCosts().add(cost.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.CostsImpl;
|
import mage.abilities.costs.CostsImpl;
|
||||||
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.SpliceCardEffectImpl;
|
import mage.abilities.effects.SpliceCardEffectImpl;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -150,7 +151,12 @@ class SpliceOntoInstantOrSorceryEffect extends SpliceCardEffectImpl {
|
||||||
splicedAbility.setSourceId(abilityToModify.getSourceId());
|
splicedAbility.setSourceId(abilityToModify.getSourceId());
|
||||||
spell.addSpellAbility(splicedAbility);
|
spell.addSpellAbility(splicedAbility);
|
||||||
for (Iterator it = ((SpliceOntoInstantOrSorceryAbility) source).getSpliceCosts().iterator(); it.hasNext(); ) {
|
for (Iterator it = ((SpliceOntoInstantOrSorceryAbility) source).getSpliceCosts().iterator(); it.hasNext(); ) {
|
||||||
spell.getSpellAbility().getCosts().add(((Cost) it.next()).copy());
|
Cost cost = (Cost) it.next();
|
||||||
|
if (cost instanceof ManaCost) {
|
||||||
|
spell.getSpellAbility().getManaCostsToPay().add((ManaCost) cost.copy());
|
||||||
|
} else {
|
||||||
|
spell.getSpellAbility().getCosts().add(cost.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -911,27 +911,22 @@ public final class CardUtil {
|
||||||
return Outcome.BoostCreature;
|
return Outcome.BoostCreature;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSpliceAbility(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SpellAbility) {
|
|
||||||
return ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLICE;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFusedPartAbility(Ability ability, Game game) {
|
public static boolean isFusedPartAbility(Ability ability, Game game) {
|
||||||
// TODO: does it work fine with copies of spells on stack?
|
// TODO: does it work fine with copies of spells on stack?
|
||||||
if (ability instanceof SpellAbility) {
|
if (!(ability instanceof SpellAbility)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLICE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Spell mainSpell = game.getSpell(ability.getId());
|
Spell mainSpell = game.getSpell(ability.getId());
|
||||||
if (mainSpell == null) {
|
if (mainSpell == null) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
SpellAbility mainSpellAbility = mainSpell.getSpellAbility();
|
SpellAbility mainSpellAbility = mainSpell.getSpellAbility();
|
||||||
return mainSpellAbility.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED
|
return mainSpellAbility.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED
|
||||||
&& !ability.equals(mainSpellAbility);
|
&& !ability.equals(mainSpellAbility);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Abilities<Ability> getAbilities(MageObject object, Game game) {
|
public static Abilities<Ability> getAbilities(MageObject object, Game game) {
|
||||||
if (object instanceof Card) {
|
if (object instanceof Card) {
|
||||||
|
|
Loading…
Reference in a new issue