Moved skipping initial shuffling to game options.

This commit is contained in:
magenoxx 2012-04-07 11:52:31 +04:00
parent 53b2893a81
commit f0be9c35d7
5 changed files with 25 additions and 10 deletions

View file

@ -63,8 +63,8 @@ public class TwoPlayerDuel extends GameImpl<TwoPlayerDuel> {
}
@Override
protected void init(UUID choosingPlayerId, boolean testMode) {
super.init(choosingPlayerId, testMode);
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
super.init(choosingPlayerId, gameOptions);
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
}

View file

@ -19,7 +19,9 @@ public class MulDayaChannelersTest extends CardTestPlayerBase {
public void testBoostFromTopCreatureCard() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Constants.Zone.HAND, playerA, "Mul Daya Channelers");
addCard(Constants.Zone.LIBRARY, playerA, "Memnite");
skipInitShuffling();
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Mul Daya Channelers");
@ -53,8 +55,10 @@ public class MulDayaChannelersTest extends CardTestPlayerBase {
public void testBoostLossThroughPhases() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 3);
addCard(Constants.Zone.HAND, playerA, "Mul Daya Channelers");
addCard(Constants.Zone.LIBRARY, playerA, "Shock");
addCard(Constants.Zone.LIBRARY, playerA, "Memnite");
skipInitShuffling();
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Mul Daya Channelers");

View file

@ -33,7 +33,9 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
BATTLEFIELD,
GRAVEYARD,
UNKNOWN
}
}
protected GameOptions gameOptions;
public CardTestPlayerBase() {
}
@ -86,6 +88,8 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
libraryCardsB.clear();
commandsA.clear();
commandsB.clear();
gameOptions = new GameOptions();
}
public void load(String path) throws FileNotFoundException, GameException {
@ -149,7 +153,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
boolean testMode = true;
long t1 = System.nanoTime();
GameOptions gameOptions = new GameOptions();
gameOptions.testMode = true;
gameOptions.stopOnTurn = stopOnTurn;
gameOptions.stopAtStep = stopAtStep;
@ -311,4 +315,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
}
}
protected void skipInitShuffling() {
gameOptions.skipInitShuffling = true;
}
}

View file

@ -382,7 +382,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
startTime = new Date();
this.gameOptions = options;
scorePlayer = state.getPlayers().values().iterator().next();
init(choosingPlayerId, options.testMode);
init(choosingPlayerId, options);
play(startingPlayerId);
saveState();
}
@ -441,7 +441,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
return false;
}
protected void init(UUID choosingPlayerId, boolean testMode) {
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
for (Player player: state.getPlayers().values()) {
player.beginTurn(this);
}
@ -449,7 +449,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
saveState();
//20091005 - 103.1
if (!testMode) { //don't shuffle in test mode for card injection on top of player's libraries
if (!gameOptions.skipInitShuffling) { //don't shuffle in test mode for card injection on top of player's libraries
for (Player player: state.getPlayers().values()) {
player.shuffleLibrary(this);
}
@ -479,10 +479,10 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
//20091005 - 103.3
for (UUID playerId: state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId);
if (!testMode || player.getLife() == 0) {
if (!gameOptions.testMode || player.getLife() == 0) {
player.setLife(this.getLife(), this);
}
if (!testMode) {
if (!gameOptions.testMode) {
player.drawCards(7, this);
}
}

View file

@ -32,5 +32,9 @@ public class GameOptions implements Serializable {
* Stop at the end of the turn if true otherwise stop at the beginning
*/
public PhaseStep stopAtStep = PhaseStep.UNTAP;
/**
* If true, library won't be shuffled at the beginning of the game
*/
public boolean skipInitShuffling = false;
}