Select a random player for the first round

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@263 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Jannis Harder 2011-05-24 01:51:54 +02:00
parent d9a0b0e37d
commit 92d1109954
5 changed files with 61 additions and 3 deletions

View file

@ -0,0 +1,24 @@
package jrummikub.model;
/**
* Class that stores information for a game of multiple rounds
*/
public class GameState {
private int firstRoundFirstPlayer;
/**
* Gets the number of the first player of the first round
* @return the number of the first player of the first round
*/
public int getFirstRoundFirstPlayer() {
return firstRoundFirstPlayer;
}
/**
* Sets the number of the first player of the first round
* @param firstRoundFirstPlayer the number of the first player of the first round
*/
public void setFirstRoundFirstPlayer(int firstRoundFirstPlayer) {
this.firstRoundFirstPlayer = firstRoundFirstPlayer;
}
}

View file

@ -64,8 +64,7 @@ public interface IRoundState {
* Sets the player that will make the last turn before the round ends when
* the heap is empty
*
* @param lastPlayer
* the last player
* @return the last player
*/
public abstract IPlayer getLastPlayer();
@ -73,8 +72,17 @@ public interface IRoundState {
* Gets the player that will make the last turn before the round ends when
* the heap is empty
*
* @return lastPlayer the last player
* @param lastPlayer
* the last player
*/
public abstract void setLastPlayer(IPlayer lastPlayer);
/**
* Makes the player with number i the active player
*
* @param i
* number of the player to make active
*/
public void setActivePlayerNumber(int i);
}

View file

@ -52,6 +52,15 @@ public class RoundState implements IRoundState {
public void nextPlayer() {
activePlayer = (activePlayer + 1) % players.size();
}
@Override
public void setActivePlayerNumber(int i) {
int j = i % players.size();
if (j < 0) {
j += players.size();
}
activePlayer = j;
}
@Override
public IPlayer getNthNextPlayer(int i) {