public void stateChanged(List<ActionRule> appliedRules) { /* * Update score */ int appliedScore = 0; for (ActionRule aRule : appliedRules) { appliedScore += aRule.score(); } this.playerScore += appliedScore; /* * Check whether a Rule ended the game */ for (ActionRule aRule : appliedRules) { if (aRule.endsGame() == false) { continue; } this.gameOver = true; this.gameOverMessage = aRule.getDescription(); notifyListeners(0); return; } /* * Check whether all houses are closed */ boolean allClosed = true; for (House house : this.houses) { if (house.isOpened()) allClosed = false; } if (allClosed) { /* * If all closed, then game over */ this.gameOver = true; this.gameOverMessage = "All houses where closed."; } else { /* * If at least one opened, try to deal */ try { deal(); } catch (HoCException e) { /* * If there are no cards left, game over */ this.playersHandCard = null; this.gameOver = true; notifyListenersGameWon( this.hallOfFame.addPlayer(new Player("Enter Name", this.playerScore))); return; } } notifyListeners(appliedScore); }