mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Can't be activated effects - fixed that some restricted effects show abilities as playable (example: Sharkey, Tyrant of the Shire and Karakas, fixed #10642)
This commit is contained in:
parent
21ad11dbdc
commit
393dbc4047
9 changed files with 136 additions and 44 deletions
|
|
@ -4,14 +4,23 @@ import mage.abilities.Abilities;
|
|||
import mage.abilities.Ability;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentImpl;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.SimpleCardView;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
|
|
@ -89,4 +98,74 @@ public class AbilityPickerTest extends CardTestPlayerBase {
|
|||
PermanentImpl permanent = new PermanentCard(info.createCard(), playerA.getId(), currentGame);
|
||||
return permanent.getAbilities(currentGame);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_RealGame_ActivatedAbilities_All() {
|
||||
// possible bug: wrongly enabled ability, see #10642
|
||||
|
||||
// Activated abilities of lands your opponents control can't be activated unless they're mana abilities.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Sharkey, Tyrant of the Shire", 1);
|
||||
// {T}: Add {W}.
|
||||
// {T}: Return target legendary creature to its owner's hand.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Karakas", 1);
|
||||
|
||||
// have all abilities
|
||||
runCode("all available", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
List<String> needList = new ArrayList<>(Arrays.asList(
|
||||
"{T}: Add {W}.",
|
||||
"{T}: Return target legendary creature to its owner's hand."
|
||||
));
|
||||
Collections.sort(needList);
|
||||
assertPlayableAbilities(needList);
|
||||
});
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_RealGame_ActivatedAbilities_Restricted() {
|
||||
// possible bug: wrongly enabled ability, see #10642
|
||||
|
||||
// Activated abilities of lands your opponents control can't be activated unless they're mana abilities.
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Sharkey, Tyrant of the Shire", 1);
|
||||
// {T}: Add {W}.
|
||||
// {T}: Return target legendary creature to its owner's hand.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Karakas", 1);
|
||||
|
||||
// have mana abilities only
|
||||
runCode("non-mana ability disabled", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
List<String> needList = new ArrayList<>(Collections.singletonList(
|
||||
"{T}: Add {W}."
|
||||
));
|
||||
Collections.sort(needList);
|
||||
assertPlayableAbilities(needList);
|
||||
});
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
}
|
||||
|
||||
private void assertPlayableAbilities(List<String> need) {
|
||||
// server side
|
||||
List<String> realList = playerA.getPlayable(currentGame, true).stream()
|
||||
.map(Ability::getRule)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
Assert.assertEquals("wrong server side playable list", need.toString(), realList.toString());
|
||||
|
||||
// client side as game data
|
||||
GameView gameView = getGameView(playerA);
|
||||
realList.clear();
|
||||
gameView.getCanPlayObjects().getObjects().forEach((objectId, stats) -> {
|
||||
stats.getPlayableAbilityIds().forEach(abilityId -> {
|
||||
Ability ability = currentGame.getAbility(abilityId, objectId).orElse(null);
|
||||
realList.add(ability == null ? "null" : ability.getRule());
|
||||
});
|
||||
});
|
||||
Collections.sort(realList);
|
||||
Assert.assertEquals("wrong client side playable list", need.toString(), realList.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue