- Install
docker
(>= 1.12.1) anddocker-compose
(>= 1.8.0) - In
/frontend
folder, run./run-command-in-container.sh npm install
- In root, run
./start-dev.sh
Frontend testing is done with Jest. Configuration for Jest is located in frontend/package.json
. Frontend tests are run from command line:
./run-command-in-container.sh npm test
Backend tests are run in the IntelliJ Idea IDE or from command line.
From command line: ./gradlew TASK
The different tasks:
test
: unit testsintegrationTest
: integration testsacceptanceTest
: acceptance tests (Cucumber)build
: all the above together
See the separate server documentation file provided.
Run the npm install ...
command through ./run-command-in-container.sh npm install ...
in /frontend
folder
Creating of objects happens with builder-pattern. Background and how to use them can be read here: Builder-pattern
For fast generation of builder objects for classes in IntelliJ IDEA: Builder-generator
Basic with defaults example:
String playerName = "player";
game = GameBuilder.aGame()
.withNormalDifficultyMockDefaults(playerName)
.build();
Overwriting some attribute but keeping others default:
String playerName = "player";
game = GameBuilder.aGame()
.withNormalDifficultyMockDefaults(playerName)
.withId("id")
.build();
Object persistance in dev and integration-testing:
@Autowired
private GameRepository gameRepository;
...
String playerName = "player";
game = GameBuilder.aGame()
.withNormalDifficultyMockDefaults(playerName)
.create(gameRepository);
NOTE create is not default provided by builder generator
Advanced-version of the game should include event cards. The idea is for Advanced DifficultyConfiguration to produce a game with event cards, using EventCardInstantiators. This is not implemented yet in the game.
GameOptionChange-class can alter the game and its options in the game initialization phase or later with event cards. GameOptionChange-object stores the callable method name with its parameters. The idea is to use reflection to call the method to change the game options. Example of this in use in GameInitService.java:
public Game getInitializedGame(DifficultyConfiguration difficultyConfiguration, String playerName) {
...
Object gameWithGameOptionChanges = GameBuilder.aGame()
.withNormalDifficultyDefaults(difficultyConfiguration,
playerName, baseCardRepository, phaseRepository)
.withDifficultyLevel(GameDifficulty.ADVANCED)
.build();
for (int i = 0; i < difficultyConfiguration.getInitialGameOptionChanges().size(); i++) {
GameOptionChange gameOptionChange = difficultyConfiguration.getInitialGameOptionChanges().get(i);
String methodName = gameOptionChange.getMethodName();
try {
Class parameterCls = Class.forName(gameOptionChange.getParameters());
Method methodToInvoke = GameOptionService.class.getMethod(methodName, parameterCls);
gameWithGameOptionChanges = methodToInvoke.invoke(new GameOptionService(), gameWithGameOptionChanges);
} catch (Exception e) {
throw new GameInitException();
}
}
...