diff --git a/Mage/src/mage/abilities/keyword/FlashbackAbility.java b/Mage/src/mage/abilities/keyword/FlashbackAbility.java index b62f48e1be..8ba533ce86 100644 --- a/Mage/src/mage/abilities/keyword/FlashbackAbility.java +++ b/Mage/src/mage/abilities/keyword/FlashbackAbility.java @@ -88,6 +88,14 @@ public class FlashbackAbility extends SpellAbility { if (super.canActivate(playerId, game)) { Card card = game.getCard(getSourceId()); if (card != null) { + // Flashback can never cast a split card by Fuse, because Fuse only works from hand + if (card.isSplitCard()) { + if (((SplitCard)card).getLeftHalfCard().getName().equals(abilityName)) { + return ((SplitCard)card).getLeftHalfCard().getSpellAbility().canActivate(playerId, game); + } else if (((SplitCard)card).getRightHalfCard().getName().equals(abilityName)) { + return ((SplitCard)card).getRightHalfCard().getSpellAbility().canActivate(playerId, game); + } + } return card.getSpellAbility().canActivate(playerId, game); } } diff --git a/Mage/src/mage/cards/SplitCard.java b/Mage/src/mage/cards/SplitCard.java index af02f71838..bbff7f6e07 100644 --- a/Mage/src/mage/cards/SplitCard.java +++ b/Mage/src/mage/cards/SplitCard.java @@ -90,7 +90,7 @@ public abstract class SplitCard extends CardImpl { public Card getRightHalfCard () { return rightHalfCard; } - + @Override public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { switch(ability.getSpellAbilityType()) { @@ -102,7 +102,7 @@ public abstract class SplitCard extends CardImpl { return super.cast(game, fromZone, ability, controllerId); } } - + @Override public Abilities getAbilities(){ Abilities allAbilites = new AbilitiesImpl<>(); @@ -119,8 +119,6 @@ public abstract class SplitCard extends CardImpl { @Override public List getRules() { List rules = new ArrayList<>(); -// rules.addAll(leftHalfCard.getRules()); -// rules.addAll(rightHalfCard.getRules()); if (getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) { rules.add("--------------------------------------------------------------------------\nFuse (You may cast one or both halves of this card from your hand.)"); } @@ -191,25 +189,16 @@ class LeftHalfCard extends CardImpl { public int getCardNumber() { return splitCardParent.getCardNumber(); } - @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) { - return splitCardParent.moveToZone(toZone, sourceId, game, flag, null); - } @Override public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); } - - @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) { - return splitCardParent.moveToExile(exileId, name, sourceId, game, null); - } - + @Override public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); - } + } } /* @@ -249,21 +238,11 @@ class RightHalfCard extends CardImpl { return splitCardParent.getCardNumber(); } - @Override - public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) { - return splitCardParent.moveToZone(toZone, sourceId, game, flag, null); - } - @Override public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList appliedEffects) { return splitCardParent.moveToZone(toZone, sourceId, game, flag, appliedEffects); } - - @Override - public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) { - return splitCardParent.moveToExile(exileId, name, sourceId, game, null); - } - + @Override public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList appliedEffects) { return splitCardParent.moveToExile(exileId, name, sourceId, game, appliedEffects); diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 3ee92c04d7..f1f598202c 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -1080,19 +1080,20 @@ public abstract class PlayerImpl implements Player, Serializable { if (!ability.canActivate(this.playerId, game)) { return false; } - if (ability instanceof SpecialAction) { + + if (ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) { result = specialAction((SpecialAction)ability.copy(), game); } - else if (ability instanceof ManaAbility) { + else if (ability.getAbilityType().equals(AbilityType.MANA)) { result = playManaAbility((ManaAbility)ability.copy(), game); } - else if (ability instanceof FlashbackAbility){ - result = playAbility(ability.copy(), game); - } - else if (ability instanceof SpellAbility) { - result = cast((SpellAbility)ability, game, false); - } - else { + else if (ability.getAbilityType().equals(AbilityType.SPELL)) { + if (ability instanceof FlashbackAbility){ + result = playAbility(ability.copy(), game); + } else { + result = cast((SpellAbility)ability, game, false); + } + } else { result = playAbility(ability.copy(), game); } } @@ -1214,8 +1215,9 @@ public abstract class PlayerImpl implements Player, Serializable { Card card = game.getCard(ability.getSourceId()); if (card.isSplitCard() && ability instanceof FlashbackAbility) { FlashbackAbility flashbackAbility; - if (card.getCardType().contains(CardType.INSTANT)) { - flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT); + // Left Half + if (card.getCardType().contains(CardType.INSTANT)) { + flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.INSTANT); } else { flashbackAbility = new FlashbackAbility(((SplitCard) card).getLeftHalfCard().getManaCost(), TimingRule.SORCERY); @@ -1224,7 +1226,10 @@ public abstract class PlayerImpl implements Player, Serializable { flashbackAbility.setControllerId(card.getOwnerId()); flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_LEFT); flashbackAbility.setAbilityName(((SplitCard) card).getLeftHalfCard().getName()); - useable.put(flashbackAbility.getId(), flashbackAbility); + if (flashbackAbility.canActivate(playerId, game)) { + useable.put(flashbackAbility.getId(), flashbackAbility); + } + // Right Half if (card.getCardType().contains(CardType.INSTANT)) { flashbackAbility = new FlashbackAbility(((SplitCard) card).getRightHalfCard().getManaCost(), TimingRule.INSTANT); } @@ -1235,7 +1240,9 @@ public abstract class PlayerImpl implements Player, Serializable { flashbackAbility.setControllerId(card.getOwnerId()); flashbackAbility.setSpellAbilityType(SpellAbilityType.SPLIT_RIGHT); flashbackAbility.setAbilityName(((SplitCard) card).getRightHalfCard().getName()); - useable.put(flashbackAbility.getId(), flashbackAbility); + if (flashbackAbility.canActivate(playerId, game)) { + useable.put(flashbackAbility.getId(), flashbackAbility); + } } else { useable.put(ability.getId(), ability); @@ -2205,7 +2212,7 @@ public abstract class PlayerImpl implements Player, Serializable { ManaCostsImpl manaCosts = new ManaCostsImpl(); for(Cost cost:alternateSourceCostsAbility.getCosts()) { if (cost instanceof ManaCost) { - manaCosts.add(cost); + manaCosts.add((ManaCost)cost); } } @@ -2242,7 +2249,7 @@ public abstract class PlayerImpl implements Player, Serializable { ManaCostsImpl manaCosts = new ManaCostsImpl(); for(Cost cost:ability.getCosts()) { if (cost instanceof ManaCost) { - manaCosts.add(cost); + manaCosts.add((ManaCost)cost); } }