mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
refactor: improved search in stack
This commit is contained in:
parent
26adccdfd5
commit
384ce67cc3
20 changed files with 101 additions and 119 deletions
|
|
@ -55,7 +55,7 @@ public class DisguiseTest extends CardTestPlayerBase {
|
|||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Dog Walker using Disguise");
|
||||
runCode("face up on stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
Assert.assertEquals("stack, server - can't find spell", 1, currentGame.getStack().size());
|
||||
SpellAbility spellAbility = (SpellAbility) currentGame.getStack().getFirst().getStackAbility();
|
||||
SpellAbility spellAbility = (SpellAbility) currentGame.getStack().getFirstOrNull().getStackAbility();
|
||||
Assert.assertEquals("stack, server - can't find spell", "Cast Dog Walker using Disguise", spellAbility.getName());
|
||||
CardView spellView = getGameView(playerA).getStack().values().stream().findFirst().orElse(null);
|
||||
Assert.assertNotNull("stack, client: can't find spell", spellView);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class DisturbTest extends CardTestPlayerBase {
|
|||
checkStackObject("on stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter using Disturb", 1);
|
||||
runCode("check stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
// Stack must contain another card side, so spell/card characteristics must be diff from main side (only mana value is same)
|
||||
Spell spell = (Spell) game.getStack().getFirst();
|
||||
Spell spell = (Spell) game.getStack().getFirstOrNull();
|
||||
Assert.assertEquals("Hook-Haunt Drifter", spell.getName());
|
||||
Assert.assertEquals(1, spell.getCardType(game).size());
|
||||
Assert.assertEquals(CardType.CREATURE, spell.getCardType(game).get(0));
|
||||
|
|
@ -91,7 +91,7 @@ public class DisturbTest extends CardTestPlayerBase {
|
|||
checkStackObject("on stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Waildrifter using Disturb", 1);
|
||||
runCode("check stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
// Stack must contain another card side, so spell/card characteristics must be diff from main side (only mana value is same)
|
||||
Spell spell = (Spell) game.getStack().getFirst();
|
||||
Spell spell = (Spell) game.getStack().getFirstOrNull();
|
||||
Assert.assertEquals("Waildrifter", spell.getName());
|
||||
Assert.assertEquals(1, spell.getCardType(game).size());
|
||||
Assert.assertEquals(CardType.CREATURE, spell.getCardType(game).get(0));
|
||||
|
|
@ -187,7 +187,7 @@ public class DisturbTest extends CardTestPlayerBase {
|
|||
// cast with disturb
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Hook-Haunt Drifter using Disturb");
|
||||
runCode("check stack", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
Spell spell = (Spell) game.getStack().getFirst();
|
||||
Spell spell = (Spell) game.getStack().getFirstOrNull();
|
||||
Assert.assertEquals("mana value must be from main side", 2, spell.getManaValue());
|
||||
Assert.assertEquals("mana cost to pay must be modified", "{U}", spell.getSpellAbility().getManaCostsToPay().getText());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -334,11 +334,8 @@ public class TestPlayer implements Player {
|
|||
return true;
|
||||
} else if (groups[2].startsWith("spellOnTopOfStack=")) {
|
||||
String spellOnTopOFStack = groups[2].substring(18);
|
||||
if (!game.getStack().isEmpty()) {
|
||||
StackObject stackObject = game.getStack().getFirst();
|
||||
return stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack);
|
||||
}
|
||||
return false;
|
||||
StackObject stackObject = game.getStack().getFirstOrNull();
|
||||
return stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack);
|
||||
} else if (groups[2].startsWith("manaInPool=")) {
|
||||
String manaInPool = groups[2].substring(11);
|
||||
int amountOfMana = Integer.parseInt(manaInPool);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue