diff --git a/Mage/src/mage/abilities/ActivatedAbilityImpl.java b/Mage/src/mage/abilities/ActivatedAbilityImpl.java index fd270faf351..1f0ca1412e7 100644 --- a/Mage/src/mage/abilities/ActivatedAbilityImpl.java +++ b/Mage/src/mage/abilities/ActivatedAbilityImpl.java @@ -243,31 +243,53 @@ public abstract class ActivatedAbilityImpl> ex } else { sb.append("unknown"); } - if (object instanceof Spell && ((Spell) object).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) { - Spell spell = (Spell) object; - int i = 0; - for (SpellAbility spellAbility : spell.getSpellAbilities()) { - i++; - String half; - if (i == 1) { - half = " left"; - } else { - half = " right"; + if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) { + if (((Spell) object).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) { + Spell spell = (Spell) object; + int i = 0; + for (SpellAbility spellAbility : spell.getSpellAbilities()) { + i++; + String half; + if (i == 1) { + half = " left"; + } else { + half = " right"; + } + if (spellAbility.getTargets().size() > 0) { + sb.append(half).append(" half targeting "); + for (Target target: spellAbility.getTargets()) { + sb.append(target.getTargetedName(game)); + } + } } - if (spellAbility.getTargets().size() > 0) { - sb.append(half).append(" half targeting "); - for (Target target: spellAbility.getTargets()) { - sb.append(target.getTargetedName(game)); + } else { + Spell spell = (Spell) object; + int i = 0; + for (SpellAbility spellAbility : spell.getSpellAbilities()) { + i++; + if ( i > 1) { + sb.append(" splicing "); + if (spellAbility.name.length() > 5 && spellAbility.name.startsWith("Cast ")) { + sb.append(spellAbility.name.substring(5)); + } else { + sb.append(spellAbility.name); + } + } + if (spellAbility.getTargets().size() > 0) { + for (Target target: spellAbility.getTargets()) { + sb.append(" targeting "); + sb.append(target.getTargetedName(game)); + } } } } } else if (object instanceof Spell && ((Spell) object).getSpellAbility().getModes().size() > 1) { - Modes modes = ((Spell) object).getSpellAbility().getModes(); + Modes spellModes = ((Spell) object).getSpellAbility().getModes(); int item = 0; - for (Mode mode : modes.values()) { + for (Mode mode : spellModes.values()) { item++; - if (modes.getSelectedModes().contains(mode.getId())) { - modes.setMode(mode); + if (spellModes.getSelectedModes().contains(mode.getId())) { + spellModes.setMode(mode); sb.append(" (mode ").append(item).append(")"); if (getTargets().size() > 0) { sb.append(" targeting "); diff --git a/Mage/src/mage/abilities/effects/ContinuousEffects.java b/Mage/src/mage/abilities/effects/ContinuousEffects.java index 6919f6ca31b..0cc5102bfcd 100644 --- a/Mage/src/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/mage/abilities/effects/ContinuousEffects.java @@ -38,11 +38,20 @@ import mage.MageObject; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.StaticAbility; +import mage.abilities.keyword.SpliceOntoArcaneAbility; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.Outcome; import mage.constants.SpellAbilityType; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.target.common.TargetCardInHand; /** * @@ -434,15 +443,52 @@ public class ContinuousEffects implements Serializable { return; } List spliceEffects = getApplicableSpliceCardEffects(game); - - for ( SpliceCardEffect effect : spliceEffects) { + // get the applyable splice abilities + List spliceAbilities = new ArrayList(); + for (SpliceCardEffect effect : spliceEffects) { HashSet abilities = spliceCardEffects.getAbility(effect.getId()); for (Ability ability : abilities) { - if ( effect.applies(abilityToModify, ability, game) ) { - effect.apply(game, ability, abilityToModify); + if (effect.applies(abilityToModify, ability, game) ) { + spliceAbilities.add((SpliceOntoArcaneAbility) ability); } } } + // check if player wants to use splice + + if (spliceAbilities.size() > 0) { + Player controller = game.getPlayer(abilityToModify.getControllerId()); + if (controller.chooseUse(Outcome.Benefit, "Splice a card?", game)) { + Cards cardsToReveal = new CardsImpl(); + do { + FilterCard filter = new FilterCard("a card to splice"); + ArrayList> idPredicates = new ArrayList>(); + for (SpliceOntoArcaneAbility ability : spliceAbilities) { + idPredicates.add(new CardIdPredicate((ability.getSourceId()))); + } + filter.add(Predicates.or(idPredicates)); + TargetCardInHand target = new TargetCardInHand(filter); + target.setRequired(true); + controller.chooseTarget(Outcome.Benefit, target, abilityToModify, game); + UUID cardId = target.getFirstTarget(); + if (cardId != null) { + SpliceOntoArcaneAbility selectedAbility = null; + for(SpliceOntoArcaneAbility ability :spliceAbilities) { + if (ability.getSourceId().equals(cardId)) { + selectedAbility = ability; + break; + } + } + if (selectedAbility != null) { + SpliceCardEffect spliceEffect = (SpliceCardEffect) selectedAbility.getEffects().get(0); + spliceEffect.apply(game, selectedAbility, abilityToModify); + cardsToReveal.add(game.getCard(cardId)); + spliceAbilities.remove(selectedAbility); + } + } + } while (!spliceAbilities.isEmpty() && controller.chooseUse(Outcome.Benefit, "Splice another card?", game)); + controller.revealCards("Spliced cards", cardsToReveal, game); + } + } } diff --git a/Mage/src/mage/abilities/keyword/SpliceOntoArcaneAbility.java b/Mage/src/mage/abilities/keyword/SpliceOntoArcaneAbility.java index e58bf4bc0a0..299aaf3cc7f 100644 --- a/Mage/src/mage/abilities/keyword/SpliceOntoArcaneAbility.java +++ b/Mage/src/mage/abilities/keyword/SpliceOntoArcaneAbility.java @@ -106,6 +106,7 @@ public class SpliceOntoArcaneAbility extends SimpleStaticAbility { private static final String KEYWORD_TEXT = "Splice onto Arcane"; private Costs spliceCosts = new CostsImpl(); + private boolean nonManaCosts = false; public SpliceOntoArcaneAbility(String manaString) { super(Zone.HAND, new SpliceOntoArcaneEffect()); @@ -115,11 +116,13 @@ public class SpliceOntoArcaneAbility extends SimpleStaticAbility { public SpliceOntoArcaneAbility(Cost cost) { super(Zone.HAND, new SpliceOntoArcaneEffect()); spliceCosts.add(cost); + nonManaCosts = true; } public SpliceOntoArcaneAbility(final SpliceOntoArcaneAbility ability) { super(ability); this.spliceCosts = ability.spliceCosts.copy(); + this.nonManaCosts = ability.nonManaCosts; } @Override @@ -134,9 +137,9 @@ public class SpliceOntoArcaneAbility extends SimpleStaticAbility { @Override public String getRule() { StringBuilder sb = new StringBuilder(); - sb.append(KEYWORD_TEXT).append(" "); - sb.append(spliceCosts.getText()); - sb.append(" (As you cast an Arcane spell, you may reveal this card from your hand and pay its splice cost. If you do, add this card's effects to that spell.)"); + sb.append(KEYWORD_TEXT).append(nonManaCosts?"-":" "); + sb.append(spliceCosts.getText()).append(nonManaCosts?". ":" "); + sb.append("(As you cast an Arcane spell, you may reveal this card from your hand and pay its splice cost. If you do, add this card's effects to that spell.)"); return sb.toString(); } } @@ -165,24 +168,19 @@ class SpliceOntoArcaneEffect extends SpliceCardEffectImpl