Always operate on cloned hands in the turn controls
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@380 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
c59332950b
commit
af3661fea0
11 changed files with 157 additions and 84 deletions
|
@ -42,4 +42,9 @@ public class MockPlayer implements IPlayer {
|
|||
public void setLaidOut(boolean laidOut) {
|
||||
this.laidOut = laidOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHand(IHand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class RoundControl {
|
|||
IRoundState roundState;
|
||||
private IView view;
|
||||
private ITable clonedTable;
|
||||
IHand clonedHand;
|
||||
private Event restartRoundEvent = new Event();
|
||||
private Event1<Score> endOfRoundEvent = new Event1<Score>();
|
||||
private List<Connection> connections = new ArrayList<Connection>();
|
||||
|
@ -84,6 +85,7 @@ public class RoundControl {
|
|||
boolean isHuman = roundState.getActivePlayer().getPlayerSettings()
|
||||
.getTurnControlType() == HUMAN;
|
||||
clonedTable = (ITable) roundState.getTable().clone();
|
||||
clonedHand = (IHand) roundState.getActivePlayer().getHand().clone();
|
||||
|
||||
view.setBottomPanel(isHuman ? BottomPanelType.START_TURN_PANEL
|
||||
: BottomPanelType.COMPUTER_HAND_PANEL);
|
||||
|
@ -109,7 +111,7 @@ public class RoundControl {
|
|||
|
||||
if (roundState.getTurnNumber() < 1) {
|
||||
turnMode = TurnMode.INSPECT_ONLY;
|
||||
if (roundState.getActivePlayer().getHand().getIdenticalStoneCount() >= 3) {
|
||||
if (clonedHand.getIdenticalStoneCount() >= 3) {
|
||||
turnMode = TurnMode.MAY_REDEAL;
|
||||
}
|
||||
}
|
||||
|
@ -120,8 +122,9 @@ public class RoundControl {
|
|||
turnControl = TurnControlFactory.getFactory(
|
||||
roundState.getActivePlayer().getPlayerSettings().getTurnControlType())
|
||||
.create();
|
||||
turnControl.setup(roundState.getGameSettings(),
|
||||
roundState.getActivePlayer(), clonedTable, view, turnMode);
|
||||
turnControl.setup(new ITurnControl.TurnInfo(clonedTable, clonedHand,
|
||||
roundState.getActivePlayer().getLaidOut(), turnMode), roundState
|
||||
.getGameSettings(), view);
|
||||
turnControl.getEndOfTurnEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
|
@ -189,6 +192,8 @@ public class RoundControl {
|
|||
}
|
||||
|
||||
private void checkTurn() {
|
||||
roundState.getActivePlayer().setHand(clonedHand);
|
||||
|
||||
if (!clonedTable.isValid()) {
|
||||
rejectMove();
|
||||
return;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package jrummikub.control.turn;
|
||||
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.IPlayer;
|
||||
import jrummikub.model.ITable;
|
||||
import jrummikub.util.Event;
|
||||
import jrummikub.util.IEvent;
|
||||
import jrummikub.view.IView;
|
||||
|
@ -14,11 +12,9 @@ public abstract class AbstractTurnControl implements ITurnControl {
|
|||
|
||||
protected Event endOfTurnEvent = new Event();
|
||||
protected Event redealEvent = new Event();
|
||||
protected TurnInfo turnInfo;
|
||||
protected GameSettings settings;
|
||||
protected IPlayer player;
|
||||
protected ITable table;
|
||||
protected IView view;
|
||||
protected TurnMode turnMode;
|
||||
|
||||
@Override
|
||||
public IEvent getEndOfTurnEvent() {
|
||||
|
@ -31,13 +27,10 @@ public abstract class AbstractTurnControl implements ITurnControl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setup(GameSettings settings, IPlayer player, ITable table,
|
||||
IView view, TurnMode turnMode) {
|
||||
public void setup(TurnInfo info, GameSettings settings, IView view) {
|
||||
turnInfo = info;
|
||||
this.settings = settings;
|
||||
this.player = player;
|
||||
this.table = table;
|
||||
this.view = view;
|
||||
this.turnMode = turnMode;
|
||||
}
|
||||
|
||||
}
|
|
@ -63,7 +63,7 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
}
|
||||
|
||||
private void compute() {
|
||||
switch (turnMode) {
|
||||
switch (turnInfo.getTurnMode()) {
|
||||
case MAY_REDEAL:
|
||||
emitRedeal();
|
||||
break;
|
||||
|
@ -77,14 +77,14 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
}
|
||||
|
||||
private Stone findMatchingStone(Stone target) {
|
||||
for (Pair<Stone, Position> entry : player.getHand()) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
Stone stone = entry.getFirst();
|
||||
if (stone.getValue() == target.getValue()
|
||||
&& stone.getColor() == target.getColor()) {
|
||||
return stone;
|
||||
}
|
||||
}
|
||||
for (Pair<Stone, Position> entry : player.getHand()) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
Stone stone = entry.getFirst();
|
||||
if (stone.isJoker()) {
|
||||
return stone;
|
||||
|
@ -95,14 +95,14 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
|
||||
private Stone pickUpMatchingStone(Stone target) {
|
||||
Stone match = findMatchingStone(target);
|
||||
player.getHand().pickUp(match);
|
||||
turnInfo.getHand().pickUp(match);
|
||||
return match;
|
||||
}
|
||||
|
||||
private void turn() {
|
||||
List<Stone> stones = new ArrayList<Stone>();
|
||||
|
||||
for (Pair<Stone, Position> entry : player.getHand()) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
stones.add(entry.getFirst());
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
Math.max(30, settings.getInitialMeldThreshold() * 2),
|
||||
counts.getFirst(), counts.getSecond());
|
||||
|
||||
if (!player.getLaidOut()
|
||||
if (!turnInfo.getLaidOut()
|
||||
&& result.getSecond() < settings.getInitialMeldThreshold()) {
|
||||
emitEndOfTurn();
|
||||
return;
|
||||
|
@ -126,7 +126,7 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
for (Stone stone : set) {
|
||||
handStones.add(pickUpMatchingStone(stone));
|
||||
}
|
||||
table.drop(new StoneSet(handStones), new Position(
|
||||
turnInfo.getTable().drop(new StoneSet(handStones), new Position(
|
||||
(float) Math.random() * 30 - 15, (float) Math.random() * 6 - 3));
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class BaseAIControl extends AbstractTurnControl {
|
|||
private void emitEndOfTurn() {
|
||||
long timeElapsed = System.currentTimeMillis() - startTime;
|
||||
long timeNeeded = Math.min((long) (1000 + Math.random()
|
||||
* player.getHand().getSize() * 100), 50000);
|
||||
* turnInfo.getHand().getSize() * 100), 50000);
|
||||
long waitTime = timeNeeded - timeElapsed;
|
||||
|
||||
if (waitTime > 0) {
|
||||
|
|
|
@ -73,11 +73,11 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
addHandPanelHandlers();
|
||||
addStoneCollectionHandlers();
|
||||
|
||||
if (turnMode == TurnMode.NORMAL_TURN) {
|
||||
if (turnInfo.getTurnMode() == TurnMode.NORMAL_TURN) {
|
||||
addTablePanelHandlers();
|
||||
}
|
||||
|
||||
view.getHandPanel().setStones(player.getHand().clone());
|
||||
view.getHandPanel().setStones(turnInfo.getHand().clone());
|
||||
view.getHandPanel().resetCurrentRow();
|
||||
view.setBottomPanel(BottomPanelType.HUMAN_HAND_PANEL);
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
private void handClick(Position pos) {
|
||||
List<Stone> handStones = new ArrayList<Stone>();
|
||||
for (Stone s : selectedStones) {
|
||||
if (player.getHand().pickUp(s)) {
|
||||
if (turnInfo.getHand().pickUp(s)) {
|
||||
handStones.add(s);
|
||||
}
|
||||
}
|
||||
|
@ -236,28 +236,28 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
for (Stone s : handStones) {
|
||||
double x = Math.max(0,
|
||||
Math.min(13, pos.getX() - handStones.size() / 2.0f + i));
|
||||
player.getHand().drop(s,
|
||||
turnInfo.getHand().drop(s,
|
||||
new Position(x, (float) Math.floor(pos.getY())));
|
||||
selectedStones.remove(s);
|
||||
i++;
|
||||
}
|
||||
view.setSelectedStones(selectedStones);
|
||||
view.getHandPanel().setStones(player.getHand());
|
||||
view.getHandPanel().setStones(turnInfo.getHand());
|
||||
}
|
||||
|
||||
private void sortStones(Comparator<Stone> comparator) {
|
||||
List<Stone> stones = new ArrayList<Stone>();
|
||||
for (Pair<Stone, Position> entry : player.getHand()) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
stones.add(entry.getFirst());
|
||||
}
|
||||
for (Stone stone : stones) {
|
||||
player.getHand().pickUp(stone);
|
||||
turnInfo.getHand().pickUp(stone);
|
||||
}
|
||||
|
||||
Collections.sort(stones, comparator);
|
||||
int x = 0, y = 0;
|
||||
for (Stone stone : stones) {
|
||||
player.getHand().drop(stone, new Position(x, y));
|
||||
turnInfo.getHand().drop(stone, new Position(x, y));
|
||||
x++;
|
||||
if (x >= Hand.WIDTH) {
|
||||
x = 0;
|
||||
|
@ -265,7 +265,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
}
|
||||
}
|
||||
|
||||
view.getHandPanel().setStones(player.getHand());
|
||||
view.getHandPanel().setStones(turnInfo.getHand());
|
||||
}
|
||||
|
||||
private void sortByRuns() {
|
||||
|
@ -306,8 +306,8 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
|
||||
private void pickUpSelectedStones() {
|
||||
for (Stone stone : selectedStones) {
|
||||
player.getHand().pickUp(stone);
|
||||
table.pickUpStone(stone);
|
||||
turnInfo.getHand().pickUp(stone);
|
||||
turnInfo.getTable().pickUpStone(stone);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,12 +317,12 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
}
|
||||
|
||||
pickUpSelectedStones();
|
||||
table.drop(new StoneSet(selectedStones), new Position(position.getX()
|
||||
turnInfo.getTable().drop(new StoneSet(selectedStones), new Position(position.getX()
|
||||
- selectedStones.size() * 0.5f, position.getY() - 0.5f));
|
||||
selectedStones.clear();
|
||||
|
||||
view.getTablePanel().setStoneSets(table);
|
||||
view.getHandPanel().setStones(player.getHand());
|
||||
view.getTablePanel().setStoneSets(turnInfo.getTable());
|
||||
view.getHandPanel().setStones(turnInfo.getHand());
|
||||
view.setSelectedStones(selectedStones);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
if (!collect) {
|
||||
selectedStones.clear();
|
||||
}
|
||||
StoneSet selectedSet = table.findStoneSet(stone);
|
||||
StoneSet selectedSet = turnInfo.getTable().findStoneSet(stone);
|
||||
for (Stone setStone : selectedSet) {
|
||||
selectedStones.remove(setStone);
|
||||
selectedStones.add(setStone);
|
||||
|
@ -344,8 +344,8 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
return;
|
||||
}
|
||||
Stone lastStone = selectedStones.get(selectedStones.size() - 1);
|
||||
StoneSet lastSet = table.findStoneSet(lastStone);
|
||||
StoneSet selectedSet = table.findStoneSet(stone);
|
||||
StoneSet lastSet = turnInfo.getTable().findStoneSet(lastStone);
|
||||
StoneSet selectedSet = turnInfo.getTable().findStoneSet(stone);
|
||||
if (lastSet != selectedSet) {
|
||||
stoneClick(stone, true);
|
||||
return;
|
||||
|
@ -376,13 +376,13 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
return;
|
||||
}
|
||||
Stone lastStone = selectedStones.get(selectedStones.size() - 1);
|
||||
StoneSet lastSet = table.findStoneSet(lastStone);
|
||||
StoneSet lastSet = turnInfo.getTable().findStoneSet(lastStone);
|
||||
if (lastSet != null) {
|
||||
stoneClick(stone, true);
|
||||
return;
|
||||
}
|
||||
List<Pair<Stone, Position>> handPairs = new ArrayList<Pair<Stone, Position>>();
|
||||
for (Pair<Stone, Position> entry : player.getHand()) {
|
||||
for (Pair<Stone, Position> entry : turnInfo.getHand()) {
|
||||
handPairs.add(entry);
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
|
||||
private void connectorClick(StoneSet set, boolean right) {
|
||||
List<Stone> stones = new LinkedList<Stone>();
|
||||
Position pos = table.getPosition(set);
|
||||
Position pos = turnInfo.getTable().getPosition(set);
|
||||
for (Stone stone : set) {
|
||||
stones.add(stone);
|
||||
}
|
||||
|
@ -421,24 +421,24 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
pickUpSelectedStones();
|
||||
StoneSet newSet = null;
|
||||
for (Stone stone : stones) {
|
||||
newSet = table.findStoneSet(stone);
|
||||
newSet = turnInfo.getTable().findStoneSet(stone);
|
||||
if (newSet != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newSet != null) {
|
||||
Position newPos = table.getPosition(newSet);
|
||||
table.pickUp(newSet);
|
||||
Position newPos = turnInfo.getTable().getPosition(newSet);
|
||||
turnInfo.getTable().pickUp(newSet);
|
||||
if (right) {
|
||||
StoneSet joinedSet = newSet.join(new StoneSet(selectedStones));
|
||||
table.drop(joinedSet, newPos);
|
||||
turnInfo.getTable().drop(joinedSet, newPos);
|
||||
} else {
|
||||
StoneSet joinedSet = new StoneSet(selectedStones).join(newSet);
|
||||
table.drop(joinedSet, new Position(newPos.getX()
|
||||
turnInfo.getTable().drop(joinedSet, new Position(newPos.getX()
|
||||
- selectedStones.size(), newPos.getY()));
|
||||
}
|
||||
} else {
|
||||
table.drop(
|
||||
turnInfo.getTable().drop(
|
||||
new StoneSet(selectedStones),
|
||||
new Position(pos.getX()
|
||||
+ (set.getSize() - selectedStones.size()) * 0.5f,
|
||||
|
@ -447,8 +447,8 @@ public class HumanTurnControl extends AbstractTurnControl {
|
|||
|
||||
selectedStones.clear();
|
||||
|
||||
view.getTablePanel().setStoneSets(table);
|
||||
view.getHandPanel().setStones(player.getHand());
|
||||
view.getTablePanel().setStoneSets(turnInfo.getTable());
|
||||
view.getHandPanel().setStones(turnInfo.getHand());
|
||||
view.setSelectedStones(selectedStones);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package jrummikub.control.turn;
|
||||
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.IPlayer;
|
||||
import jrummikub.model.IHand;
|
||||
import jrummikub.model.ITable;
|
||||
import jrummikub.util.IEvent;
|
||||
import jrummikub.view.IView;
|
||||
|
@ -14,19 +14,15 @@ public interface ITurnControl {
|
|||
/**
|
||||
* Start the turn
|
||||
*
|
||||
* @param info
|
||||
* the current turn state
|
||||
*
|
||||
* @param settings
|
||||
* the game settings
|
||||
* @param player
|
||||
* the active player
|
||||
* @param table
|
||||
* current table
|
||||
* @param view
|
||||
* view for user interaction.
|
||||
* @param turnMode
|
||||
* whether it is turn zero and if one may redeal
|
||||
*/
|
||||
public void setup(GameSettings settings, IPlayer player, ITable table,
|
||||
IView view, TurnMode turnMode);
|
||||
public void setup(TurnInfo info, GameSettings settings, IView view);
|
||||
|
||||
/**
|
||||
* Get the event that is emitted when the turn is over
|
||||
|
@ -45,6 +41,71 @@ public interface ITurnControl {
|
|||
/**
|
||||
* Start the turn
|
||||
*/
|
||||
public abstract void startTurn();
|
||||
public void startTurn();
|
||||
|
||||
/**
|
||||
* The TurnInfo class encapsulates all information concerning the current turn
|
||||
*/
|
||||
public class TurnInfo {
|
||||
private ITable table;
|
||||
private IHand hand;
|
||||
private boolean hasLaidOut;
|
||||
private TurnMode turnMode;
|
||||
|
||||
/**
|
||||
* Creates a new TurnInfo instance
|
||||
*
|
||||
* @param table
|
||||
* the current table
|
||||
* @param hand
|
||||
* the current player's hand
|
||||
* @param hasLaidOut
|
||||
* has the player laid out yet?
|
||||
* @param turnMode
|
||||
* the turn mode
|
||||
*/
|
||||
public TurnInfo(ITable table, IHand hand, boolean hasLaidOut,
|
||||
TurnMode turnMode) {
|
||||
this.table = table;
|
||||
this.hand = hand;
|
||||
this.hasLaidOut = hasLaidOut;
|
||||
this.turnMode = turnMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current table
|
||||
*
|
||||
* @return the table
|
||||
*/
|
||||
public ITable getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current player's hand
|
||||
*
|
||||
* @return the hand
|
||||
*/
|
||||
public IHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the current player has laid out yet
|
||||
*
|
||||
* @return if the player has laid out
|
||||
*/
|
||||
public boolean getLaidOut() {
|
||||
return hasLaidOut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current turn's mode
|
||||
*
|
||||
* @return the turn mode
|
||||
*/
|
||||
public TurnMode getTurnMode() {
|
||||
return turnMode;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,6 +12,13 @@ public interface IPlayer {
|
|||
*/
|
||||
public IHand getHand();
|
||||
|
||||
/**
|
||||
* Set the current hand of the player
|
||||
*
|
||||
* @param hand the new hand
|
||||
*/
|
||||
public void setHand(IHand hand);
|
||||
|
||||
/**
|
||||
* Has the player laid out yet?
|
||||
*
|
||||
|
|
|
@ -24,6 +24,11 @@ public class Player implements IPlayer {
|
|||
return hand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHand(IHand hand) {
|
||||
this.hand = hand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getLaidOut() {
|
||||
return laidOut;
|
||||
|
|
|
@ -147,7 +147,7 @@ public class RoundControlTest {
|
|||
Stone blueTwo = new Stone(2, BLUE);
|
||||
Stone blueThree = new Stone(3, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueOne, new Position(0, 0));
|
||||
hand.drop(blueTwo, new Position(0, 0));
|
||||
hand.drop(blueThree, new Position(0, 0));
|
||||
|
@ -177,7 +177,7 @@ public class RoundControlTest {
|
|||
}
|
||||
view.startTurnEvent.emit();
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
|
||||
assertFalse(roundState.getActivePlayer().getLaidOut());
|
||||
|
||||
|
@ -202,7 +202,7 @@ public class RoundControlTest {
|
|||
Stone blueTwo = new Stone(2, BLUE);
|
||||
Stone blueThree = new Stone(3, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueOne, new Position(0, 0));
|
||||
hand.drop(blueTwo, new Position(0, 0));
|
||||
hand.drop(blueThree, new Position(0, 0));
|
||||
|
@ -255,7 +255,7 @@ public class RoundControlTest {
|
|||
Stone blueTwo = new Stone(2, BLUE);
|
||||
Stone blueThree = new Stone(3, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueOne, new Position(0, 0));
|
||||
hand.drop(blueTwo, new Position(0, 0));
|
||||
hand.drop(blueThree, new Position(0, 0));
|
||||
|
@ -286,7 +286,7 @@ public class RoundControlTest {
|
|||
Stone redNine = new Stone(9, RED);
|
||||
Stone redTen = new Stone(10, RED);
|
||||
|
||||
hand = roundState.getActivePlayer().getHand();
|
||||
hand = roundControl.clonedHand;
|
||||
hand.drop(redEight, new Position(0, 0));
|
||||
hand.drop(redNine, new Position(0, 0));
|
||||
hand.drop(redTen, new Position(0, 0));
|
||||
|
@ -326,7 +326,7 @@ public class RoundControlTest {
|
|||
Stone blueTwo = new Stone(2, BLUE);
|
||||
Stone blueThree = new Stone(3, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueOne, new Position(0, 0));
|
||||
hand.drop(blueTwo, new Position(0, 0));
|
||||
hand.drop(blueThree, new Position(0, 0));
|
||||
|
@ -358,7 +358,7 @@ public class RoundControlTest {
|
|||
Stone redTen = new Stone(10, RED);
|
||||
Stone redEleven = new Stone(11, RED);
|
||||
|
||||
hand = roundState.getActivePlayer().getHand();
|
||||
hand = roundControl.clonedHand;
|
||||
hand.drop(redEight, new Position(0, 0));
|
||||
hand.drop(redNine, new Position(0, 0));
|
||||
hand.drop(redTen, new Position(0, 0));
|
||||
|
@ -400,7 +400,7 @@ public class RoundControlTest {
|
|||
Stone blueSix = new Stone(6, BLUE);
|
||||
Stone blueSeven = new Stone(7, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueFive, new Position(0, 0));
|
||||
hand.drop(blueSix, new Position(0, 0));
|
||||
hand.drop(blueSeven, new Position(0, 0));
|
||||
|
@ -427,7 +427,7 @@ public class RoundControlTest {
|
|||
assertEquals(2, roundState.getTable().getSize());
|
||||
view.startTurnEvent.emit();
|
||||
|
||||
hand = roundState.getActivePlayer().getHand();
|
||||
hand = roundControl.clonedHand;
|
||||
|
||||
view.tablePanel.stoneClickEvent.emit(blueFour, false);
|
||||
view.tablePanel.stoneClickEvent.emit(blueFive, true);
|
||||
|
@ -464,7 +464,7 @@ public class RoundControlTest {
|
|||
Stone blueTwo = new Stone(2, BLUE);
|
||||
Stone blueThree = new Stone(3, BLUE);
|
||||
|
||||
IHand hand = roundState.getActivePlayer().getHand();
|
||||
IHand hand = roundControl.clonedHand;
|
||||
hand.drop(blueOne, new Position(0, 0));
|
||||
hand.drop(blueTwo, new Position(0, 0));
|
||||
hand.drop(blueThree, new Position(0, 0));
|
||||
|
@ -573,7 +573,7 @@ public class RoundControlTest {
|
|||
|
||||
view.startTurnEvent.emit();
|
||||
assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType);
|
||||
IHand hand = testRoundState.players.get(0).hand;
|
||||
IHand hand = testRound.clonedHand;
|
||||
Stone stone = hand.iterator().next().getFirst();
|
||||
hand.pickUp(stone);
|
||||
testTable.drop(new StoneSet(stone), new Position(0, 0));
|
||||
|
@ -658,7 +658,7 @@ public class RoundControlTest {
|
|||
|
||||
view.startTurnEvent.emit();
|
||||
assertSame(BottomPanelType.HUMAN_HAND_PANEL, view.bottomPanelType);
|
||||
IHand hand = testRoundState.players.get(0).hand;
|
||||
IHand hand = testRound.clonedHand;
|
||||
|
||||
Stone blueEight = new Stone(8, BLUE);
|
||||
Stone blackEight = new Stone(8, BLACK);
|
||||
|
@ -680,6 +680,7 @@ public class RoundControlTest {
|
|||
for (int i = 0; i < 4; i++) {
|
||||
testRoundState.players.get(i).hand = new Hand();
|
||||
}
|
||||
testRound.clonedHand = (IHand) testRoundState.players.get(3).hand.clone();
|
||||
resetTurnStart();
|
||||
|
||||
assertFalse(roundEnded);
|
||||
|
@ -952,6 +953,7 @@ public class RoundControlTest {
|
|||
hand.drop(new Stone(i / 2, RED), new Position(0, 0));
|
||||
}
|
||||
testRoundState.players.get(0).hand = hand;
|
||||
testRound.clonedHand = (IHand) hand.clone();
|
||||
view.startTurnEvent.emit();
|
||||
assertEquals(view.playerPanel.turnMode, TurnMode.MAY_REDEAL);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
|
|
@ -75,7 +75,7 @@ public class BaseAIControlTest {
|
|||
*/
|
||||
@Test(timeout = 10000)
|
||||
public void testTurnZeroRedealing() throws InterruptedException {
|
||||
aiControl.setup(gameSettings, player, table, view, TurnMode.MAY_REDEAL);
|
||||
aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.MAY_REDEAL), gameSettings, view);
|
||||
aiControl.startTurn();
|
||||
while (!redealt) {
|
||||
Thread.sleep(100);
|
||||
|
@ -89,7 +89,7 @@ public class BaseAIControlTest {
|
|||
*/
|
||||
@Test(timeout = 10000)
|
||||
public void testTurnZeroNotMelding() throws InterruptedException {
|
||||
aiControl.setup(gameSettings, player, table, view, TurnMode.INSPECT_ONLY);
|
||||
aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.INSPECT_ONLY), gameSettings, view);
|
||||
aiControl.startTurn();
|
||||
while (!turnEnded) {
|
||||
Thread.sleep(100);
|
||||
|
@ -103,7 +103,7 @@ public class BaseAIControlTest {
|
|||
*/
|
||||
@Test(timeout = 10000)
|
||||
public void testNormalTurnMelding() throws InterruptedException {
|
||||
aiControl.setup(gameSettings, player, table, view, TurnMode.NORMAL_TURN);
|
||||
aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.NORMAL_TURN), gameSettings, view);
|
||||
aiControl.startTurn();
|
||||
while (!turnEnded) {
|
||||
Thread.sleep(100);
|
||||
|
|
|
@ -110,8 +110,7 @@ public class TurnControlTest {
|
|||
mockPlayer = new MockPlayer(null, null);
|
||||
mockPlayer.hand = mockHand;
|
||||
testControl = new HumanTurnControl(mockTimer);
|
||||
testControl.setup(new GameSettings(), mockPlayer, mockTable, mockView,
|
||||
TurnMode.NORMAL_TURN);
|
||||
testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||
}
|
||||
|
||||
/** */
|
||||
|
@ -135,8 +134,7 @@ public class TurnControlTest {
|
|||
mockHand.iterable = stones;
|
||||
|
||||
testControl = new HumanTurnControl(mockTimer);
|
||||
testControl.setup(new GameSettings(), mockPlayer, mockTable, mockView,
|
||||
TurnMode.NORMAL_TURN);
|
||||
testControl.setup(new ITurnControl.TurnInfo(mockTable, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||
testControl.startTurn();
|
||||
|
||||
int i = 0;
|
||||
|
@ -629,8 +627,7 @@ public class TurnControlTest {
|
|||
public void testAddLeft() {
|
||||
AccessibleTable table = new AccessibleTable();
|
||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||
turnControl.setup(new GameSettings(), mockPlayer, table, mockView,
|
||||
TurnMode.NORMAL_TURN);
|
||||
turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||
turnControl.startTurn();
|
||||
Stone blueOne = new Stone(1, BLUE);
|
||||
Stone redOne = new Stone(1, RED);
|
||||
|
@ -747,8 +744,7 @@ public class TurnControlTest {
|
|||
public void testAddRight() {
|
||||
AccessibleTable table = new AccessibleTable();
|
||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||
turnControl.setup(new GameSettings(), mockPlayer, table, mockView,
|
||||
TurnMode.NORMAL_TURN);
|
||||
turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||
turnControl.startTurn();
|
||||
Stone blueOne = new Stone(1, BLUE);
|
||||
Stone redOne = new Stone(1, RED);
|
||||
|
@ -865,8 +861,7 @@ public class TurnControlTest {
|
|||
public void testAddNewSet() {
|
||||
AccessibleTable table = new AccessibleTable();
|
||||
HumanTurnControl turnControl = new HumanTurnControl(mockTimer);
|
||||
turnControl.setup(new GameSettings(), mockPlayer, table, mockView,
|
||||
TurnMode.NORMAL_TURN);
|
||||
turnControl.setup(new ITurnControl.TurnInfo(table, mockPlayer.getHand(), mockPlayer.getLaidOut(), TurnMode.NORMAL_TURN), new GameSettings(), mockView);
|
||||
turnControl.startTurn();
|
||||
Stone blueOne = new Stone(1, BLUE);
|
||||
Stone redOne = new Stone(1, RED);
|
||||
|
|
Reference in a new issue