* Double lands - fixed duplicated choices in choose dialog (#7197);

This commit is contained in:
Oleg Agafonov 2020-11-21 12:43:55 +04:00
parent c2c1e157e9
commit 24e2728fca
2 changed files with 33 additions and 8 deletions

View file

@ -196,6 +196,23 @@ public class ModalDoubleFacesCardsTest extends CardTestPlayerBase {
Assert.assertEquals("toughness", 5, card.getToughness().getValue());
}
@Test
public void test_DoubleLands_IgnoreDefaultAbilities() {
// https://github.com/magefree/mage/issues/7197
// Branchloft Pathway - land
// Boulderloft Pathway - land
addCard(Zone.HAND, playerA, "Branchloft Pathway");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
// possible bug: duplicated abilities list in main card
Assert.assertEquals("must have only 2 play abilities", 2, playerA.getPlayable(currentGame, true).size());
}
@Test
public void test_PlayFromNonHand_GraveyardByFlashback() {
removeAllCardsFromHand(playerA);

View file

@ -3,10 +3,7 @@ package mage.cards;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.*;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.*;
@ -171,12 +168,24 @@ public abstract class ModalDoubleFacesCard extends CardImpl {
return getInnerAbilities(game, false);
}
private boolean isIgnoreDefaultAbility(Ability ability) {
// ignore default play/spell ability from main card (only halfes are actual)
// default abilities added on card creation from card type and can't be skipped
// skip cast spell
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.MODAL) {
return true;
}
// skip play land
return ability instanceof PlayLandAbility;
}
private Abilities<Ability> getInnerAbilities(Game game, boolean showOnlyMainSide) {
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
// ignore default spell ability from main card (only halfes are actual)
for (Ability ability : super.getAbilities(game)) {
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.MODAL) {
if (isIgnoreDefaultAbility(ability)) {
continue;
}
allAbilites.add(ability);
@ -193,9 +202,8 @@ public abstract class ModalDoubleFacesCard extends CardImpl {
private Abilities<Ability> getInnerAbilities(boolean showOnlyMainSide) {
Abilities<Ability> allAbilites = new AbilitiesImpl<>();
// ignore default spell ability from main card (only halfes are actual)
for (Ability ability : super.getAbilities()) {
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.MODAL) {
if (isIgnoreDefaultAbility(ability)) {
continue;
}
allAbilites.add(ability);