package games.gofish;
import game.Card;
import game.Game;
import game.Player;
import games.gofish.state.PlayerTurnState;
import games.gofish.state.TurnState;
import hand.GoFishHand;
import hand.Hand;
/**
* A game of go fish between the user and the computer
* @author TJ Renninger
*
*/
public class GoFish extends Game
{
private Player computer;
private TurnState turnState;
/**
* Sets the player to go first
*/
public GoFish()
{
resetDeck();
setId(3);
player = new Player(new GoFishHand());
computer = new Player(new GoFishHand());
turnState = new PlayerTurnState();
start();
}
/**
* Shuffle the deck and each player draws
*/
public void start()
{
shuffleDeck();
player.draw();
computer.draw();
}
/**
* The players whose turn it is will ask the other player for a card
* @param value of the card being asked for
*/
public void askForCard(int value)
{
turnState.askForCard(this, player, computer, value);
}
/**
* The players whose turn it is will fish for a card
*/
public void goFish()
{
turnState.goFish(player, computer);
}
/**
* Sets which players turn it is.
* @param turnState
*/
public void setState(TurnState turnState)
{
this.turnState = turnState;
}
/**
* The players whose turn it is will check its hand for a match
*/
public boolean checkForMatch()
{
return turnState.checkForMatch(player, computer);
}
/**
*
* @return the current turn state
*/
public TurnState getState()
{
return turnState;
}
/**
*
* @return the player
*/
public Player getPlayer()
{
return player;
}
/**
*
* @return the computer
*/
public Player getComputer()
{
return computer;
}
}