Added all missing comments
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@213 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
4a860e53cf
commit
3b49b2053e
38 changed files with 696 additions and 263 deletions
|
@ -2,12 +2,26 @@ package jrummikub.control;
|
|||
|
||||
import jrummikub.util.IEvent;
|
||||
|
||||
/**
|
||||
* Interface for the {@link TurnTimer}
|
||||
*/
|
||||
public interface ITurnTimer {
|
||||
|
||||
/**
|
||||
* Starts the timer
|
||||
*/
|
||||
public abstract void startTimer();
|
||||
|
||||
/**
|
||||
* Stops the timer. Stopping an already stopped timer is a no-op.
|
||||
*/
|
||||
public abstract void stopTimer();
|
||||
|
||||
/**
|
||||
* Returns the event that is emitted if the timer timed out.
|
||||
*
|
||||
* @return time out event
|
||||
*/
|
||||
public abstract IEvent getTimeRunOutEvent();
|
||||
|
||||
}
|
|
@ -18,6 +18,9 @@ import jrummikub.util.IListener;
|
|||
import jrummikub.util.Pair;
|
||||
import jrummikub.view.IView;
|
||||
|
||||
/**
|
||||
* Controller that manages a single round of rummikub
|
||||
*/
|
||||
public class RoundControl {
|
||||
private IGameState gameState;
|
||||
private IView view;
|
||||
|
@ -25,6 +28,14 @@ public class RoundControl {
|
|||
private Event endRoundEvent = new Event();
|
||||
private List<Connection> connections = new ArrayList<Connection>();
|
||||
|
||||
/**
|
||||
* Create a new RoundControl using the given gameState and view
|
||||
*
|
||||
* @param gameState
|
||||
* initial game state
|
||||
* @param view
|
||||
* view used for user interaction
|
||||
*/
|
||||
public RoundControl(IGameState gameState, IView view) {
|
||||
this.gameState = gameState;
|
||||
this.view = view;
|
||||
|
@ -34,6 +45,9 @@ public class RoundControl {
|
|||
return endRoundEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin the round
|
||||
*/
|
||||
public void startRound() {
|
||||
deal();
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ import jrummikub.util.IListener2;
|
|||
import jrummikub.util.Pair;
|
||||
import jrummikub.view.IView;
|
||||
|
||||
/**
|
||||
* Controller for a single turn made by a human player
|
||||
*/
|
||||
public class TurnControl {
|
||||
private IHand hand;
|
||||
private ITable table;
|
||||
|
@ -32,6 +35,17 @@ public class TurnControl {
|
|||
private Event endOfTurnEvent = new Event();
|
||||
private List<Connection> connections = new ArrayList<Connection>();
|
||||
|
||||
/**
|
||||
* Create a new TurnControl using a given hand (of the active player), a
|
||||
* given table and a given view for user interaction.
|
||||
*
|
||||
* @param hand
|
||||
* active player's hand
|
||||
* @param table
|
||||
* current table
|
||||
* @param view
|
||||
* view for user interaction.
|
||||
*/
|
||||
public TurnControl(IHand hand, ITable table, IView view) {
|
||||
this.hand = hand;
|
||||
this.table = table;
|
||||
|
@ -47,6 +61,9 @@ public class TurnControl {
|
|||
this.timer = testTimer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the turn
|
||||
*/
|
||||
public void startTurn() {
|
||||
|
||||
IListener endOfTurnListener = new IListener() {
|
||||
|
@ -408,6 +425,11 @@ public class TurnControl {
|
|||
view.setSelectedStones(new ArrayList<Stone>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event that is emitted when the turn is over
|
||||
*
|
||||
* @return end of turn event
|
||||
*/
|
||||
public IEvent getEndOfTurnEvent() {
|
||||
return endOfTurnEvent;
|
||||
}
|
||||
|
|
|
@ -9,12 +9,21 @@ import jrummikub.util.Event;
|
|||
import jrummikub.util.IEvent;
|
||||
import jrummikub.view.IView;
|
||||
|
||||
/**
|
||||
* Count-down timer used to limit the turn time
|
||||
*/
|
||||
public class TurnTimer implements ActionListener, ITurnTimer {
|
||||
private IView view;
|
||||
private int timeLeft = 60;
|
||||
private Timer timer;
|
||||
private Event timeRunOutEvent = new Event();
|
||||
|
||||
/**
|
||||
* Create a new timer using a given view to display the current time left
|
||||
*
|
||||
* @param view
|
||||
* view to display
|
||||
*/
|
||||
public TurnTimer(IView view) {
|
||||
this.view = view;
|
||||
timer = new Timer(1000, this);
|
||||
|
@ -23,19 +32,16 @@ public class TurnTimer implements ActionListener, ITurnTimer {
|
|||
view.getPlayerPanel().setTimeLeft(timeLeft);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startTimer() {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stopTimer() {
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
timeLeft--;
|
||||
|
|
Reference in a new issue