GameState ist jetzt RoundState
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@249 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
d0a7014577
commit
b3c903a2ad
7 changed files with 19 additions and 19 deletions
|
@ -5,9 +5,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock class for {@link GameState}
|
* Mock class for {@link RoundState}
|
||||||
*/
|
*/
|
||||||
public class MockGameState implements IGameState {
|
public class MockRoundState implements IRoundState {
|
||||||
/** */
|
/** */
|
||||||
public MockTable table;
|
public MockTable table;
|
||||||
/** */
|
/** */
|
||||||
|
@ -20,7 +20,7 @@ public class MockGameState implements IGameState {
|
||||||
public StoneHeap gameHeap;
|
public StoneHeap gameHeap;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public MockGameState() {
|
public MockRoundState() {
|
||||||
table = new MockTable();
|
table = new MockTable();
|
||||||
players = new ArrayList<MockPlayer>();
|
players = new ArrayList<MockPlayer>();
|
||||||
players.add(new MockPlayer("Player 1", Color.RED));
|
players.add(new MockPlayer("Player 1", Color.RED));
|
|
@ -1,6 +1,6 @@
|
||||||
package jrummikub.control;
|
package jrummikub.control;
|
||||||
|
|
||||||
import jrummikub.model.GameState;
|
import jrummikub.model.RoundState;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class GameControl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState gameState = new GameState();
|
RoundState gameState = new RoundState();
|
||||||
|
|
||||||
roundControl = new RoundControl(gameState, view);
|
roundControl = new RoundControl(gameState, view);
|
||||||
roundControl.getEndRoundEvent().add(new IListener() {
|
roundControl.getEndRoundEvent().add(new IListener() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import jrummikub.model.Hand;
|
import jrummikub.model.Hand;
|
||||||
import jrummikub.model.IGameState;
|
import jrummikub.model.IRoundState;
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
|
@ -23,7 +23,7 @@ import jrummikub.view.IView;
|
||||||
* Controller that manages a single round of rummikub
|
* Controller that manages a single round of rummikub
|
||||||
*/
|
*/
|
||||||
public class RoundControl {
|
public class RoundControl {
|
||||||
private IGameState gameState;
|
private IRoundState gameState;
|
||||||
private IView view;
|
private IView view;
|
||||||
private ITable clonedTable;
|
private ITable clonedTable;
|
||||||
private Event endRoundEvent = new Event();
|
private Event endRoundEvent = new Event();
|
||||||
|
@ -37,7 +37,7 @@ public class RoundControl {
|
||||||
* @param view
|
* @param view
|
||||||
* view used for user interaction
|
* view used for user interaction
|
||||||
*/
|
*/
|
||||||
public RoundControl(IGameState gameState, IView view) {
|
public RoundControl(IRoundState gameState, IView view) {
|
||||||
this.gameState = gameState;
|
this.gameState = gameState;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package jrummikub.model;
|
package jrummikub.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for {@link GameState} model
|
* Interface for {@link RoundState} model
|
||||||
*/
|
*/
|
||||||
public interface IGameState {
|
public interface IRoundState {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current {@link Table}
|
* Get the current {@link Table}
|
|
@ -5,7 +5,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** Class managing the overall and momentary GameState */
|
/** Class managing the overall and momentary GameState */
|
||||||
public class GameState implements IGameState {
|
public class RoundState implements IRoundState {
|
||||||
private ITable table;
|
private ITable table;
|
||||||
private List<Player> players;
|
private List<Player> players;
|
||||||
private int activePlayer;
|
private int activePlayer;
|
||||||
|
@ -14,7 +14,7 @@ public class GameState implements IGameState {
|
||||||
/**
|
/**
|
||||||
* Create a new GameState with an empty table and (currently) 4 new players.
|
* Create a new GameState with an empty table and (currently) 4 new players.
|
||||||
*/
|
*/
|
||||||
public GameState() {
|
public RoundState() {
|
||||||
table = new Table();
|
table = new Table();
|
||||||
players = new ArrayList<Player>();
|
players = new ArrayList<Player>();
|
||||||
players.add(new Player("Ida", Color.RED));
|
players.add(new Player("Ida", Color.RED));
|
|
@ -20,7 +20,7 @@ import java.util.Set;
|
||||||
import jrummikub.model.Hand;
|
import jrummikub.model.Hand;
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.model.MockGameState;
|
import jrummikub.model.MockRoundState;
|
||||||
import jrummikub.model.MockTable;
|
import jrummikub.model.MockTable;
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
import jrummikub.model.Stone;
|
import jrummikub.model.Stone;
|
||||||
|
@ -37,7 +37,7 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class RoundControlTest {
|
public class RoundControlTest {
|
||||||
private MockView view;
|
private MockView view;
|
||||||
private MockGameState testGameState;
|
private MockRoundState testGameState;
|
||||||
private RoundControl testRound;
|
private RoundControl testRound;
|
||||||
private MockTable newTable;
|
private MockTable newTable;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class RoundControlTest {
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
view = new MockView();
|
view = new MockView();
|
||||||
testGameState = new MockGameState();
|
testGameState = new MockRoundState();
|
||||||
testRound = new RoundControl(testGameState, view);
|
testRound = new RoundControl(testGameState, view);
|
||||||
Stone stone = testGameState.getGameHeap().drawStone();
|
Stone stone = testGameState.getGameHeap().drawStone();
|
||||||
testGameState.table.drop(new StoneSet(stone), new Position(5, 0));
|
testGameState.table.drop(new StoneSet(stone), new Position(5, 0));
|
||||||
|
|
|
@ -7,15 +7,15 @@ import java.awt.Color;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* Test class for {@link GameState}
|
* Test class for {@link RoundState}
|
||||||
*/
|
*/
|
||||||
public class GameStateTest {
|
public class RoundStateTest {
|
||||||
private IGameState testGame;
|
private IRoundState testGame;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@Before
|
@Before
|
||||||
public void createGame() {
|
public void createGame() {
|
||||||
testGame = new GameState();
|
testGame = new RoundState();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
Reference in a new issue