mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
-setStrictChooseMode and assertAllCommandsUsed in every test
-store filter info in GameState -put instead of putIfAbsent
This commit is contained in:
parent
7c4d86f583
commit
1dc305f329
6 changed files with 42 additions and 32 deletions
|
@ -61,7 +61,7 @@ class ZilorthaStrengthIncarnateEffect extends ContinuousEffectImpl {
|
|||
// Change the rule
|
||||
FilterCreaturePermanent filter = StaticFilters.FILTER_PERMANENT_CREATURE.copy();
|
||||
filter.add(new ControllerIdPredicate(source.getControllerId()));
|
||||
game.addPowerInsteadOfToughnessForDamageLethalityFilter(source.getSourceId(), filter);
|
||||
game.getState().addPowerInsteadOfToughnessForDamageLethalityFilter(source.getSourceId(), filter);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
|
|||
*/
|
||||
public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent_combatDamageResolvesLethalityAsNormal() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Savai Sabertooth");
|
||||
|
@ -24,7 +19,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
attack(1, playerA, "Savai Sabertooth");
|
||||
block(1, playerB, "Drannith Healer", "Savai Sabertooth");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Savai Sabertooth", 1);
|
||||
assertGraveyardCount(playerB, "Drannith Healer", 1);
|
||||
|
@ -39,7 +37,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
attack(1, playerA, "Savai Sabertooth");
|
||||
block(1, playerB, "Drannith Healer", "Savai Sabertooth");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Savai Sabertooth", 0);
|
||||
assertGraveyardCount(playerB, "Drannith Healer", 1);
|
||||
|
@ -58,7 +59,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
attack(1, playerA, "Aegis Turtle");
|
||||
block(1, playerB, "Aegis Turtle", "Aegis Turtle");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Aegis Turtle", 0);
|
||||
assertGraveyardCount(playerB, "Aegis Turtle", 0);
|
||||
|
@ -72,7 +76,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Flame Spill", "Savai Sabertooth");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Savai Sabertooth", 1);
|
||||
assertGraveyardCount(playerB, "Flame Spill", 1);
|
||||
|
@ -89,7 +96,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Flame Spill", "Savai Sabertooth");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Savai Sabertooth", 1);
|
||||
assertGraveyardCount(playerB, "Flame Spill", 1);
|
||||
|
@ -114,7 +124,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Murder", "Zilortha, Strength Incarnate");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Zilortha, Strength Incarnate", 1);
|
||||
assertGraveyardCount(playerA, "Savai Sabertooth", 1);
|
||||
|
@ -132,7 +145,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
attack(1, playerA, "Maned Serval");
|
||||
block(1, playerB, "Maned Serval", "Maned Serval");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_COMBAT);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Maned Serval", 1);
|
||||
assertGraveyardCount(playerB, "Maned Serval", 1);
|
||||
|
@ -152,7 +168,10 @@ public class ZilorthaStrengthIncarnateTest extends CardTestPlayerBase {
|
|||
|
||||
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Zilortha, Strength Incarnate");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Maned Serval", 1);
|
||||
assertGraveyardCount(playerB, "Maned Serval", 0);
|
||||
|
|
|
@ -17,7 +17,6 @@ import mage.cards.decks.Deck;
|
|||
import mage.choices.Choice;
|
||||
import mage.constants.*;
|
||||
import mage.counters.Counters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.command.Commander;
|
||||
import mage.game.command.Emblem;
|
||||
|
@ -487,8 +486,4 @@ public interface Game extends MageItem, Serializable {
|
|||
return getCommandersIds(player, CommanderCardType.ANY);
|
||||
}
|
||||
|
||||
void addPowerInsteadOfToughnessForDamageLethalityFilter(UUID source, FilterCreaturePermanent filter);
|
||||
|
||||
List<FilterCreaturePermanent> getActivePowerInsteadOfToughnessForDamageLethalityFilters();
|
||||
|
||||
}
|
||||
|
|
|
@ -70,9 +70,6 @@ import java.io.IOException;
|
|||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public abstract class GameImpl implements Game, Serializable {
|
||||
|
||||
|
@ -149,8 +146,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
// temporary store for income concede commands, don't copy
|
||||
private final LinkedList<UUID> concedingPlayers = new LinkedList<>();
|
||||
|
||||
private Map<UUID, FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = new HashMap<>();
|
||||
|
||||
public GameImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, Mulligan mulligan, int startLife, int startingSize) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.range = range;
|
||||
|
@ -1897,7 +1892,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
List<Permanent> legendary = new ArrayList<>();
|
||||
List<Permanent> worldEnchantment = new ArrayList<>();
|
||||
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = getActivePowerInsteadOfToughnessForDamageLethalityFilters();
|
||||
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters();
|
||||
for (Permanent perm : getBattlefield().getAllActivePermanents()) {
|
||||
if (perm.isCreature()) {
|
||||
//20091005 - 704.5f
|
||||
|
@ -3320,18 +3315,4 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public Set<UUID> getCommandersIds(Player player, CommanderCardType commanderCardType) {
|
||||
return player.getCommandersIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPowerInsteadOfToughnessForDamageLethalityFilter(UUID source, FilterCreaturePermanent filter) {
|
||||
usePowerInsteadOfToughnessForDamageLethalityFilters.putIfAbsent(source, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterCreaturePermanent> getActivePowerInsteadOfToughnessForDamageLethalityFilters() {
|
||||
return usePowerInsteadOfToughnessForDamageLethalityFilters.isEmpty() ? emptyList() : getBattlefield().getAllActivePermanents().stream()
|
||||
.map(Card::getId)
|
||||
.filter(usePowerInsteadOfToughnessForDamageLethalityFilters::containsKey)
|
||||
.map(usePowerInsteadOfToughnessForDamageLethalityFilters::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import mage.cards.Card;
|
|||
import mage.cards.SplitCard;
|
||||
import mage.constants.Zone;
|
||||
import mage.designations.Designation;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.Command;
|
||||
|
@ -38,6 +39,8 @@ import java.io.Serializable;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* <p>
|
||||
|
@ -96,6 +99,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
private Map<UUID, Integer> zoneChangeCounter = new HashMap<>();
|
||||
private Map<UUID, Card> copiedCards = new HashMap<>();
|
||||
private int permanentOrderNumber;
|
||||
private Map<UUID, FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = new HashMap<>();
|
||||
|
||||
private int applyEffectsCounter; // Upcounting number of each applyEffects execution
|
||||
|
||||
|
@ -1209,4 +1213,15 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
return applyEffectsCounter;
|
||||
}
|
||||
|
||||
public void addPowerInsteadOfToughnessForDamageLethalityFilter(UUID source, FilterCreaturePermanent filter) {
|
||||
usePowerInsteadOfToughnessForDamageLethalityFilters.put(source, filter);
|
||||
}
|
||||
|
||||
public List<FilterCreaturePermanent> getActivePowerInsteadOfToughnessForDamageLethalityFilters() {
|
||||
return usePowerInsteadOfToughnessForDamageLethalityFilters.isEmpty() ? emptyList() : getBattlefield().getAllActivePermanents().stream()
|
||||
.map(Card::getId)
|
||||
.filter(usePowerInsteadOfToughnessForDamageLethalityFilters::containsKey)
|
||||
.map(usePowerInsteadOfToughnessForDamageLethalityFilters::get)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -934,7 +934,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
}
|
||||
|
||||
public static int getLethalDamage(Permanent damagedPermanent, Game game) {
|
||||
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = game.getActivePowerInsteadOfToughnessForDamageLethalityFilters();
|
||||
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = game.getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters();
|
||||
/*
|
||||
* for handling Zilortha, Strength Incarnate:
|
||||
* 2020-04-17
|
||||
|
|
Loading…
Reference in a new issue