Commit 2b234e74 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers 🐦

fix issue in end of game detection (fixes #23 )

parent 8bafc7cf
......@@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v1.2.3 (unreleased)
## v1.2.4
### Fixes
- Fix regression in end of game detection ( issue #23 )
## v1.2.3
### Added
- New history features allow for easier processing of game events ( issue #6 )
......
......@@ -156,7 +156,7 @@ public class BasicState implements GameState {
this.deck = new Deck();
this.table = new EnumMap<>(CardColour.class);
this.discard = new ArrayList<>();
this.movesLeft = playerCount;
this.movesLeft = playerCount + 1;
this.historyEntries = new LinkedList<>();
this.turnNumber = 0;
......
package com.fossgalaxy.games.fireworks.state;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import com.fossgalaxy.games.fireworks.state.actions.Action;
import com.fossgalaxy.games.fireworks.state.actions.PlayCard;
public class TestBasicState {
/**
* Game logic test: check the end game plays out correctly
*/
@Test
public void testEndgame() {
//setup a two player game
GameState state = new BasicState(2);
state.init();
Deck deck = state.getDeck();
// empty the deck
while(deck.hasCardsLeft()) {
deck.getTopCard();
}
// draw the last card as player 1
Action action = new PlayCard(1);
Action action2 = new PlayCard(2); //slot 1 will be null
// check the game is not over
action.apply(0, state);
assertEquals("Game was over when it was my go", false, state.isGameOver());
// let player 1 have a go
action.apply(1, state);
assertEquals("Game was over after other player's go", false, state.isGameOver());
// we make the last move
action2.apply(0, state);
assertEquals("game was not over at the end", true, state.isGameOver());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment