de.palmmedia.yahtzee
Class Game

java.lang.Object
  extended by Activity
      extended by de.palmmedia.yahtzee.Game

public class Game
extends Activity

The activity where the game is played. Each player can roll the dices three times, the dices can be locked to exclude them from rolling. As soon as the player has marked an Element it's the next player's turn.

Author:
Daniel Palme

Field Summary
private  List<ElementButton> elementButtons
          The buttons that allow to select an element.
private  OnClickListener markListener
          Executed when an element is selected.
(package private)  MediaPlayer rollingDicesMediaPlayer
          Mediaplayer to play sound.
private  ShakeDetector shakeDetector
          ShakeDetector to roll dices when device is shook.
private  ShakeEventListener shakeEventListener
          Executed when device is shook.
 
Constructor Summary
Game()
           
 
Method Summary
private  View createElementView(Element element)
          Creates a view for the given Element.
private  GameContext getGameContext()
          Get the GameContext.
private  void markElement(ElementButton markedElementButton)
          Executed when an element is marked.
 void nextPlayer(View view)
          Shows the next player.
 void onCreate(Bundle savedInstanceState)
          
protected  void onPause()
          
protected  void onResume()
          
 void rollDices(View view)
          Rolls the dices.
private  void showScores()
          Shows the results at the end of the game.
private  void undoMarking()
          Remove the marking from the marked element.
private  void update()
          Update the UI, except the elements.
private  void updateElements()
          Update the elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shakeDetector

private ShakeDetector shakeDetector
ShakeDetector to roll dices when device is shook.


rollingDicesMediaPlayer

MediaPlayer rollingDicesMediaPlayer
Mediaplayer to play sound.


elementButtons

private List<ElementButton> elementButtons
The buttons that allow to select an element.


markListener

private OnClickListener markListener
Executed when an element is selected.


shakeEventListener

private ShakeEventListener shakeEventListener
Executed when device is shook.

Constructor Detail

Game

public Game()
Method Detail

getGameContext

private GameContext getGameContext()
Get the GameContext.

Returns:
The GameContext.

onCreate

public void onCreate(Bundle savedInstanceState)


onResume

protected void onResume()


onPause

protected void onPause()


rollDices

public void rollDices(View view)
Rolls the dices.

Parameters:
view - The view.

nextPlayer

public void nextPlayer(View view)
Shows the next player.

Parameters:
view - The view.

markElement

private void markElement(ElementButton markedElementButton)
Executed when an element is marked.

Parameters:
markedElementButton -

undoMarking

private void undoMarking()
Remove the marking from the marked element.


showScores

private void showScores()
Shows the results at the end of the game.


update

private void update()
Update the UI, except the elements.


updateElements

private void updateElements()
Update the elements.


createElementView

private View createElementView(Element element)
Creates a view for the given Element.

Parameters:
element - The Element.
Returns:
The created view.