Allow laying out stone sets
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@180 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
b9fbe279c3
commit
b86571cf83
8 changed files with 209 additions and 125 deletions
|
@ -8,7 +8,7 @@ import jrummikub.util.Pair;
|
||||||
|
|
||||||
public class MockHand implements IHand {
|
public class MockHand implements IHand {
|
||||||
|
|
||||||
public List<Stone> stones = new ArrayList<Stone>();
|
public List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>();
|
||||||
|
|
||||||
public Iterable<Pair<Stone, Position>> iterable;
|
public Iterable<Pair<Stone, Position>> iterable;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class MockHand implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(Stone object, Position position) {
|
public void drop(Stone object, Position position) {
|
||||||
stones.add(object);
|
stones.add(new Pair<Stone, Position>(object, position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,12 @@ public class MockHand implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pickUp(Stone object) {
|
public void pickUp(Stone object) {
|
||||||
stones.remove(object);
|
List<Pair<Stone, Position>> itList = new ArrayList(stones);
|
||||||
|
for (Pair<Stone, Position> entry : itList) {
|
||||||
|
if (entry.getFirst() == object) {
|
||||||
|
stones.remove(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,7 +45,11 @@ public class MockHand implements IHand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Pair<Stone, Position>> iterator() {
|
public Iterator<Pair<Stone, Position>> iterator() {
|
||||||
return iterable.iterator();
|
if (iterable != null) {
|
||||||
|
return iterable.iterator();
|
||||||
|
} else {
|
||||||
|
return stones.iterator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockHand clone() {
|
public MockHand clone() {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package jrummikub.view;
|
package jrummikub.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
import jrummikub.model.Stone;
|
import jrummikub.model.Stone;
|
||||||
import jrummikub.util.Event2;
|
import jrummikub.util.Event2;
|
||||||
|
@ -9,7 +12,7 @@ import jrummikub.util.Pair;
|
||||||
|
|
||||||
public class MockHandPanel implements IHandPanel {
|
public class MockHandPanel implements IHandPanel {
|
||||||
public Event2<Stone, Boolean> stoneClickEvent = new Event2<Stone, Boolean>();
|
public Event2<Stone, Boolean> stoneClickEvent = new Event2<Stone, Boolean>();
|
||||||
public Iterable<Pair<Stone, Position>> stones;
|
public List<Pair<Stone, Position>> stones;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
||||||
|
@ -36,7 +39,11 @@ public class MockHandPanel implements IHandPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStones(Iterable<Pair<Stone, Position>> stones) {
|
public void setStones(Iterable<Pair<Stone, Position>> stones) {
|
||||||
this.stones = stones;
|
this.stones = new ArrayList<Pair<Stone, Position>>();
|
||||||
|
|
||||||
|
for (Pair<Stone, Position> entry : stones) {
|
||||||
|
this.stones.add(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ public class JRummikub {
|
||||||
GameState gameState = new GameState();
|
GameState gameState = new GameState();
|
||||||
View view = new View();
|
View view = new View();
|
||||||
|
|
||||||
for (Stone stone : gameState.getGameHeap().drawStones(5)) {
|
/*for (Stone stone : gameState.getGameHeap().drawStones(5)) {
|
||||||
gameState.getTable().drop(new StoneSet(stone), new Position(0, 0));
|
gameState.getTable().drop(new StoneSet(stone), new Position(0, 0));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
RoundControl roundControl = new RoundControl(gameState, view);
|
RoundControl roundControl = new RoundControl(gameState, view);
|
||||||
roundControl.startRound();
|
roundControl.startRound();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import jrummikub.util.Connection;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.IListener1;
|
||||||
import jrummikub.util.IListener2;
|
import jrummikub.util.IListener2;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
|
@ -59,8 +60,7 @@ public class TurnControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Stone stone, Boolean collect) {
|
public void handle(Stone stone, Boolean collect) {
|
||||||
handStoneClick(stone, collect);
|
stoneClick(stone, collect);
|
||||||
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -72,6 +72,36 @@ public class TurnControl {
|
||||||
collectionStoneClick(stone, collect);
|
collectionStoneClick(stone, collect);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
connections.add(view.getTablePanel().getStoneClickEvent()
|
||||||
|
.add(new IListener2<Stone, Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Stone stone, Boolean collect) {
|
||||||
|
stoneClick(stone, collect);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
connections.add(view.getTablePanel().getClickEvent()
|
||||||
|
.add(new IListener1<Position>() {
|
||||||
|
@Override
|
||||||
|
public void handle(Position pos) {
|
||||||
|
tableClick(pos);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
connections.add(view.getTablePanel().getLeftConnectorClickEvent()
|
||||||
|
.add(new IListener1<StoneSet>() {
|
||||||
|
@Override
|
||||||
|
public void handle(StoneSet set) {
|
||||||
|
leftConnectorClick(set);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
connections.add(view.getTablePanel().getRightConnectorClickEvent()
|
||||||
|
.add(new IListener1<StoneSet>() {
|
||||||
|
@Override
|
||||||
|
public void handle(StoneSet set) {
|
||||||
|
rightConnectorClick(set);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
|
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
|
||||||
view.enableStartTurnPanel(false);
|
view.enableStartTurnPanel(false);
|
||||||
|
@ -87,7 +117,7 @@ public class TurnControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handStoneClick(Stone stone, boolean collect) {
|
private void stoneClick(Stone stone, boolean collect) {
|
||||||
if (collect) {
|
if (collect) {
|
||||||
if (!selectedStones.remove(stone)) {
|
if (!selectedStones.remove(stone)) {
|
||||||
selectedStones.add(stone);
|
selectedStones.add(stone);
|
||||||
|
@ -110,15 +140,32 @@ public class TurnControl {
|
||||||
view.setSelectedStones(selectedStones);
|
view.setSelectedStones(selectedStones);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leftConnectorClick(StoneSet set){
|
private void pickUpSelectedStones() {
|
||||||
|
for (Stone stone : selectedStones) {
|
||||||
|
hand.pickUp(stone);
|
||||||
|
table.pickUpStone(stone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tableClick(Position position) {
|
||||||
|
if (selectedStones.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pickUpSelectedStones();
|
||||||
|
table.drop(new StoneSet(selectedStones), position);
|
||||||
|
selectedStones.clear();
|
||||||
|
|
||||||
|
view.getTablePanel().setStoneSets(table);
|
||||||
|
view.getPlayerPanel().getHandPanel().setStones(hand);
|
||||||
|
view.setSelectedStones(selectedStones);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void leftConnectorClick(StoneSet set) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rightConnectorClick(StoneSet set){
|
private void rightConnectorClick(StoneSet set) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tableClick(Position position){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import jrummikub.util.Pair;
|
||||||
* Type of positioned objects (must implement Sizeable)
|
* Type of positioned objects (must implement Sizeable)
|
||||||
*/
|
*/
|
||||||
public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
protected HashMap<E, Position> objects = new HashMap<E, Position>();
|
protected HashMap<E, Pair<E, Position>> objects = new HashMap<E, Pair<E, Position>>();
|
||||||
|
|
||||||
/** Possible move directions in case of overlapping Stones/Sets */
|
/** Possible move directions in case of overlapping Stones/Sets */
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public E pickUp(Position position) {
|
public E pickUp(Position position) {
|
||||||
for (Map.Entry<E, Position> i : objects.entrySet()) {
|
for (Map.Entry<E, Pair<E, Position>> i : objects.entrySet()) {
|
||||||
Position currentPosition = i.getValue();
|
Position currentPosition = i.getValue().getSecond();
|
||||||
E currentObject = i.getKey();
|
E currentObject = i.getKey();
|
||||||
// Tests if position is left of, above ... the current object
|
// Tests if position is left of, above ... the current object
|
||||||
if (position.getX() < currentPosition.getX()) {
|
if (position.getX() < currentPosition.getX()) {
|
||||||
|
@ -68,10 +68,10 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void drop(E object, Position position, Direction direction) {
|
private void drop(E object, Position position, Direction direction) {
|
||||||
for (Map.Entry<E, Position> i : ((Map<E, Position>) objects.clone())
|
for (Pair<E, Position> i : ((Map<E, Pair<E, Position>>) objects.clone())
|
||||||
.entrySet()) {
|
.values()) {
|
||||||
Position currentPosition = i.getValue();
|
Position currentPosition = i.getSecond();
|
||||||
E currentObject = i.getKey();
|
E currentObject = i.getFirst();
|
||||||
if (!objectsOverlap(object, position, currentObject,
|
if (!objectsOverlap(object, position, currentObject,
|
||||||
currentPosition)) {
|
currentPosition)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -101,10 +101,10 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
objects.remove(i.getKey());
|
objects.remove(i.getFirst());
|
||||||
drop(currentObject, newPosition, direction);
|
drop(currentObject, newPosition, direction);
|
||||||
}
|
}
|
||||||
objects.put(object, position);
|
objects.put(object, new Pair<E, Position>(object, position));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tests whether two objects overlap **/
|
/** Tests whether two objects overlap **/
|
||||||
|
@ -127,14 +127,14 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Direction getMoveDirection(E object, Position position,
|
private Direction getMoveDirection(E object, Position position,
|
||||||
Map.Entry<E, Position> blocking) {
|
Pair<E, Position> blocking) {
|
||||||
boolean isVertical = getMoveOrientationn(object, position, blocking);
|
boolean isVertical = getMoveOrientation(object, position, blocking);
|
||||||
float objectMidpointX = position.getX() + object.getWidth() / 2;
|
float objectMidpointX = position.getX() + object.getWidth() / 2;
|
||||||
float objectMidpointY = position.getY() + object.getHeight() / 2;
|
float objectMidpointY = position.getY() + object.getHeight() / 2;
|
||||||
float blockingMidpointX = blocking.getValue().getX()
|
float blockingMidpointX = blocking.getSecond().getX()
|
||||||
+ blocking.getKey().getWidth() / 2;
|
+ blocking.getFirst().getWidth() / 2;
|
||||||
float blockingMidpointY = blocking.getValue().getY()
|
float blockingMidpointY = blocking.getSecond().getY()
|
||||||
+ blocking.getKey().getHeight() / 2;
|
+ blocking.getFirst().getHeight() / 2;
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
if (objectMidpointY < blockingMidpointY) {
|
if (objectMidpointY < blockingMidpointY) {
|
||||||
return Direction.BOTTOM;
|
return Direction.BOTTOM;
|
||||||
|
@ -150,21 +150,21 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getMoveOrientationn(E object, Position position,
|
private boolean getMoveOrientation(E object, Position position,
|
||||||
Map.Entry<E, Position> blocking) {
|
Pair<E, Position> blocking) {
|
||||||
float objectRight = position.getX() + object.getWidth();
|
float objectRight = position.getX() + object.getWidth();
|
||||||
float blockingRight = blocking.getValue().getX()
|
float blockingRight = blocking.getSecond().getX()
|
||||||
+ blocking.getKey().getWidth();
|
+ blocking.getFirst().getWidth();
|
||||||
float overlapRight = Math.min(objectRight, blockingRight);
|
float overlapRight = Math.min(objectRight, blockingRight);
|
||||||
float overlapLeft = Math.max(position.getX(), blocking.getValue()
|
float overlapLeft = Math.max(position.getX(), blocking.getSecond()
|
||||||
.getX());
|
.getX());
|
||||||
float overlapX = overlapRight - overlapLeft;
|
float overlapX = overlapRight - overlapLeft;
|
||||||
float objectBottom = position.getY() + object.getHeight();
|
float objectBottom = position.getY() + object.getHeight();
|
||||||
float blockingBottom = blocking.getValue().getY()
|
float blockingBottom = blocking.getSecond().getY()
|
||||||
+ blocking.getKey().getHeight();
|
+ blocking.getFirst().getHeight();
|
||||||
float overlapBottom = Math.min(objectBottom, blockingBottom);
|
float overlapBottom = Math.min(objectBottom, blockingBottom);
|
||||||
float overlapTop = Math
|
float overlapTop = Math
|
||||||
.max(position.getY(), blocking.getValue().getY());
|
.max(position.getY(), blocking.getSecond().getY());
|
||||||
float overlapY = overlapBottom - overlapTop;
|
float overlapY = overlapBottom - overlapTop;
|
||||||
// vertical or horizontal Shift
|
// vertical or horizontal Shift
|
||||||
// TODO magic factor
|
// TODO magic factor
|
||||||
|
@ -178,33 +178,12 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Position getPosition(E object) {
|
public Position getPosition(E object) {
|
||||||
return objects.get(object);
|
return objects.get(object).getSecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Pair<E, Position>> iterator() {
|
public Iterator<Pair<E, Position>> iterator() {
|
||||||
final Iterator<Map.Entry<E, Position>> entryIterator = objects
|
return objects.values().iterator();
|
||||||
.entrySet().iterator();
|
|
||||||
return new Iterator<Pair<E, Position>>() {
|
|
||||||
Iterator<Map.Entry<E, Position>> iterator = entryIterator;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return iterator.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Pair<E, Position> next() {
|
|
||||||
Map.Entry<E, Position> entry = iterator.next();
|
|
||||||
return new Pair<E, Position>(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() {
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -227,7 +206,7 @@ public class StoneTray<E extends Sizeable> implements IStoneTray<E> {
|
||||||
public IStoneTray<E> clone() {
|
public IStoneTray<E> clone() {
|
||||||
try {
|
try {
|
||||||
StoneTray<E> copy = (StoneTray<E>) super.clone();
|
StoneTray<E> copy = (StoneTray<E>) super.clone();
|
||||||
copy.objects = (HashMap<E, Position>) objects.clone();
|
copy.objects = (HashMap<E, Pair<E, Position>>) objects.clone();
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
|
|
|
@ -28,8 +28,6 @@ public class Table extends StoneTray<StoneSet> implements ITable {
|
||||||
public Pair<StoneSet, StoneSet> pickUpStone(Stone stone) {
|
public Pair<StoneSet, StoneSet> pickUpStone(Stone stone) {
|
||||||
StoneInfo info = findStoneInfo(stone);
|
StoneInfo info = findStoneInfo(stone);
|
||||||
|
|
||||||
System.err.println("Stone: " + stone);
|
|
||||||
|
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -78,11 +76,7 @@ public class Table extends StoneTray<StoneSet> implements ITable {
|
||||||
pickUp(set);
|
pickUp(set);
|
||||||
|
|
||||||
Pair<StoneSet, StoneSet> firstSplit = set.splitAt(stonePosition);
|
Pair<StoneSet, StoneSet> firstSplit = set.splitAt(stonePosition);
|
||||||
System.err.println("Size: " + set.size());
|
|
||||||
System.err.println("stonePosition: " + stonePosition);
|
|
||||||
System.err.println("Frist split: " + firstSplit.getFirst() + " " + firstSplit.getSecond());
|
|
||||||
Pair<StoneSet, StoneSet> secondSplit = firstSplit.getSecond().splitAt(1);
|
Pair<StoneSet, StoneSet> secondSplit = firstSplit.getSecond().splitAt(1);
|
||||||
System.err.println("Second split: " + secondSplit.getFirst() + " " + secondSplit.getSecond());
|
|
||||||
|
|
||||||
StoneSet leftSet = firstSplit.getFirst();
|
StoneSet leftSet = firstSplit.getFirst();
|
||||||
StoneSet rightSet = secondSplit.getSecond();
|
StoneSet rightSet = secondSplit.getSecond();
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class RoundControlTest {
|
||||||
|
|
||||||
view.startTurnEvent.emit();
|
view.startTurnEvent.emit();
|
||||||
assertFalse(view.displayStartTurnPanel);
|
assertFalse(view.displayStartTurnPanel);
|
||||||
Stone stone = testGameState.players.get(0).hand.stones.remove(0);
|
Stone stone = testGameState.players.get(0).hand.stones.remove(0).getFirst();
|
||||||
newTable.drop(new StoneSet(stone), new Position(0, 0));
|
newTable.drop(new StoneSet(stone), new Position(0, 0));
|
||||||
resetTurnStart();
|
resetTurnStart();
|
||||||
view.getPlayerPanel().endTurnEvent.emit();
|
view.getPlayerPanel().endTurnEvent.emit();
|
||||||
|
@ -194,7 +194,7 @@ public class RoundControlTest {
|
||||||
|
|
||||||
view.startTurnEvent.emit();
|
view.startTurnEvent.emit();
|
||||||
assertFalse(view.displayStartTurnPanel);
|
assertFalse(view.displayStartTurnPanel);
|
||||||
Stone stone = testGameState.players.get(0).hand.stones.remove(0);
|
Stone stone = testGameState.players.get(0).hand.stones.remove(0).getFirst();
|
||||||
newTable.drop(new StoneSet(stone), new Position(0, 0));
|
newTable.drop(new StoneSet(stone), new Position(0, 0));
|
||||||
testGameState.players.get(0).hand.stones.clear();
|
testGameState.players.get(0).hand.stones.clear();
|
||||||
resetTurnStart();
|
resetTurnStart();
|
||||||
|
|
|
@ -10,8 +10,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import jrummikub.model.IHand;
|
||||||
|
import jrummikub.model.ITable;
|
||||||
import jrummikub.model.MockHand;
|
import jrummikub.model.MockHand;
|
||||||
import jrummikub.model.MockTable;
|
import jrummikub.model.MockTable;
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
|
@ -29,8 +32,8 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TurnControlTest {
|
public class TurnControlTest {
|
||||||
static class AccessibleTable extends Table{
|
static class AccessibleTable extends Table {
|
||||||
StoneSet[] getSetArray(){
|
StoneSet[] getSetArray() {
|
||||||
return objects.keySet().toArray(new StoneSet[0]);
|
return objects.keySet().toArray(new StoneSet[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +66,30 @@ public class TurnControlTest {
|
||||||
MockHand mockHand;
|
MockHand mockHand;
|
||||||
boolean eventFired;
|
boolean eventFired;
|
||||||
|
|
||||||
|
private void checkTableDisplay(ITable table) {
|
||||||
|
Iterator<Pair<StoneSet, Position>> stoneSetsView = mockView.tablePanel.stoneSets
|
||||||
|
.iterator();
|
||||||
|
Iterator<Pair<StoneSet, Position>> stoneSetsModel = table.iterator();
|
||||||
|
|
||||||
|
while (stoneSetsView.hasNext()) {
|
||||||
|
assertTrue(stoneSetsModel.hasNext());
|
||||||
|
assertSame(stoneSetsView.next(), stoneSetsModel.next());
|
||||||
|
}
|
||||||
|
assertFalse(stoneSetsModel.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkHandDisplay(IHand hand) {
|
||||||
|
Iterator<Pair<Stone, Position>> stoneSetsView = mockView.playerPanel.handPanel.stones
|
||||||
|
.iterator();
|
||||||
|
Iterator<Pair<Stone, Position>> stoneSetsModel = hand.iterator();
|
||||||
|
|
||||||
|
while (stoneSetsView.hasNext()) {
|
||||||
|
assertTrue(stoneSetsModel.hasNext());
|
||||||
|
assertSame(stoneSetsView.next(), stoneSetsModel.next());
|
||||||
|
}
|
||||||
|
assertFalse(stoneSetsModel.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockView = new MockView();
|
mockView = new MockView();
|
||||||
|
@ -70,28 +97,23 @@ public class TurnControlTest {
|
||||||
mockTable = new MockTable();
|
mockTable = new MockTable();
|
||||||
mockHand = new MockHand();
|
mockHand = new MockHand();
|
||||||
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
testControl = new TurnControl(mockHand, mockTable, mockView, mockTimer);
|
||||||
testControl.startTurn();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void startTimer() {
|
public void startTimer() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
assertTrue(mockTimer.timerRunning);
|
assertTrue(mockTimer.timerRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void showInitialHand() {
|
public void showInitialHand() {
|
||||||
mockView = new MockView();
|
|
||||||
mockTimer = new MockTimer();
|
|
||||||
mockTable = new MockTable();
|
|
||||||
mockHand = new MockHand();
|
|
||||||
|
|
||||||
mockView.displayStartTurnPanel = true;
|
mockView.displayStartTurnPanel = true;
|
||||||
|
|
||||||
List<Pair<Stone, Position>> stones = Arrays
|
List<Pair<Stone, Position>> stones = Arrays.asList(
|
||||||
.asList(new Pair<Stone, Position>(new Stone(RED), new Position(
|
new Pair<Stone, Position>(new Stone(RED), new Position(0, 0)),
|
||||||
0, 0)), new Pair<Stone, Position>(new Stone(BLACK),
|
new Pair<Stone, Position>(new Stone(BLACK), new Position(1, 0)));
|
||||||
new Position(1, 0)));
|
|
||||||
|
|
||||||
mockHand.iterable = stones;
|
mockHand.iterable = stones;
|
||||||
|
|
||||||
|
@ -111,6 +133,8 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void viewEndOfTurn() {
|
public void viewEndOfTurn() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
eventFired = false;
|
eventFired = false;
|
||||||
mockTimer.timerRunning = true;
|
mockTimer.timerRunning = true;
|
||||||
|
|
||||||
|
@ -131,6 +155,8 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timerEndOfTurn() {
|
public void timerEndOfTurn() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
eventFired = false;
|
eventFired = false;
|
||||||
mockTimer.timerRunning = true;
|
mockTimer.timerRunning = true;
|
||||||
|
|
||||||
|
@ -150,6 +176,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deselctOnEndOfTurn() {
|
public void deselctOnEndOfTurn() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
|
@ -162,6 +189,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectStoneInHand() {
|
public void selectStoneInHand() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
|
@ -180,6 +208,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collectStoneInHand() {
|
public void collectStoneInHand() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
|
@ -202,20 +231,23 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deselectStoneInCollection() {
|
public void deselectStoneInCollection() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
Stone secondStone = new Stone(StoneColor.BLACK);
|
Stone secondStone = new Stone(StoneColor.BLACK);
|
||||||
|
|
||||||
mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true);
|
mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true);
|
||||||
mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true);
|
mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true);
|
||||||
|
|
||||||
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(
|
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone,
|
||||||
firstStone, false);
|
false);
|
||||||
|
|
||||||
assertCollection(Arrays.asList(secondStone));
|
assertCollection(Arrays.asList(secondStone));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reorderCollection() {
|
public void reorderCollection() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
Stone secondStone = new Stone(StoneColor.BLACK);
|
Stone secondStone = new Stone(StoneColor.BLACK);
|
||||||
|
@ -223,14 +255,15 @@ public class TurnControlTest {
|
||||||
mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true);
|
mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true);
|
||||||
mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true);
|
mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true);
|
||||||
|
|
||||||
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(
|
mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit(firstStone,
|
||||||
firstStone, true);
|
true);
|
||||||
|
|
||||||
assertCollection(Arrays.asList(secondStone, firstStone));
|
assertCollection(Arrays.asList(secondStone, firstStone));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deselectWholeCollection() {
|
public void deselectWholeCollection() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
Stone secondStone = new Stone(StoneColor.BLACK);
|
Stone secondStone = new Stone(StoneColor.BLACK);
|
||||||
|
@ -246,6 +279,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectStoneOnTable() {
|
public void selectStoneOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
|
@ -264,6 +298,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collectStoneOnTable() {
|
public void collectStoneOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone firstStone = new Stone(StoneColor.RED);
|
Stone firstStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
|
@ -286,6 +321,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void selectSetOnTable() {
|
public void selectSetOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone stone1 = new Stone(StoneColor.RED);
|
Stone stone1 = new Stone(StoneColor.RED);
|
||||||
Stone stone2 = new Stone(StoneColor.BLACK);
|
Stone stone2 = new Stone(StoneColor.BLACK);
|
||||||
|
@ -305,6 +341,7 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collectSetOnTable() {
|
public void collectSetOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone stone1 = new Stone(StoneColor.RED);
|
Stone stone1 = new Stone(StoneColor.RED);
|
||||||
Stone stone2 = new Stone(StoneColor.BLACK);
|
Stone stone2 = new Stone(StoneColor.BLACK);
|
||||||
|
@ -324,13 +361,13 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeSelectOnTable() {
|
public void rangeSelectOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone stone1 = new Stone(1, StoneColor.RED);
|
Stone stone1 = new Stone(1, StoneColor.RED);
|
||||||
Stone stone2 = new Stone(2, StoneColor.RED);
|
Stone stone2 = new Stone(2, StoneColor.RED);
|
||||||
Stone stone3 = new Stone(3, StoneColor.RED);
|
Stone stone3 = new Stone(3, StoneColor.RED);
|
||||||
Stone stone4 = new Stone(4, StoneColor.RED);
|
Stone stone4 = new Stone(4, StoneColor.RED);
|
||||||
StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3,
|
StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4));
|
||||||
stone4));
|
|
||||||
|
|
||||||
mockTable.findStoneSet.put(stone1, set1);
|
mockTable.findStoneSet.put(stone1, set1);
|
||||||
mockTable.findStoneSet.put(stone3, set1);
|
mockTable.findStoneSet.put(stone3, set1);
|
||||||
|
@ -344,14 +381,15 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeCollectOnTable() {
|
public void rangeCollectOnTable() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone extraStone = new Stone(StoneColor.RED);
|
Stone extraStone = new Stone(StoneColor.RED);
|
||||||
|
|
||||||
Stone stone1 = new Stone(1, StoneColor.RED);
|
Stone stone1 = new Stone(1, StoneColor.RED);
|
||||||
Stone stone2 = new Stone(2, StoneColor.RED);
|
Stone stone2 = new Stone(2, StoneColor.RED);
|
||||||
Stone stone3 = new Stone(3, StoneColor.RED);
|
Stone stone3 = new Stone(3, StoneColor.RED);
|
||||||
Stone stone4 = new Stone(4, StoneColor.RED);
|
Stone stone4 = new Stone(4, StoneColor.RED);
|
||||||
StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3,
|
StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2, stone3, stone4));
|
||||||
stone4));
|
|
||||||
|
|
||||||
mockTable.findStoneSet.put(stone1, set1);
|
mockTable.findStoneSet.put(stone1, set1);
|
||||||
mockTable.findStoneSet.put(stone3, set1);
|
mockTable.findStoneSet.put(stone3, set1);
|
||||||
|
@ -366,6 +404,8 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeFailSelect() {
|
public void rangeFailSelect() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone stone1 = new Stone(1, StoneColor.RED);
|
Stone stone1 = new Stone(1, StoneColor.RED);
|
||||||
Stone stone2 = new Stone(2, StoneColor.RED);
|
Stone stone2 = new Stone(2, StoneColor.RED);
|
||||||
StoneSet set1 = new StoneSet(Arrays.asList(stone1));
|
StoneSet set1 = new StoneSet(Arrays.asList(stone1));
|
||||||
|
@ -388,6 +428,8 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeFailCollect() {
|
public void rangeFailCollect() {
|
||||||
|
testControl.startTurn();
|
||||||
|
|
||||||
Stone stone1 = new Stone(1, StoneColor.RED);
|
Stone stone1 = new Stone(1, StoneColor.RED);
|
||||||
Stone stone2 = new Stone(2, StoneColor.RED);
|
Stone stone2 = new Stone(2, StoneColor.RED);
|
||||||
StoneSet set1 = new StoneSet(Arrays.asList(stone1));
|
StoneSet set1 = new StoneSet(Arrays.asList(stone1));
|
||||||
|
@ -416,8 +458,9 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddLeft() {
|
public void testAddLeft() {
|
||||||
AccessibleTable table=new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
TurnControl turnControl=new TurnControl(mockHand, table, mockView, mockTimer);
|
TurnControl turnControl = new TurnControl(mockHand, table, mockView,
|
||||||
|
mockTimer);
|
||||||
turnControl.startTurn();
|
turnControl.startTurn();
|
||||||
Stone blueOne = new Stone(1, BLUE);
|
Stone blueOne = new Stone(1, BLUE);
|
||||||
Stone redOne = new Stone(1, RED);
|
Stone redOne = new Stone(1, RED);
|
||||||
|
@ -432,10 +475,10 @@ public class TurnControlTest {
|
||||||
Stone blackThree = new Stone(3, BLACK);
|
Stone blackThree = new Stone(3, BLACK);
|
||||||
Stone blackFour = new Stone(4, BLACK);
|
Stone blackFour = new Stone(4, BLACK);
|
||||||
Stone blackFive = new Stone(5, BLACK);
|
Stone blackFive = new Stone(5, BLACK);
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(
|
||||||
blackFive));
|
Arrays.asList(blueTwo, blackFour, blackFive));
|
||||||
table.drop(oldSet1, new Position(0, 0));
|
table.drop(oldSet1, new Position(0, 0));
|
||||||
table.drop(oldSet2, new Position(0, 0));
|
table.drop(oldSet2, new Position(0, 0));
|
||||||
mockHand.drop(blueThree, new Position(0, 0));
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
|
@ -446,7 +489,7 @@ public class TurnControlTest {
|
||||||
mockView.tablePanel.leftConnectorClickEvent.emit(oldSet1);
|
mockView.tablePanel.leftConnectorClickEvent.emit(oldSet1);
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(mockHand.stones.get(0), blueFour);
|
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
|
||||||
// tablecheck
|
// tablecheck
|
||||||
assertEquals(2, table.getSize());
|
assertEquals(2, table.getSize());
|
||||||
StoneSet newSet1, newSet2;
|
StoneSet newSet1, newSet2;
|
||||||
|
@ -475,12 +518,12 @@ public class TurnControlTest {
|
||||||
mockView.tablePanel.leftConnectorClickEvent.emit(oldSet2);
|
mockView.tablePanel.leftConnectorClickEvent.emit(oldSet2);
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(mockHand.stones.get(0), blueFour);
|
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
|
||||||
// tablecheck
|
// tablecheck
|
||||||
assertEquals(2, table.getSize());
|
assertEquals(2, table.getSize());
|
||||||
if (table.getSetArray()[0].size() == 5) {
|
if (table.getSetArray()[0].size() == 5) {
|
||||||
newSet2 =table.getSetArray()[0];
|
newSet2 = table.getSetArray()[0];
|
||||||
newSet1 =table.getSetArray()[1];
|
newSet1 = table.getSetArray()[1];
|
||||||
} else {
|
} else {
|
||||||
newSet1 = table.getSetArray()[0];
|
newSet1 = table.getSetArray()[0];
|
||||||
newSet2 = table.getSetArray()[1];
|
newSet2 = table.getSetArray()[1];
|
||||||
|
@ -529,8 +572,9 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddRight() {
|
public void testAddRight() {
|
||||||
AccessibleTable table=new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
TurnControl turnControl=new TurnControl(mockHand, table, mockView, mockTimer);
|
TurnControl turnControl = new TurnControl(mockHand, table, mockView,
|
||||||
|
mockTimer);
|
||||||
turnControl.startTurn();
|
turnControl.startTurn();
|
||||||
Stone blueOne = new Stone(1, BLUE);
|
Stone blueOne = new Stone(1, BLUE);
|
||||||
Stone redOne = new Stone(1, RED);
|
Stone redOne = new Stone(1, RED);
|
||||||
|
@ -545,10 +589,10 @@ public class TurnControlTest {
|
||||||
Stone blackThree = new Stone(3, BLACK);
|
Stone blackThree = new Stone(3, BLACK);
|
||||||
Stone blackFour = new Stone(4, BLACK);
|
Stone blackFour = new Stone(4, BLACK);
|
||||||
Stone blackFive = new Stone(5, BLACK);
|
Stone blackFive = new Stone(5, BLACK);
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(
|
||||||
blackFive));
|
Arrays.asList(blueTwo, blackFour, blackFive));
|
||||||
table.drop(oldSet1, new Position(0, 0));
|
table.drop(oldSet1, new Position(0, 0));
|
||||||
table.drop(oldSet2, new Position(0, 0));
|
table.drop(oldSet2, new Position(0, 0));
|
||||||
mockHand.drop(blueThree, new Position(0, 0));
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
|
@ -559,7 +603,7 @@ public class TurnControlTest {
|
||||||
mockView.tablePanel.rightConnectorClickEvent.emit(oldSet1);
|
mockView.tablePanel.rightConnectorClickEvent.emit(oldSet1);
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(mockHand.stones.get(0), blueFour);
|
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
|
||||||
// tablecheck
|
// tablecheck
|
||||||
assertEquals(2, table.getSize());
|
assertEquals(2, table.getSize());
|
||||||
StoneSet newSet1, newSet2;
|
StoneSet newSet1, newSet2;
|
||||||
|
@ -588,7 +632,7 @@ public class TurnControlTest {
|
||||||
mockView.tablePanel.rightConnectorClickEvent.emit(oldSet2);
|
mockView.tablePanel.rightConnectorClickEvent.emit(oldSet2);
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(mockHand.stones.get(0), blueFour);
|
assertSame(mockHand.stones.get(0).getFirst(), blueFour);
|
||||||
// tablecheck
|
// tablecheck
|
||||||
assertEquals(2, table.getSize());
|
assertEquals(2, table.getSize());
|
||||||
if (table.getSetArray()[0].size() == 5) {
|
if (table.getSetArray()[0].size() == 5) {
|
||||||
|
@ -642,8 +686,9 @@ public class TurnControlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddNewSet() {
|
public void testAddNewSet() {
|
||||||
AccessibleTable table=new AccessibleTable();
|
AccessibleTable table = new AccessibleTable();
|
||||||
TurnControl turnControl=new TurnControl(mockHand, table, mockView, mockTimer);
|
TurnControl turnControl = new TurnControl(mockHand, table, mockView,
|
||||||
|
mockTimer);
|
||||||
turnControl.startTurn();
|
turnControl.startTurn();
|
||||||
Stone blueOne = new Stone(1, BLUE);
|
Stone blueOne = new Stone(1, BLUE);
|
||||||
Stone redOne = new Stone(1, RED);
|
Stone redOne = new Stone(1, RED);
|
||||||
|
@ -658,10 +703,10 @@ public class TurnControlTest {
|
||||||
Stone blackThree = new Stone(3, BLACK);
|
Stone blackThree = new Stone(3, BLACK);
|
||||||
Stone blackFour = new Stone(4, BLACK);
|
Stone blackFour = new Stone(4, BLACK);
|
||||||
Stone blackFive = new Stone(5, BLACK);
|
Stone blackFive = new Stone(5, BLACK);
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
|
||||||
blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
|
redTwo, redThree, redFour, blackTwo, blackThree));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
|
StoneSet oldSet2 = new StoneSet(
|
||||||
blackFive));
|
Arrays.asList(blueTwo, blackFour, blackFive));
|
||||||
table.drop(oldSet1, new Position(0, 0));
|
table.drop(oldSet1, new Position(0, 0));
|
||||||
table.drop(oldSet2, new Position(0, 0));
|
table.drop(oldSet2, new Position(0, 0));
|
||||||
mockHand.drop(blueThree, new Position(0, 0));
|
mockHand.drop(blueThree, new Position(0, 0));
|
||||||
|
@ -673,10 +718,10 @@ public class TurnControlTest {
|
||||||
mockView.tablePanel.clickEvent.emit(new Position(0, 0));
|
mockView.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
// handcheck
|
// handcheck
|
||||||
assertEquals(1, mockHand.getSize());
|
assertEquals(1, mockHand.getSize());
|
||||||
assertSame(blueFour, mockHand.stones.get(0));
|
assertSame(blueFour, mockHand.stones.get(0).getFirst());
|
||||||
// tablecheck
|
// tablecheck
|
||||||
StoneSet newSet1, newSet2, newSet3;
|
StoneSet newSet1, newSet2, newSet3;
|
||||||
assertEquals(2, table.getSize());
|
assertEquals(3, table.getSize());
|
||||||
if (table.getSetArray()[0].size() == 2) {
|
if (table.getSetArray()[0].size() == 2) {
|
||||||
newSet2 = table.getSetArray()[0];
|
newSet2 = table.getSetArray()[0];
|
||||||
if (table.getSetArray()[1].size() == 4) {
|
if (table.getSetArray()[1].size() == 4) {
|
||||||
|
@ -701,7 +746,7 @@ public class TurnControlTest {
|
||||||
newSet2 = table.getSetArray()[1];
|
newSet2 = table.getSetArray()[1];
|
||||||
newSet3 = table.getSetArray()[2];
|
newSet3 = table.getSetArray()[2];
|
||||||
} else {
|
} else {
|
||||||
newSet2 =table.getSetArray()[2];
|
newSet2 = table.getSetArray()[2];
|
||||||
newSet3 = table.getSetArray()[1];
|
newSet3 = table.getSetArray()[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,5 +769,8 @@ public class TurnControlTest {
|
||||||
assertSame(newSet3.get(1), redOne);
|
assertSame(newSet3.get(1), redOne);
|
||||||
assertSame(newSet3.get(2), redThree);
|
assertSame(newSet3.get(2), redThree);
|
||||||
assertSame(newSet3.get(3), blueTwo);
|
assertSame(newSet3.get(3), blueTwo);
|
||||||
|
|
||||||
|
checkTableDisplay(table);
|
||||||
|
checkHandDisplay(mockHand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue