package uno; import java.util.List; /** *

A GameState object provides programmatic access to certain (legal) * aspects of an Uno game, so that interested players can take advantage of * that information. Note that not all aspects of a game's state * (e.g., the direction of play, whose turn it is next, the actual * cards in each player's hand (!), etc.) are reflected in the GameState * object -- only those for which it makes sense for a player to have * access.

* @since 2.0 */ public class GameState { private Game theGame; private int[] numCardsInHandsOfUpcomingPlayers; private UnoPlayer.Color[] mostRecentColorCalledByUpcomingPlayers; private int[] totalScoreOfUpcomingPlayers; /** * (Blank constructor, used only during testing.) */ GameState() { numCardsInHandsOfUpcomingPlayers = new int[4]; mostRecentColorCalledByUpcomingPlayers = new UnoPlayer.Color[4]; totalScoreOfUpcomingPlayers = new int[4]; } /** * Instantiate a new GameState object whose job it is to provide safe * access to the Game object passed. */ GameState(Game game) { numCardsInHandsOfUpcomingPlayers = new int[game.scoreboard.getNumPlayers()]; mostRecentColorCalledByUpcomingPlayers = new UnoPlayer.Color[game.scoreboard.getNumPlayers()]; totalScoreOfUpcomingPlayers = new int[game.scoreboard.getNumPlayers()]; if (game.direction == Game.Direction.FORWARDS) { for (int i=0; iall cards that have been played since the * last time the deck was remixed. This allows players to "card count" * if they choose. */ public List getPlayedCards() { if (theGame != null) { return theGame.deck.getDiscardedCards(); } else { // testing only return new java.util.ArrayList(); } } }