Skip to content

Instantly share code, notes, and snippets.

@paveljurca
Created July 19, 2015 09:31
Show Gist options
  • Save paveljurca/49508cbea7bcc45a6e65 to your computer and use it in GitHub Desktop.
Save paveljurca/49508cbea7bcc45a6e65 to your computer and use it in GitHub Desktop.
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class GameTest {
private Game game;
private GameSchema plot;
@Before
public void setUp() {
// "false" let's you load a particular progress
game = new Game(false);
plot = game.getSchema();
}
@Test
public void testGameIsWinnable() {
// the game DSL
String[] progress = {
"toaleta",
"seber mydlo skrinka",
"jdi predsin",
"jdi zagameda",
"poloz mydlo myval",
"seber klicKOMORA myval",
"jdi predsin",
"jdi pracovna",
"poloz klickomora",
"seber suplik stolek",
"poloz suplik",
"seber cepels suplik",
"seber klickomora",
"jdi predsin",
"jdi chodba",
"odemkni komora",
"jdi komora",
"seber voda",
"jez cepels",
"pij voda"
};
Stuff backpack = null;
// a backpack is randomly placed
for (Room room : plot.getRooms()) {
backpack = room.withdraw("bagl");
if (backpack != null) {
break;
}
}
// likewise the backpack is a special stuff
if (backpack != null && backpack instanceof StuffBackpack) {
plot.you().addStuff((StuffBackpack)backpack);
}
// we've managed to grab the backpack
assertNotNull(plot.you().getBatoh());
// so we can load the game progress now
game.Load(progress);
/*
the game is winnable
*/
assertTrue(game.isSuccess());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment