mirror of
https://github.com/correl/mage.git
synced 2024-12-29 11:09:17 +00:00
Test framework: fixed missing range info for added cards (some ETB effects were broken on "put to battlefield" command usage);
This commit is contained in:
parent
654c0be1ac
commit
4e79c83784
5 changed files with 27 additions and 2 deletions
|
@ -3023,6 +3023,11 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.untap(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRange(Game game) {
|
||||
computerPlayer.updateRange(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return computerPlayer.getId();
|
||||
|
|
|
@ -298,6 +298,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
(maxTurn > this.stopOnTurn) || (maxTurn == this.stopOnTurn && maxPhase > this.stopAtStep.getIndex()));
|
||||
|
||||
if (!currentGame.isPaused()) {
|
||||
// workaround to fill range info (cause real range fills after game start, but some cheated cards needs range on ETB)
|
||||
for (Player player : currentGame.getPlayers().values()) {
|
||||
player.updateRange(currentGame);
|
||||
}
|
||||
// add cards to game
|
||||
for (Player player : currentGame.getPlayers().values()) {
|
||||
TestPlayer testPlayer = (TestPlayer) player;
|
||||
currentGame.cheat(testPlayer.getId(), getCommands(testPlayer));
|
||||
|
|
|
@ -1030,6 +1030,11 @@ public class PlayerStub implements Player {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRange(Game game) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaOptions getManaAvailable(Game game) {
|
||||
return null;
|
||||
|
|
|
@ -707,6 +707,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void untap(Game game);
|
||||
|
||||
void updateRange(Game game);
|
||||
|
||||
ManaOptions getManaAvailable(Game game);
|
||||
|
||||
void addAvailableTriggeredMana(List<Mana> netManaAvailable);
|
||||
|
|
|
@ -483,7 +483,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void beginTurn(Game game) {
|
||||
this.landsPlayed = 0;
|
||||
updateRangeOfInfluence(game);
|
||||
updateRange(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -491,7 +491,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
return range;
|
||||
}
|
||||
|
||||
protected void updateRangeOfInfluence(Game game) {
|
||||
@Override
|
||||
public void updateRange(Game game) {
|
||||
// 20100423 - 801.2c
|
||||
// 801.2c The particular players within each player’s range of influence are determined as each turn begins.
|
||||
inRange.clear();
|
||||
|
@ -523,6 +524,13 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
@Override
|
||||
public Set<UUID> getInRange() {
|
||||
if (inRange.isEmpty()) {
|
||||
// runtime check: inRange filled on beginTurn, but unit tests adds cards by cheat engine before game starting,
|
||||
// so inRange will be empty and some ETB effects can be broken (example: Spark Double puts direct to battlefield).
|
||||
// Cheat engine already have a workaround, so that error must not be visible in normal situation.
|
||||
throw new IllegalStateException("Wrong code usage (game is not started, but you call getInRange in some effects).");
|
||||
}
|
||||
|
||||
return inRange;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue