|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jrummikub.control.RoundControl
public class RoundControl
Controller that manages a single round of rummikub
Nested Class Summary | |
---|---|
static class |
RoundControl.InvalidTurnInfo
Table, stone sets and type of an invalid turn to allow a user to track his own errors |
static class |
RoundControl.InvalidTurnType
Enum summarizing the different types of invalid turns to set the correct panel message |
Field Summary | |
---|---|
protected java.util.List<Connection> |
connections
|
private Event1<Score> |
endOfRoundEvent
|
private boolean |
mayPause
|
private Event1<PlayerSettings> |
restartRoundEvent
|
protected IRoundState |
roundState
|
private Event1<IRoundState> |
roundStateUpdateEvent
|
private ITurnControl |
turnControl
|
private IView |
view
|
Constructor Summary | |
---|---|
|
RoundControl(IRoundState roundState,
IView view)
Create a new RoundControl using the given roundState and view |
protected |
RoundControl(IRoundState roundState,
IView view,
boolean mayPause)
Create a new RoundControl using the given roundState and view |
Method Summary | |
---|---|
void |
abortRound()
Abort round if a new one is started or a saved one is loaded |
protected void |
addTurnControlListeners(ITurnControl turnControl)
Override this |
void |
continueRound()
Continue a saved round after loading |
protected ITurnControl |
createTurnControl()
Creates new turn control of the specified type |
protected void |
deal()
Deal each player the number of stones specified in the game settings (numberOfStonesDealt) |
protected void |
doPrepareTurn()
Prepare turn by setting the view components |
(package private) void |
endOfRound()
Ends the current round and emits an event setting the score |
protected void |
endOfTurn(RoundControl.InvalidTurnInfo invalidTurnInfo)
End the players turn |
IEvent1<Score> |
getEndOfRoundEvent()
End the round |
IEvent1<PlayerSettings> |
getRestartRoundEvent()
Emitted when the round is aborted and needs to be restarted |
IEvent1<IRoundState> |
getRoundStateUpdateEvent()
Is emitted in network when a new turn starts |
protected void |
nextPlayer()
Set the next player as active player if the round is not finished |
protected void |
prepareTurn()
Prepare a player's turn by checking the player types and setting the correct turn control |
protected void |
redeal()
Redeal stones and restart round if a player was allowed to redeal and chose to do so |
private void |
removeListeners()
Removes all listeners form the connections |
private Score |
score()
Calculate the score for the current round and the total game score |
protected void |
setRoundState(IRoundState state)
Sets the current round state |
protected IView.BottomPanelType |
showStartTurnPanel()
|
void |
startRound()
Begin the round |
protected void |
startTurn()
Start a players turn with the correct turn control |
private static Pair<java.lang.Integer,java.lang.Integer> |
updateBestScore(Pair<java.lang.Integer,java.lang.Integer> bestScore,
int stonePoints,
int size)
Update the best score to find the winner in case of special game end (everybody still has stones on hand) |
private void |
updateSidePanel()
Update the side panel to show correct player order and heap size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private ITurnControl turnControl
protected IRoundState roundState
private IView view
private Event1<PlayerSettings> restartRoundEvent
private Event1<IRoundState> roundStateUpdateEvent
private Event1<Score> endOfRoundEvent
protected java.util.List<Connection> connections
private boolean mayPause
Constructor Detail |
---|
public RoundControl(IRoundState roundState, IView view)
roundState
- initial round stateview
- view used for user interactionprotected RoundControl(IRoundState roundState, IView view, boolean mayPause)
roundState
- initial round stateview
- view used for user interactionmayPause
- true when players are allowed to pauseMethod Detail |
---|
public IEvent1<IRoundState> getRoundStateUpdateEvent()
public IEvent1<Score> getEndOfRoundEvent()
public void startRound()
public void continueRound()
public void abortRound()
protected void setRoundState(IRoundState state)
state
- to be setprotected IView.BottomPanelType showStartTurnPanel()
protected void prepareTurn()
protected void doPrepareTurn()
protected void startTurn()
private void updateSidePanel()
protected void addTurnControlListeners(ITurnControl turnControl)
turnControl
- current turn controlprotected ITurnControl createTurnControl()
protected void deal()
protected void endOfTurn(RoundControl.InvalidTurnInfo invalidTurnInfo)
invalidTurnInfo
- info about the player's last turnprotected void nextPlayer()
void endOfRound()
private void removeListeners()
private Score score()
private static Pair<java.lang.Integer,java.lang.Integer> updateBestScore(Pair<java.lang.Integer,java.lang.Integer> bestScore, int stonePoints, int size)
bestScore
- of previous roundsstonePoints
- sum of points still left on handssize
- number of players in game (= size of score list in columns)
public IEvent1<PlayerSettings> getRestartRoundEvent()
protected void redeal()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |