Remove player labels at the table edges
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@283 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
cff3180460
commit
3d74d11974
8 changed files with 89 additions and 193 deletions
|
@ -30,12 +30,6 @@ public class MockTablePanel implements ITablePanel {
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public MockStoneCollectionPanel stoneCollectionPanel = new MockStoneCollectionPanel();
|
public MockStoneCollectionPanel stoneCollectionPanel = new MockStoneCollectionPanel();
|
||||||
/** */
|
|
||||||
public String leftPlayerName;
|
|
||||||
/** */
|
|
||||||
public String topPlayerName;
|
|
||||||
/** */
|
|
||||||
public String rightPlayerName;
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public Iterable<Pair<StoneSet, Position>> stoneSets;
|
public Iterable<Pair<StoneSet, Position>> stoneSets;
|
||||||
|
@ -60,21 +54,6 @@ public class MockTablePanel implements ITablePanel {
|
||||||
return clickEvent;
|
return clickEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLeftPlayerName(String playerName) {
|
|
||||||
leftPlayerName = playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTopPlayerName(String playerName) {
|
|
||||||
topPlayerName = playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRightPlayerName(String playerName) {
|
|
||||||
rightPlayerName = playerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStoneSets(Iterable<Pair<StoneSet, Position>> stoneSets) {
|
public void setStoneSets(Iterable<Pair<StoneSet, Position>> stoneSets) {
|
||||||
this.stoneSets = stoneSets;
|
this.stoneSets = stoneSets;
|
||||||
|
|
|
@ -90,4 +90,10 @@ public class MockView implements IView {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSettingsPanel(boolean show) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,9 +36,9 @@ public class RoundControl {
|
||||||
* Create a new RoundControl using the given gameState and view
|
* Create a new RoundControl using the given gameState and view
|
||||||
*
|
*
|
||||||
* @param roundState
|
* @param roundState
|
||||||
* initial round state
|
* initial round state
|
||||||
* @param view
|
* @param view
|
||||||
* view used for user interaction
|
* view used for user interaction
|
||||||
*/
|
*/
|
||||||
public RoundControl(IRoundState roundState, IView view) {
|
public RoundControl(IRoundState roundState, IView view) {
|
||||||
this.roundState = roundState;
|
this.roundState = roundState;
|
||||||
|
@ -75,14 +75,8 @@ public class RoundControl {
|
||||||
clonedTable = (ITable) roundState.getTable().clone();
|
clonedTable = (ITable) roundState.getTable().clone();
|
||||||
view.enableStartTurnPanel(true);
|
view.enableStartTurnPanel(true);
|
||||||
view.getTablePanel().setStoneSets(clonedTable);
|
view.getTablePanel().setStoneSets(clonedTable);
|
||||||
view.setCurrentPlayerName(roundState.getActivePlayer()
|
view.setCurrentPlayerName(roundState.getActivePlayer().getPlayerSettings()
|
||||||
.getPlayerSettings().getName());
|
.getName());
|
||||||
view.getTablePanel().setLeftPlayerName(
|
|
||||||
roundState.getNthNextPlayer(1).getPlayerSettings().getName());
|
|
||||||
view.getTablePanel().setTopPlayerName(
|
|
||||||
roundState.getNthNextPlayer(2).getPlayerSettings().getName());
|
|
||||||
view.getTablePanel().setRightPlayerName(
|
|
||||||
roundState.getNthNextPlayer(3).getPlayerSettings().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startTurn() {
|
private void startTurn() {
|
||||||
|
@ -103,10 +97,8 @@ public class RoundControl {
|
||||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||||
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
IHand hand = roundState.getNthNextPlayer(i).getHand();
|
||||||
for (int j = 0; j < 7; j++) {
|
for (int j = 0; j < 7; j++) {
|
||||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(j,
|
hand.drop(roundState.getGameHeap().drawStone(), new Position(j, 0));
|
||||||
0));
|
hand.drop(roundState.getGameHeap().drawStone(), new Position(j, 1));
|
||||||
hand.drop(roundState.getGameHeap().drawStone(), new Position(j,
|
|
||||||
1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,8 +113,7 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalValue == 0
|
return totalValue == 0
|
||||||
|| totalValue >= roundState.getGameSettings()
|
|| totalValue >= roundState.getGameSettings().getInitialMeldThreshold();
|
||||||
.getInitialMeldThreshold();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endOfTurn() {
|
private void endOfTurn() {
|
||||||
|
@ -158,8 +149,7 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
if (!roundState.getActivePlayer().getLaidOut()) {
|
if (!roundState.getActivePlayer().getLaidOut()) {
|
||||||
// Player touched forbidden stones
|
// Player touched forbidden stones
|
||||||
if (!tableSetDifference(clonedTable, roundState.getTable())
|
if (!tableSetDifference(clonedTable, roundState.getTable()).isEmpty()) {
|
||||||
.isEmpty()) {
|
|
||||||
rejectMove();
|
rejectMove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -168,8 +158,7 @@ public class RoundControl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<Stone> tableDiff = tableDifference(roundState.getTable(),
|
Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable);
|
||||||
clonedTable);
|
|
||||||
|
|
||||||
roundState.setTable(clonedTable);
|
roundState.setTable(clonedTable);
|
||||||
|
|
||||||
|
@ -185,8 +174,7 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rejectMove() {
|
private void rejectMove() {
|
||||||
Set<Stone> tableDiff = tableDifference(roundState.getTable(),
|
Set<Stone> tableDiff = tableDifference(roundState.getTable(), clonedTable);
|
||||||
clonedTable);
|
|
||||||
// deal penalty, reset
|
// deal penalty, reset
|
||||||
roundState.getGameHeap().putBack(tableDiff);
|
roundState.getGameHeap().putBack(tableDiff);
|
||||||
dealPenalty(tableDiff.size());
|
dealPenalty(tableDiff.size());
|
||||||
|
@ -258,7 +246,8 @@ public class RoundControl {
|
||||||
|
|
||||||
boolean foundRegularWinner = false;
|
boolean foundRegularWinner = false;
|
||||||
int winnerPlayerNumber = 0;
|
int winnerPlayerNumber = 0;
|
||||||
Pair<Integer, Integer> bestScore = new Pair<Integer, Integer>(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
Pair<Integer, Integer> bestScore = new Pair<Integer, Integer>(
|
||||||
|
Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
int pointSum = 0;
|
int pointSum = 0;
|
||||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||||
IPlayer player = roundState.getNthPlayer(i);
|
IPlayer player = roundState.getNthPlayer(i);
|
||||||
|
@ -276,9 +265,9 @@ public class RoundControl {
|
||||||
} else {
|
} else {
|
||||||
stonePoints = playerHand.getStonePoints();
|
stonePoints = playerHand.getStonePoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize());
|
bestScore = updateBestScore(bestScore, -stonePoints, playerHand.getSize());
|
||||||
|
|
||||||
points.add(-stonePoints);
|
points.add(-stonePoints);
|
||||||
pointSum += stonePoints;
|
pointSum += stonePoints;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +276,8 @@ public class RoundControl {
|
||||||
points.set(winnerPlayerNumber, pointSum);
|
points.set(winnerPlayerNumber, pointSum);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
for (int i = 0; i < roundState.getPlayerCount(); i++) {
|
||||||
if (bestScore.equals(new Pair<Integer, Integer>(points.get(i), roundState.getNthPlayer(i).getHand().getSize()))) {
|
if (bestScore.equals(new Pair<Integer, Integer>(points.get(i),
|
||||||
|
roundState.getNthPlayer(i).getHand().getSize()))) {
|
||||||
winners.set(i, true);
|
winners.set(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +288,8 @@ public class RoundControl {
|
||||||
private static Pair<Integer, Integer> updateBestScore(
|
private static Pair<Integer, Integer> updateBestScore(
|
||||||
Pair<Integer, Integer> bestScore, int stonePoints, int size) {
|
Pair<Integer, Integer> bestScore, int stonePoints, int size) {
|
||||||
if (bestScore.getFirst() == stonePoints) {
|
if (bestScore.getFirst() == stonePoints) {
|
||||||
return new Pair<Integer, Integer>(stonePoints, Math.min(bestScore.getSecond(), size));
|
return new Pair<Integer, Integer>(stonePoints, Math.min(
|
||||||
|
bestScore.getSecond(), size));
|
||||||
} else if (bestScore.getFirst() < stonePoints) {
|
} else if (bestScore.getFirst() < stonePoints) {
|
||||||
return new Pair<Integer, Integer>(stonePoints, size);
|
return new Pair<Integer, Integer>(stonePoints, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,30 +9,6 @@ import jrummikub.util.Pair;
|
||||||
* The view of the table, where the stone sets lie
|
* The view of the table, where the stone sets lie
|
||||||
*/
|
*/
|
||||||
public interface ITablePanel extends IStonePanel, IClickable {
|
public interface ITablePanel extends IStonePanel, IClickable {
|
||||||
/**
|
|
||||||
* Sets the player name on the left label
|
|
||||||
*
|
|
||||||
* @param playerName
|
|
||||||
* the name to set
|
|
||||||
*/
|
|
||||||
public void setLeftPlayerName(String playerName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the player name on the top label
|
|
||||||
*
|
|
||||||
* @param playerName
|
|
||||||
* the name to set
|
|
||||||
*/
|
|
||||||
public void setTopPlayerName(String playerName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the player name on the right label
|
|
||||||
*
|
|
||||||
* @param playerName
|
|
||||||
* the name to set
|
|
||||||
*/
|
|
||||||
public void setRightPlayerName(String playerName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the stone sets lying on the table
|
* Sets the stone sets lying on the table
|
||||||
*
|
*
|
||||||
|
|
|
@ -87,4 +87,11 @@ public interface IView {
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
IEvent getNewRoundEvent();
|
IEvent getNewRoundEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows or hides the game settings panel
|
||||||
|
*
|
||||||
|
* @param show specifies if the panel shall be shown or hidden
|
||||||
|
*/
|
||||||
|
void showSettingsPanel(boolean show);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package jrummikub.view.impl;
|
package jrummikub.view.impl;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
@ -17,7 +16,6 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import jrummikub.model.Position;
|
import jrummikub.model.Position;
|
||||||
|
@ -49,7 +47,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
private final float COLLECTION_RATIO = 0.12f;
|
private final float COLLECTION_RATIO = 0.12f;
|
||||||
private final int COLLECTION_GAP = 5;
|
private final int COLLECTION_GAP = 5;
|
||||||
|
|
||||||
private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel;
|
|
||||||
private StoneCollectionPanel stoneCollection;
|
private StoneCollectionPanel stoneCollection;
|
||||||
|
|
||||||
private Iterable<Pair<StoneSet, Position>> stoneSets = Collections.emptySet();
|
private Iterable<Pair<StoneSet, Position>> stoneSets = Collections.emptySet();
|
||||||
|
@ -61,21 +58,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
private StoneSet leftHoveredConnector;
|
private StoneSet leftHoveredConnector;
|
||||||
private StoneSet rightHoveredConnector;
|
private StoneSet rightHoveredConnector;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLeftPlayerName(String playerName) {
|
|
||||||
leftPlayerLabel.setText(playerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTopPlayerName(String playerName) {
|
|
||||||
topPlayerLabel.setText(playerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRightPlayerName(String playerName) {
|
|
||||||
rightPlayerLabel.setText(playerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Event1<StoneSet> getLeftConnectorClickEvent() {
|
public Event1<StoneSet> getLeftConnectorClickEvent() {
|
||||||
return leftConnectorClickEvent;
|
return leftConnectorClickEvent;
|
||||||
|
@ -124,36 +106,12 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLabels() {
|
|
||||||
leftPlayerLabel = new JLabel();
|
|
||||||
leftPlayerLabel.setForeground(Color.WHITE);
|
|
||||||
leftPlayerLabel.setHorizontalAlignment(JLabel.LEFT);
|
|
||||||
leftPlayerLabel.setHorizontalTextPosition(JLabel.LEFT);
|
|
||||||
add(leftPlayerLabel);
|
|
||||||
|
|
||||||
topPlayerLabel = new JLabel();
|
|
||||||
topPlayerLabel.setHorizontalAlignment(JLabel.CENTER);
|
|
||||||
topPlayerLabel.setHorizontalTextPosition(JLabel.CENTER);
|
|
||||||
topPlayerLabel.setVerticalAlignment(JLabel.TOP);
|
|
||||||
topPlayerLabel.setVerticalTextPosition(JLabel.TOP);
|
|
||||||
topPlayerLabel.setForeground(Color.WHITE);
|
|
||||||
add(topPlayerLabel);
|
|
||||||
|
|
||||||
rightPlayerLabel = new JLabel();
|
|
||||||
rightPlayerLabel.setForeground(Color.WHITE);
|
|
||||||
rightPlayerLabel.setHorizontalAlignment(JLabel.RIGHT);
|
|
||||||
rightPlayerLabel.setHorizontalTextPosition(JLabel.RIGHT);
|
|
||||||
add(rightPlayerLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Table instance
|
* Creates a new Table instance
|
||||||
*/
|
*/
|
||||||
TablePanel() {
|
TablePanel() {
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
|
|
||||||
createLabels();
|
|
||||||
|
|
||||||
stoneCollection = new StoneCollectionPanel();
|
stoneCollection = new StoneCollectionPanel();
|
||||||
stoneCollection.getOtherClickEvent().add(new IListener1<Point>() {
|
stoneCollection.getOtherClickEvent().add(new IListener1<Point>() {
|
||||||
|
|
||||||
|
@ -206,10 +164,6 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
||||||
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
||||||
|
|
||||||
leftPlayerLabel.setBounds(x, y, width, height);
|
|
||||||
topPlayerLabel.setBounds(x, y, width, height);
|
|
||||||
rightPlayerLabel.setBounds(x, y, width, height);
|
|
||||||
|
|
||||||
int collectionHeight = (int) (height * COLLECTION_RATIO);
|
int collectionHeight = (int) (height * COLLECTION_RATIO);
|
||||||
stoneCollection
|
stoneCollection
|
||||||
.setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
|
.setBounds(x, y + height - collectionHeight - COLLECTION_GAP, width,
|
||||||
|
|
|
@ -154,6 +154,11 @@ public class View extends JFrame implements IView {
|
||||||
winPanel.setVisible(enable);
|
winPanel.setVisible(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showSettingsPanel(boolean show) {
|
||||||
|
settingsPanel.setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentPlayerName(String playerName) {
|
public void setCurrentPlayerName(String playerName) {
|
||||||
playerPanel.setCurrentPlayerName(playerName);
|
playerPanel.setCurrentPlayerName(playerName);
|
||||||
|
@ -175,5 +180,4 @@ public class View extends JFrame implements IView {
|
||||||
public IEvent getFinalScoreEvent() {
|
public IEvent getFinalScoreEvent() {
|
||||||
return winPanel.getFinalScoreEvent();
|
return winPanel.getFinalScoreEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,7 @@
|
||||||
package jrummikub.control;
|
package jrummikub.control;
|
||||||
|
|
||||||
import static jrummikub.model.StoneColor.BLACK;
|
import static jrummikub.model.StoneColor.*;
|
||||||
import static jrummikub.model.StoneColor.BLUE;
|
import static org.junit.Assert.*;
|
||||||
import static jrummikub.model.StoneColor.ORANGE;
|
|
||||||
import static jrummikub.model.StoneColor.RED;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -76,10 +68,8 @@ public class RoundControlTest {
|
||||||
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
|
gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED));
|
||||||
gameSettings.getPlayerList().add(
|
gameSettings.getPlayerList().add(
|
||||||
new PlayerSettings("Matthias", Color.YELLOW));
|
new PlayerSettings("Matthias", Color.YELLOW));
|
||||||
gameSettings.getPlayerList().add(
|
gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN));
|
||||||
new PlayerSettings("Jannis", Color.GREEN));
|
gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK));
|
||||||
gameSettings.getPlayerList().add(
|
|
||||||
new PlayerSettings("Bennet", Color.BLACK));
|
|
||||||
roundState = new RoundState(gameSettings);
|
roundState = new RoundState(gameSettings);
|
||||||
roundControl = new RoundControl(roundState, view);
|
roundControl = new RoundControl(roundState, view);
|
||||||
}
|
}
|
||||||
|
@ -89,16 +79,13 @@ public class RoundControlTest {
|
||||||
- testRoundState.table.getSize(), testRoundState.getGameHeap()
|
- testRoundState.table.getSize(), testRoundState.getGameHeap()
|
||||||
.getSize());
|
.getSize());
|
||||||
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
|
for (int i = 0; i < testRoundState.getPlayerCount(); i++) {
|
||||||
assertEquals(14, testRoundState.getNthNextPlayer(i).getHand()
|
assertEquals(14, testRoundState.getNthNextPlayer(i).getHand().getSize());
|
||||||
.getSize());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTurnStartSetUp() {
|
private void checkTurnStartSetUp() {
|
||||||
assertNotNull(view.currentPlayerName);
|
assertNotNull(view.currentPlayerName);
|
||||||
assertNotNull(view.getTablePanel().leftPlayerName);
|
// TODO Check player list in view
|
||||||
assertNotNull(view.getTablePanel().topPlayerName);
|
|
||||||
assertNotNull(view.getTablePanel().rightPlayerName);
|
|
||||||
assertTrue(view.displayStartTurnPanel);
|
assertTrue(view.displayStartTurnPanel);
|
||||||
assertFalse(view.startTurnEvent.listeners.isEmpty());
|
assertFalse(view.startTurnEvent.listeners.isEmpty());
|
||||||
assertFalse(view.displayWinPanel);
|
assertFalse(view.displayWinPanel);
|
||||||
|
@ -120,9 +107,7 @@ public class RoundControlTest {
|
||||||
|
|
||||||
private void resetTurnStart() {
|
private void resetTurnStart() {
|
||||||
view.currentPlayerName = null;
|
view.currentPlayerName = null;
|
||||||
view.getTablePanel().leftPlayerName = null;
|
// TODO reset player list
|
||||||
view.getTablePanel().topPlayerName = null;
|
|
||||||
view.getTablePanel().rightPlayerName = null;
|
|
||||||
view.displayStartTurnPanel = false;
|
view.displayStartTurnPanel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +140,8 @@ public class RoundControlTest {
|
||||||
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(0, roundState.getTable().getSize());
|
assertEquals(0, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 6, hand.getSize());
|
assertEquals(14 + 6, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -176,8 +161,8 @@ public class RoundControlTest {
|
||||||
assertFalse(roundState.getActivePlayer().getLaidOut());
|
assertFalse(roundState.getActivePlayer().getLaidOut());
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(0, roundState.getTable().getSize());
|
assertEquals(0, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 1, hand.getSize());
|
assertEquals(14 + 1, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -224,8 +209,8 @@ public class RoundControlTest {
|
||||||
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(0, roundState.getTable().getSize());
|
assertEquals(0, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 9, hand.getSize());
|
assertEquals(14 + 9, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -295,8 +280,8 @@ public class RoundControlTest {
|
||||||
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(2, roundState.getTable().getSize());
|
assertEquals(2, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 6, hand.getSize());
|
assertEquals(14 + 6, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -369,8 +354,8 @@ public class RoundControlTest {
|
||||||
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(2, roundState.getTable().getSize());
|
assertEquals(2, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 7, hand.getSize());
|
assertEquals(14 + 7, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -433,8 +418,8 @@ public class RoundControlTest {
|
||||||
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
view.tablePanel.clickEvent.emit(new Position(0, 0));
|
||||||
|
|
||||||
view.playerPanel.endTurnEvent.emit();
|
view.playerPanel.endTurnEvent.emit();
|
||||||
assertFalse(roundState
|
assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
|
||||||
.getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
|
.getLaidOut());
|
||||||
assertEquals(2, roundState.getTable().getSize());
|
assertEquals(2, roundState.getTable().getSize());
|
||||||
assertEquals(14 + 3, hand.getSize());
|
assertEquals(14 + 3, hand.getSize());
|
||||||
}
|
}
|
||||||
|
@ -692,15 +677,12 @@ public class RoundControlTest {
|
||||||
Stone blueTwo = new Stone(2, BLUE);
|
Stone blueTwo = new Stone(2, BLUE);
|
||||||
Stone blueThree = new Stone(3, BLUE);
|
Stone blueThree = new Stone(3, BLUE);
|
||||||
Stone blueFour = new Stone(4, BLUE);
|
Stone blueFour = new Stone(4, BLUE);
|
||||||
StoneSet oldSet1 = new StoneSet(
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne));
|
||||||
Arrays.asList(blueOne, redOne, blackOne));
|
|
||||||
StoneSet oldSet2 = new StoneSet(blueTwo);
|
StoneSet oldSet2 = new StoneSet(blueTwo);
|
||||||
oldTable.drop(oldSet1, new Position(0, 0));
|
oldTable.drop(oldSet1, new Position(0, 0));
|
||||||
oldTable.drop(oldSet2, new Position(0, 0));
|
oldTable.drop(oldSet2, new Position(0, 0));
|
||||||
StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo,
|
StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour));
|
||||||
blueFour));
|
StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree));
|
||||||
StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne,
|
|
||||||
blueThree));
|
|
||||||
newTable.drop(newSet1, new Position(0, 0));
|
newTable.drop(newSet1, new Position(0, 0));
|
||||||
newTable.drop(newSet2, new Position(0, 0));
|
newTable.drop(newSet2, new Position(0, 0));
|
||||||
|
|
||||||
|
@ -725,15 +707,14 @@ public class RoundControlTest {
|
||||||
Stone blueTwo = new Stone(2, BLUE);
|
Stone blueTwo = new Stone(2, BLUE);
|
||||||
Stone blueThree = new Stone(3, BLUE);
|
Stone blueThree = new Stone(3, BLUE);
|
||||||
Stone blueFour = new Stone(4, BLUE);
|
Stone blueFour = new Stone(4, BLUE);
|
||||||
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
|
StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne,
|
||||||
blackOne, orangeOne));
|
orangeOne));
|
||||||
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree,
|
StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour));
|
||||||
blueFour));
|
|
||||||
oldTable.drop(oldSet1, new Position(0, 0));
|
oldTable.drop(oldSet1, new Position(0, 0));
|
||||||
oldTable.drop(oldSet2, new Position(0, 0));
|
oldTable.drop(oldSet2, new Position(0, 0));
|
||||||
ITable newTable = (Table) oldTable.clone();
|
ITable newTable = (Table) oldTable.clone();
|
||||||
List<StoneSet> newSets = RoundControl.tableSetDifference(oldTable,
|
List<StoneSet> newSets = RoundControl
|
||||||
newTable);
|
.tableSetDifference(oldTable, newTable);
|
||||||
List<StoneSet> vanishedSets = RoundControl.tableSetDifference(newTable,
|
List<StoneSet> vanishedSets = RoundControl.tableSetDifference(newTable,
|
||||||
oldTable);
|
oldTable);
|
||||||
|
|
||||||
|
@ -741,8 +722,8 @@ public class RoundControlTest {
|
||||||
assertTrue(vanishedSets.isEmpty());
|
assertTrue(vanishedSets.isEmpty());
|
||||||
|
|
||||||
newTable.pickUp(oldSet2);
|
newTable.pickUp(oldSet2);
|
||||||
newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))),
|
newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position(
|
||||||
new Position(0, 0));
|
0, 0));
|
||||||
newSets = RoundControl.tableSetDifference(oldTable, newTable);
|
newSets = RoundControl.tableSetDifference(oldTable, newTable);
|
||||||
vanishedSets = RoundControl.tableSetDifference(newTable, oldTable);
|
vanishedSets = RoundControl.tableSetDifference(newTable, oldTable);
|
||||||
|
|
||||||
|
@ -754,8 +735,7 @@ public class RoundControlTest {
|
||||||
Stone redTwo = new Stone(2, RED);
|
Stone redTwo = new Stone(2, RED);
|
||||||
Stone redThree = new Stone(3, RED);
|
Stone redThree = new Stone(3, RED);
|
||||||
Stone redFour = new Stone(4, RED);
|
Stone redFour = new Stone(4, RED);
|
||||||
StoneSet oldSet3 = new StoneSet(
|
StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour));
|
||||||
Arrays.asList(redTwo, redThree, redFour));
|
|
||||||
ITable newTable2 = (Table) oldTable.clone();
|
ITable newTable2 = (Table) oldTable.clone();
|
||||||
newTable2.drop(oldSet3, new Position(0, 0));
|
newTable2.drop(oldSet3, new Position(0, 0));
|
||||||
newSets = RoundControl.tableSetDifference(oldTable, newTable2);
|
newSets = RoundControl.tableSetDifference(oldTable, newTable2);
|
||||||
|
@ -817,20 +797,19 @@ public class RoundControlTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
testRoundState.players.get(0).laidOut = true;
|
testRoundState.players.get(0).laidOut = true;
|
||||||
testRoundState.players.get(0).hand.drop(new Stone(1, RED),
|
testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
|
||||||
new Position(0, 0));
|
|
||||||
testRoundState.players.get(0).hand.drop(new Stone(2, RED),
|
|
||||||
new Position(0, 0));
|
|
||||||
testRoundState.players.get(1).laidOut = true;
|
|
||||||
testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0,
|
|
||||||
0));
|
0));
|
||||||
|
testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
|
||||||
|
0));
|
||||||
|
testRoundState.players.get(1).laidOut = true;
|
||||||
|
testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0));
|
||||||
testRoundState.players.get(2).laidOut = false;
|
testRoundState.players.get(2).laidOut = false;
|
||||||
testRoundState.players.get(2).hand.drop(new Stone(9, RED),
|
testRoundState.players.get(2).hand.drop(new Stone(9, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(2).hand.drop(new Stone(10, RED),
|
testRoundState.players.get(2).hand.drop(new Stone(10, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(2).hand.drop(new Stone(11, RED),
|
testRoundState.players.get(2).hand.drop(new Stone(11, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(3).laidOut = true;
|
testRoundState.players.get(3).laidOut = true;
|
||||||
|
|
||||||
testRound.endOfRound();
|
testRound.endOfRound();
|
||||||
|
@ -864,19 +843,19 @@ public class RoundControlTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
testRoundState.players.get(0).laidOut = true;
|
testRoundState.players.get(0).laidOut = true;
|
||||||
testRoundState.players.get(0).hand.drop(new Stone(1, RED),
|
testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(0).hand.drop(new Stone(2, RED),
|
testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(1).laidOut = true;
|
testRoundState.players.get(1).laidOut = true;
|
||||||
testRoundState.players.get(1).hand.drop(new Stone(3, RED),
|
testRoundState.players.get(1).hand.drop(new Stone(3, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(2).laidOut = true;
|
testRoundState.players.get(2).laidOut = true;
|
||||||
testRoundState.players.get(2).hand.drop(new Stone(3, BLUE),
|
testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
testRoundState.players.get(3).laidOut = false;
|
testRoundState.players.get(3).laidOut = false;
|
||||||
testRoundState.players.get(3).hand.drop(new Stone(13, RED),
|
testRoundState.players.get(3).hand.drop(new Stone(13, RED), new Position(0,
|
||||||
new Position(0, 0));
|
0));
|
||||||
|
|
||||||
testRound.endOfRound();
|
testRound.endOfRound();
|
||||||
assertTrue(roundEnded);
|
assertTrue(roundEnded);
|
||||||
|
@ -885,13 +864,13 @@ public class RoundControlTest {
|
||||||
assertTrue(roundScore.getWinners().get(1));
|
assertTrue(roundScore.getWinners().get(1));
|
||||||
assertTrue(roundScore.getWinners().get(2));
|
assertTrue(roundScore.getWinners().get(2));
|
||||||
assertFalse(roundScore.getWinners().get(3));
|
assertFalse(roundScore.getWinners().get(3));
|
||||||
|
|
||||||
assertEquals(-3, (int) roundScore.getPoints().get(0));
|
assertEquals(-3, (int) roundScore.getPoints().get(0));
|
||||||
assertEquals(-3, (int) roundScore.getPoints().get(1));
|
assertEquals(-3, (int) roundScore.getPoints().get(1));
|
||||||
assertEquals(-3, (int) roundScore.getPoints().get(2));
|
assertEquals(-3, (int) roundScore.getPoints().get(2));
|
||||||
assertEquals(-100, (int) roundScore.getPoints().get(3));
|
assertEquals(-100, (int) roundScore.getPoints().get(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void testInspectOnly() {
|
public void testInspectOnly() {
|
||||||
|
|
Reference in a new issue