summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/model
diff options
context:
space:
mode:
Diffstat (limited to 'test/jrummikub/model')
-rw-r--r--test/jrummikub/model/GameStateTest.java2
-rw-r--r--test/jrummikub/model/MockGameState.java54
-rw-r--r--test/jrummikub/model/MockHand.java49
-rw-r--r--test/jrummikub/model/MockPlayer.java26
-rw-r--r--test/jrummikub/model/MockTable.java26
5 files changed, 143 insertions, 14 deletions
diff --git a/test/jrummikub/model/GameStateTest.java b/test/jrummikub/model/GameStateTest.java
index a134231..e1de06c 100644
--- a/test/jrummikub/model/GameStateTest.java
+++ b/test/jrummikub/model/GameStateTest.java
@@ -8,7 +8,7 @@ import org.junit.Before;
import org.junit.Test;
public class GameStateTest {
- private GameState testGame;
+ private IGameState testGame;
@Before
public void createGame() {
diff --git a/test/jrummikub/model/MockGameState.java b/test/jrummikub/model/MockGameState.java
new file mode 100644
index 0000000..102e9fb
--- /dev/null
+++ b/test/jrummikub/model/MockGameState.java
@@ -0,0 +1,54 @@
+package jrummikub.model;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MockGameState implements IGameState {
+ public MockTable table;
+ public List<MockPlayer> players;
+ public int activePlayer;
+ public StoneHeap gameHeap;
+
+ public MockGameState() {
+ table = new MockTable();
+ players = new ArrayList<MockPlayer>();
+ players.add(new MockPlayer(Color.red));
+ players.add(new MockPlayer(Color.yellow));
+ players.add(new MockPlayer(Color.green));
+ players.add(new MockPlayer(Color.black));
+ activePlayer = 0;
+ gameHeap = new StoneHeap();
+ }
+
+ @Override
+ public ITable getTable() {
+ return table;
+ }
+
+ @Override
+ public int getPlayerCount() {
+ return players.size();
+ }
+
+ @Override
+ public IPlayer getPlayer(int i) {
+ return players.get(i);
+ }
+
+ /** Changes the activePlayer to the next {@link Player} in the list */
+ @Override
+ public void nextPlayer() {
+ activePlayer = (activePlayer + 1) % players.size();
+ }
+
+ @Override
+ public IPlayer getActivePlayer() {
+ return players.get(activePlayer);
+ }
+
+ @Override
+ public StoneHeap getGameHeap() {
+ return gameHeap;
+ }
+}
diff --git a/test/jrummikub/model/MockHand.java b/test/jrummikub/model/MockHand.java
new file mode 100644
index 0000000..1fc5954
--- /dev/null
+++ b/test/jrummikub/model/MockHand.java
@@ -0,0 +1,49 @@
+package jrummikub.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import jrummikub.util.Pair;
+
+public class MockHand implements IHand {
+
+ public List<Stone> stones = new ArrayList<Stone>();
+
+ @Override
+ public Stone pickUp(Position position) {
+ return null;
+ }
+
+ @Override
+ public void drop(Stone object, Position position) {
+ stones.add(object);
+ }
+
+ @Override
+ public Position getPosition(Stone object) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void pickUp(Stone object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getSize() {
+ return stones.size();
+ }
+
+ @Override
+ public Iterator<Pair<Stone, Position>> iterator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MockHand clone() {
+ return null;
+ }
+}
diff --git a/test/jrummikub/model/MockPlayer.java b/test/jrummikub/model/MockPlayer.java
new file mode 100644
index 0000000..adb9d85
--- /dev/null
+++ b/test/jrummikub/model/MockPlayer.java
@@ -0,0 +1,26 @@
+package jrummikub.model;
+
+import java.awt.Color;
+
+public class MockPlayer implements IPlayer {
+
+ public MockHand hand;
+ public Color color;
+
+ // private String name;
+
+ public MockPlayer(Color color) {
+ hand = new MockHand();
+ this.color = color;
+ }
+
+ @Override
+ public IHand getHand() {
+ return hand;
+ }
+
+ @Override
+ public Color getColor() {
+ return color;
+ }
+}
diff --git a/test/jrummikub/model/MockTable.java b/test/jrummikub/model/MockTable.java
index bab1f58..4d7ef1a 100644
--- a/test/jrummikub/model/MockTable.java
+++ b/test/jrummikub/model/MockTable.java
@@ -1,15 +1,19 @@
package jrummikub.model;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import jrummikub.util.Pair;
-import jrummikub.view.MockStoneCollectionPanel;
public class MockTable implements ITable {
public Map<Stone, StoneSet> findStoneSet = new HashMap<Stone, StoneSet>();
-
+ public boolean valid = false;
+ public MockTable clonedTable;
+ public List<Pair<StoneSet, Position>> sets = new ArrayList<Pair<StoneSet, Position>>();
+
@Override
public void pickUpStone(Stone stone) {
// TODO Auto-generated method stub
@@ -18,8 +22,7 @@ public class MockTable implements ITable {
@Override
public boolean isValid() {
- // TODO Auto-generated method stub
- return false;
+ return valid;
}
@Override
@@ -30,8 +33,7 @@ public class MockTable implements ITable {
@Override
public void drop(StoneSet object, Position position) {
- // TODO Auto-generated method stub
-
+ sets.add(new Pair<StoneSet, Position>(object, position));
}
@Override
@@ -43,28 +45,26 @@ public class MockTable implements ITable {
@Override
public void pickUp(StoneSet object) {
// TODO Auto-generated method stub
-
+
}
@Override
public Iterator<Pair<StoneSet, Position>> iterator() {
- // TODO Auto-generated method stub
- return null;
+ return sets.iterator();
}
@Override
public StoneSet findStoneSet(Stone stone) {
return findStoneSet.get(stone);
}
-
+
public MockTable clone() {
- return null;
+ return clonedTable;
}
@Override
public int getSize() {
- // TODO Auto-generated method stub
- return 0;
+ return sets.size();
}
}