refined game flow by adjusting situations where game with automatically pass, added test case for game flow
parent
f39f6dad01
commit
394f68bede
|
@ -253,13 +253,7 @@ public class MagicGame {
|
|||
}
|
||||
|
||||
public boolean canSkipSingleChoice() {
|
||||
//human is attacking, AI is blocking,
|
||||
//pass priority during declare blockers if AI is not blocking and nothing else to do
|
||||
return GeneralConfig.getInstance().getSkipSingle() &&
|
||||
!(isPhase(MagicPhaseType.DeclareBlockers) &&
|
||||
turnPlayer.getIndex() == 0 &&
|
||||
getOpponent(turnPlayer).getNrOfBlockers() > 0 &&
|
||||
stack.isEmpty());
|
||||
return GeneralConfig.getInstance().getSkipSingle();
|
||||
}
|
||||
|
||||
public boolean canSkipSingleManaChoice() {
|
||||
|
@ -273,7 +267,8 @@ public class MagicGame {
|
|||
|
||||
public boolean canAlwaysPass() {
|
||||
if (GeneralConfig.getInstance().getAlwaysPass()) {
|
||||
return phase.getType()==MagicPhaseType.Draw||phase.getType()==MagicPhaseType.BeginOfCombat;
|
||||
return phase.getType() == MagicPhaseType.Draw ||
|
||||
phase.getType() == MagicPhaseType.BeginOfCombat;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -90,10 +90,12 @@ public class MagicPlayChoice extends MagicChoice {
|
|||
final MagicPlayer player,
|
||||
final MagicSource source) {
|
||||
|
||||
//always pass draw and begin combat option
|
||||
if (game.canAlwaysPass()) {
|
||||
return PASS_CHOICE_RESULTS;
|
||||
}
|
||||
|
||||
//skip all combat phases if nobody is attacking
|
||||
if ((game.isPhase(MagicPhaseType.DeclareAttackers) ||
|
||||
game.isPhase(MagicPhaseType.DeclareBlockers) ||
|
||||
game.isPhase(MagicPhaseType.CombatDamage) ||
|
||||
|
@ -103,11 +105,28 @@ public class MagicPlayChoice extends MagicChoice {
|
|||
return PASS_CHOICE_RESULTS;
|
||||
}
|
||||
|
||||
//skip is phase is combat damage, not supposed to be able to do
|
||||
//anything but resolve triggers
|
||||
if (game.isPhase(MagicPhaseType.CombatDamage)) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (final Exception err) {
|
||||
|
||||
}
|
||||
}
|
||||
return PASS_CHOICE_RESULTS;
|
||||
}
|
||||
|
||||
|
||||
final Set<Object> validChoices;
|
||||
validChoices=getValidChoices(game,player);
|
||||
|
||||
if ((game.isPhase(MagicPhaseType.CombatDamage)) ||
|
||||
(validChoices.isEmpty() && game.canSkipSingleChoice())) {
|
||||
//skip single choice except during declare blockers phase and stack is empty so that
|
||||
//user can observe the final combat sitation before damage is delt
|
||||
if (validChoices.isEmpty() &&
|
||||
game.canSkipSingleChoice() &&
|
||||
!(game.isPhase(MagicPhaseType.DeclareBlockers) && game.getStack().isEmpty())) {
|
||||
if (!game.getStack().isEmpty()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package magic.test;
|
||||
|
||||
import magic.model.*;
|
||||
import magic.model.phase.MagicMainPhase;
|
||||
|
||||
class TestFlow extends TestGameBuilder {
|
||||
public MagicGame getGame() {
|
||||
final MagicTournament tournament=new MagicTournament();
|
||||
tournament.setDifficulty(6);
|
||||
|
||||
final MagicPlayerProfile profile=new MagicPlayerProfile("bgruw");
|
||||
final MagicPlayerDefinition player1=new MagicPlayerDefinition("Player",false,profile,15);
|
||||
final MagicPlayerDefinition player2=new MagicPlayerDefinition("Computer",true,profile,14);
|
||||
tournament.setPlayers(new MagicPlayerDefinition[]{player1,player2});
|
||||
tournament.setStartPlayer(0);
|
||||
|
||||
final MagicGame game=tournament.nextGame(true);
|
||||
game.setPhase(MagicMainPhase.getFirstInstance());
|
||||
final MagicPlayer player=game.getPlayer(0);
|
||||
final MagicPlayer opponent=game.getPlayer(1);
|
||||
|
||||
MagicPlayer P = player;
|
||||
|
||||
P.setLife(4);
|
||||
P.setPoison(0);
|
||||
addToLibrary(P,"Plains",10);
|
||||
createPermanent(game,P,"Rupture Spire",false,8);
|
||||
createPermanent(game,P,"Chameleon Colossus",false,1);
|
||||
|
||||
|
||||
P = opponent;
|
||||
|
||||
P.setLife(8);
|
||||
P.setPoison(0);
|
||||
addToLibrary(P,"Island",10);
|
||||
createPermanent(game,P,"Rupture Spire",false,5);
|
||||
createPermanent(game,P,"Tectonic Edge",false,3);
|
||||
|
||||
return game;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue