Make highest value and number of stones dealt settable
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@337 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
c78e8e6448
commit
c004a07a42
11 changed files with 190 additions and 52 deletions
|
@ -1,10 +1,13 @@
|
|||
package jrummikub.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import jrummikub.control.turn.TurnControlFactory;
|
||||
import jrummikub.control.turn.TurnControlFactory.Type;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.StoneColor;
|
||||
import jrummikub.util.IEvent;
|
||||
import jrummikub.util.IEvent1;
|
||||
import jrummikub.util.IEvent2;
|
||||
|
@ -42,12 +45,24 @@ public class MockSettingsPanel implements ISettingsPanel {
|
|||
public MockEvent1<Integer> changeJokerNumberEvent = new MockEvent1<Integer>();
|
||||
/** */
|
||||
public MockEvent1<Integer> changeStoneSetNumberEvent = new MockEvent1<Integer>();
|
||||
/** */
|
||||
public MockEvent1<Integer> changeNumberOfStonesDealtEvent = new MockEvent1<Integer>();
|
||||
/** */
|
||||
public MockEvent1<Integer> changeHighestValueEvent = new MockEvent1<Integer>();
|
||||
/** */
|
||||
public MockEvent1<Set<StoneColor>> changeStoneColorsEvent = new MockEvent1<Set<StoneColor>>();
|
||||
/** */
|
||||
public int initialMeldThreshold;
|
||||
/** */
|
||||
public int jokerNumber;
|
||||
|
||||
/** */
|
||||
public int stoneSetNumber;
|
||||
/** */
|
||||
public int numberOfStonesDealt;
|
||||
/** */
|
||||
public int highestValue;
|
||||
/** */
|
||||
public Set<StoneColor> stoneColors;
|
||||
|
||||
@Override
|
||||
public IEvent getAddPlayerEvent() {
|
||||
|
@ -74,6 +89,21 @@ public class MockSettingsPanel implements ISettingsPanel {
|
|||
return changeInitialMeldThresholdEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Integer> getChangeNumberOfStonesDealtEvent() {
|
||||
return changeNumberOfStonesDealtEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Integer> getChangeHighestValueEvent() {
|
||||
return changeHighestValueEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() {
|
||||
return changeStoneColorsEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent getStartGameEvent() {
|
||||
return startGameEvent;
|
||||
|
@ -108,6 +138,9 @@ public class MockSettingsPanel implements ISettingsPanel {
|
|||
initialMeldThreshold = gameSettings.getInitialMeldThreshold();
|
||||
jokerNumber = gameSettings.getJokerNumber();
|
||||
stoneSetNumber = gameSettings.getStoneSetNumber();
|
||||
numberOfStonesDealt = gameSettings.getNumberOfStonesDealt();
|
||||
highestValue = gameSettings.getHighestValue();
|
||||
stoneColors = new HashSet<StoneColor>(gameSettings.getStoneColors());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,12 +2,15 @@ package jrummikub.control;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jrummikub.control.turn.TurnControlFactory;
|
||||
import jrummikub.control.turn.TurnControlFactory.Type;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.PlayerSettings;
|
||||
import jrummikub.model.StoneColor;
|
||||
import jrummikub.util.Connection;
|
||||
import jrummikub.util.Event1;
|
||||
import jrummikub.util.IEvent1;
|
||||
|
@ -83,6 +86,30 @@ public class SettingsControl {
|
|||
update();
|
||||
}
|
||||
}));
|
||||
connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent()
|
||||
.add(new IListener1<Integer>() {
|
||||
@Override
|
||||
public void handle(Integer value) {
|
||||
settings.setNumberOfStonesDealt(value);
|
||||
update();
|
||||
}
|
||||
}));
|
||||
connections.add(view.getSettingsPanel().getChangeHighestValueEvent()
|
||||
.add(new IListener1<Integer>() {
|
||||
@Override
|
||||
public void handle(Integer value) {
|
||||
settings.setHighestValue(value);
|
||||
update();
|
||||
}
|
||||
}));
|
||||
connections.add(view.getSettingsPanel().getChangeStoneColorsEvent()
|
||||
.add(new IListener1<Set<StoneColor>>() {
|
||||
@Override
|
||||
public void handle(Set<StoneColor> value) {
|
||||
settings.setStoneColors(new HashSet<StoneColor>(value));
|
||||
update();
|
||||
}
|
||||
}));
|
||||
|
||||
addPlayerSettingsListeners();
|
||||
|
||||
|
@ -242,7 +269,7 @@ public class SettingsControl {
|
|||
|
||||
int totalStonesDealt = settings.getNumberOfStonesDealt()
|
||||
* settings.getPlayerList().size();
|
||||
int totalStones = settings.getHighestCard()
|
||||
int totalStones = settings.getHighestValue()
|
||||
* settings.getStoneSetNumber()
|
||||
* settings.getStoneColors().size() + settings.getJokerNumber();
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package jrummikub.model;
|
||||
|
||||
import static jrummikub.model.StoneColor.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import static jrummikub.model.StoneColor.*;
|
||||
|
||||
/**
|
||||
* The overall game settings
|
||||
|
@ -16,7 +17,7 @@ public class GameSettings {
|
|||
private int initialMeldThreshold;
|
||||
private int jokerPoints;
|
||||
private int jokerNumber;
|
||||
private int highestCard;
|
||||
private int highestValue;
|
||||
private int stoneSetNumber;
|
||||
private int numberOfStonesDealt;
|
||||
private boolean noLimits;
|
||||
|
@ -29,12 +30,12 @@ public class GameSettings {
|
|||
initialMeldThreshold = 30;
|
||||
jokerPoints = 50;
|
||||
jokerNumber = 2;
|
||||
highestCard = 13;
|
||||
highestValue = 13;
|
||||
stoneSetNumber = 2;
|
||||
numberOfStonesDealt = 14;
|
||||
noLimits = false;
|
||||
stoneColors = new HashSet<StoneColor>(Arrays.asList(BLACK, BLUE,
|
||||
ORANGE, RED));
|
||||
stoneColors = new HashSet<StoneColor>(Arrays.asList(BLACK, BLUE, ORANGE,
|
||||
RED));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +51,7 @@ public class GameSettings {
|
|||
* Sets the initial meld threshold
|
||||
*
|
||||
* @param value
|
||||
* the value to set
|
||||
* the value to set
|
||||
*/
|
||||
public void setInitialMeldThreshold(int value) {
|
||||
initialMeldThreshold = value;
|
||||
|
@ -69,7 +70,7 @@ public class GameSettings {
|
|||
* Sets the points counted for a joker
|
||||
*
|
||||
* @param value
|
||||
* the value to set
|
||||
* the value to set
|
||||
*/
|
||||
public void setJokerPoints(int value) {
|
||||
jokerPoints = value;
|
||||
|
@ -103,22 +104,22 @@ public class GameSettings {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the highest card value in use
|
||||
* Return the highest stone value in use
|
||||
*
|
||||
* @return highest card value
|
||||
* @return highest stone value
|
||||
*/
|
||||
public int getHighestCard() {
|
||||
return highestCard;
|
||||
public int getHighestValue() {
|
||||
return highestValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the highest card value in use
|
||||
* Set the highest stone value in use
|
||||
*
|
||||
* @param highestCard
|
||||
* highest card value
|
||||
* @param highestValue
|
||||
* highest stone value
|
||||
*/
|
||||
public void setHighestCard(int highestCard) {
|
||||
this.highestCard = highestCard;
|
||||
public void setHighestValue(int highestValue) {
|
||||
this.highestValue = highestValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,7 +135,7 @@ public class GameSettings {
|
|||
* Set the number of sets of stones in use
|
||||
*
|
||||
* @param stoneSets
|
||||
* sets of stones in use
|
||||
* sets of stones in use
|
||||
*/
|
||||
public void setStoneSetNumber(int stoneSets) {
|
||||
this.stoneSetNumber = stoneSets;
|
||||
|
@ -153,7 +154,7 @@ public class GameSettings {
|
|||
* Set whether "No-Limits" rules are used
|
||||
*
|
||||
* @param noLimits
|
||||
* use no limit rules
|
||||
* use no limit rules
|
||||
*/
|
||||
public void setNoLimits(boolean noLimits) {
|
||||
this.noLimits = noLimits;
|
||||
|
@ -172,7 +173,7 @@ public class GameSettings {
|
|||
* Set stone colors used
|
||||
*
|
||||
* @param stoneColors
|
||||
* used stone colors
|
||||
* used stone colors
|
||||
*/
|
||||
public void setStoneColors(Set<StoneColor> stoneColors) {
|
||||
this.stoneColors = stoneColors;
|
||||
|
|
|
@ -23,7 +23,7 @@ public class StoneHeap {
|
|||
* */
|
||||
public StoneHeap(GameSettings gameSettings) {
|
||||
heap = new ArrayList<Stone>();
|
||||
for (int i = 1; i <= gameSettings.getHighestCard(); i++) {
|
||||
for (int i = 1; i <= gameSettings.getHighestValue(); i++) {
|
||||
for (int j = 0; j < gameSettings.getStoneSetNumber(); j++) {
|
||||
for (StoneColor c : gameSettings.getStoneColors()) {
|
||||
heap.add(new Stone(i, c));
|
||||
|
|
|
@ -75,19 +75,19 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
|||
}
|
||||
|
||||
if (nonJoker == -1) {
|
||||
if (stones.size() > settings.getHighestCard()) {
|
||||
if (stones.size() > settings.getHighestValue()) {
|
||||
return new Pair<Type, Integer>(INVALID, 0);
|
||||
} else if (stones.size() > settings.getStoneColors().size()) {
|
||||
return new Pair<Type, Integer>(
|
||||
RUN,
|
||||
(settings.getHighestCard() * (settings.getHighestCard() + 1))
|
||||
(settings.getHighestValue() * (settings.getHighestValue() + 1))
|
||||
/ 2
|
||||
- (stones.size() - settings.getHighestCard())
|
||||
* (stones.size() - settings.getHighestCard() - 1)
|
||||
- (stones.size() - settings.getHighestValue())
|
||||
* (stones.size() - settings.getHighestValue() - 1)
|
||||
/ 2);
|
||||
} else {
|
||||
return new Pair<Type, Integer>(GROUP, stones.size()
|
||||
* settings.getHighestCard());
|
||||
* settings.getHighestValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
|||
int startValue = stones.get(referencePosition).getValue()
|
||||
- referencePosition;
|
||||
int endValue = startValue + stones.size() - 1;
|
||||
if (startValue < 1 || endValue > settings.getHighestCard()) {
|
||||
if (startValue < 1 || endValue > settings.getHighestValue()) {
|
||||
return 0;
|
||||
}
|
||||
for (int i = 0; i < stones.size(); i++) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package jrummikub.view;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Set;
|
||||
|
||||
import jrummikub.control.turn.TurnControlFactory;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.StoneColor;
|
||||
import jrummikub.util.IEvent;
|
||||
import jrummikub.util.IEvent1;
|
||||
import jrummikub.util.IEvent2;
|
||||
|
@ -34,8 +36,8 @@ public interface ISettingsPanel {
|
|||
};
|
||||
|
||||
/**
|
||||
* The add player event is emitted when the user wants to add a player to
|
||||
* the player list
|
||||
* The add player event is emitted when the user wants to add a player to the
|
||||
* player list
|
||||
*
|
||||
* @return the event
|
||||
*/
|
||||
|
@ -80,9 +82,15 @@ public interface ISettingsPanel {
|
|||
* @return the event
|
||||
*/
|
||||
public IEvent1<Integer> getChangeInitialMeldThresholdEvent();
|
||||
|
||||
|
||||
public IEvent1<Integer> getChangeStoneSetNumberEvent();
|
||||
|
||||
public IEvent1<Integer> getChangeNumberOfStonesDealtEvent();
|
||||
|
||||
public IEvent1<Integer> getChangeHighestValueEvent();
|
||||
|
||||
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent();
|
||||
|
||||
/**
|
||||
* the start game event is emitted when the user wants to start the game
|
||||
*
|
||||
|
@ -94,7 +102,7 @@ public interface ISettingsPanel {
|
|||
* Sets an error to display
|
||||
*
|
||||
* @param error
|
||||
* the kind of error
|
||||
* the kind of error
|
||||
*/
|
||||
public void setError(SettingsError error);
|
||||
|
||||
|
@ -102,7 +110,7 @@ public interface ISettingsPanel {
|
|||
* Enables or disables the start game button
|
||||
*
|
||||
* @param enable
|
||||
* specifies if the button is to be enabled or disabled
|
||||
* specifies if the button is to be enabled or disabled
|
||||
*/
|
||||
public void enableStartGameButton(boolean enable);
|
||||
|
||||
|
@ -110,7 +118,7 @@ public interface ISettingsPanel {
|
|||
* Enables or disables the add player button
|
||||
*
|
||||
* @param enable
|
||||
* specifies if the button is to be enabled or disabled
|
||||
* specifies if the button is to be enabled or disabled
|
||||
*/
|
||||
public void enableAddPlayerButton(boolean enable);
|
||||
|
||||
|
@ -118,7 +126,7 @@ public interface ISettingsPanel {
|
|||
* Enables or disables the remove player buttons
|
||||
*
|
||||
* @param enable
|
||||
* specifies if the buttons are to be enabled or disabled
|
||||
* specifies if the buttons are to be enabled or disabled
|
||||
*/
|
||||
|
||||
public void enableRemovePlayerButtons(boolean enable);
|
||||
|
@ -127,7 +135,7 @@ public interface ISettingsPanel {
|
|||
* Sets the game settings to display
|
||||
*
|
||||
* @param gameSettings
|
||||
* the settings
|
||||
* the settings
|
||||
*/
|
||||
public void setGameSettings(GameSettings gameSettings);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.awt.event.MouseEvent;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
|
@ -44,6 +45,7 @@ import jrummikub.control.turn.TurnControlFactory;
|
|||
import jrummikub.control.turn.TurnControlFactory.Type;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.PlayerSettings;
|
||||
import jrummikub.model.StoneColor;
|
||||
import jrummikub.util.Event;
|
||||
import jrummikub.util.Event1;
|
||||
import jrummikub.util.Event2;
|
||||
|
@ -66,6 +68,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
|
||||
private JSpinner initialMeldThresholdSpinner;
|
||||
private JSpinner stoneSetNumberSpinner;
|
||||
private JSpinner highestValueSpinner;
|
||||
private JSpinner numberOfStonesDealtSpinner;
|
||||
private JSpinner jokerNumberSpinner;
|
||||
|
||||
private Event startGameEvent = new Event();
|
||||
|
@ -77,6 +81,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
private Event1<Integer> changeInitialMeldThresholdEvent = new Event1<Integer>();
|
||||
private Event1<Integer> changeJokerNumberEvent = new Event1<Integer>();
|
||||
private Event1<Integer> changeStoneSetNumberEvent = new Event1<Integer>();
|
||||
private Event1<Integer> changeNumberOfStonesDealtEvent = new Event1<Integer>();
|
||||
private Event1<Integer> changeHighestValueEvent = new Event1<Integer>();
|
||||
private Event1<Set<StoneColor>> changeStoneColorsEvent = new Event1<Set<StoneColor>>();
|
||||
|
||||
@Override
|
||||
public IEvent getStartGameEvent() {
|
||||
|
@ -113,6 +120,21 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
return changeStoneSetNumberEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Integer> getChangeNumberOfStonesDealtEvent() {
|
||||
return changeNumberOfStonesDealtEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Integer> getChangeHighestValueEvent() {
|
||||
return changeHighestValueEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent() {
|
||||
return changeStoneColorsEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setError(SettingsError error) {
|
||||
switch (error) {
|
||||
|
@ -178,6 +200,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
initialMeldThresholdSpinner.setValue(gameSettings
|
||||
.getInitialMeldThreshold());
|
||||
stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber());
|
||||
highestValueSpinner.setValue(gameSettings.getHighestValue());
|
||||
numberOfStonesDealtSpinner.setValue(gameSettings.getNumberOfStonesDealt());
|
||||
jokerNumberSpinner.setValue(gameSettings.getJokerNumber());
|
||||
|
||||
playerSettingsViewport.revalidate();
|
||||
|
@ -251,13 +275,21 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
|||
stoneSetNumberSpinner = makeOptionSpinner(1, 1, 999, 1,
|
||||
changeStoneSetNumberEvent);
|
||||
|
||||
makeOptionLabel(2, "Jokeranzahl:");
|
||||
jokerNumberSpinner = makeOptionSpinner(2, 1, 999, 1,
|
||||
makeOptionLabel(2, "H\u00f6chster Steinwert:");
|
||||
highestValueSpinner = makeOptionSpinner(2, 3, 99, 1,
|
||||
changeHighestValueEvent);
|
||||
|
||||
makeOptionLabel(3, "Anzahl Startsteine:");
|
||||
numberOfStonesDealtSpinner = makeOptionSpinner(3, 1, 999, 1,
|
||||
changeNumberOfStonesDealtEvent);
|
||||
|
||||
makeOptionLabel(4, "Jokeranzahl:");
|
||||
jokerNumberSpinner = makeOptionSpinner(4, 1, 999, 1,
|
||||
changeJokerNumberEvent);
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.gridx = 1;
|
||||
c.gridy = 3;
|
||||
c.gridy = 5;
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
c.weightx = 1;
|
||||
c.weighty = 1;
|
||||
|
|
|
@ -80,7 +80,7 @@ public class RoundControlTest {
|
|||
|
||||
private void checkCorrectlyDealt() {
|
||||
GameSettings settings = testRoundState.getGameSettings();
|
||||
int totalStones = settings.getHighestCard()
|
||||
int totalStones = settings.getHighestValue()
|
||||
* settings.getStoneSetNumber()
|
||||
* settings.getStoneColors().size() + settings.getJokerNumber();
|
||||
assertEquals(
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package jrummikub.control;
|
||||
|
||||
import static jrummikub.model.StoneColor.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import jrummikub.control.turn.TurnControlFactory;
|
||||
import jrummikub.model.GameSettings;
|
||||
import jrummikub.model.StoneColor;
|
||||
import jrummikub.util.IListener1;
|
||||
import jrummikub.view.ISettingsPanel;
|
||||
import jrummikub.view.MockView;
|
||||
|
@ -37,8 +41,7 @@ public class SettingsControlTest {
|
|||
/** */
|
||||
@Test
|
||||
public void initialStateTest() {
|
||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR,
|
||||
view.settingsPanel.error);
|
||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error);
|
||||
view.settingsPanel.startGameEvent.emit();
|
||||
assertNotNull(gameSettings);
|
||||
assertEquals(2, gameSettings.getPlayerList().size());
|
||||
|
@ -159,8 +162,7 @@ public class SettingsControlTest {
|
|||
view.settingsPanel.changePlayerNameEvent.emit(1, name2);
|
||||
|
||||
assertTrue(view.settingsPanel.startButtonEnabled);
|
||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR,
|
||||
view.settingsPanel.error);
|
||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error);
|
||||
|
||||
view.settingsPanel.startGameEvent.emit();
|
||||
assertNotNull(gameSettings);
|
||||
|
@ -213,6 +215,41 @@ public class SettingsControlTest {
|
|||
assertEquals(3, gameSettings.getStoneSetNumber());
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void changeNumberOfStonesDealtTest() {
|
||||
assertEquals(initialSettings.getNumberOfStonesDealt(),
|
||||
view.settingsPanel.numberOfStonesDealt);
|
||||
|
||||
view.settingsPanel.changeNumberOfStonesDealtEvent.emit(15);
|
||||
view.settingsPanel.startGameEvent.emit();
|
||||
assertEquals(15, gameSettings.getNumberOfStonesDealt());
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void changeHighestValueTest() {
|
||||
assertEquals(initialSettings.getHighestValue(),
|
||||
view.settingsPanel.highestValue);
|
||||
|
||||
view.settingsPanel.changeHighestValueEvent.emit(10);
|
||||
view.settingsPanel.startGameEvent.emit();
|
||||
assertEquals(10, gameSettings.getHighestValue());
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void changeStoneColorsTest() {
|
||||
assertEquals(initialSettings.getStoneColors(),
|
||||
view.settingsPanel.stoneColors);
|
||||
|
||||
view.settingsPanel.changeStoneColorsEvent.emit(new HashSet<StoneColor>(Arrays.asList(
|
||||
BLUE, RED, BLACK)));
|
||||
view.settingsPanel.startGameEvent.emit();
|
||||
assertEquals(new HashSet<StoneColor>(Arrays.asList(BLUE, RED, BLACK)),
|
||||
gameSettings.getStoneColors());
|
||||
}
|
||||
|
||||
/** */
|
||||
@Test
|
||||
public void typeChangeTest() {
|
||||
|
@ -225,10 +262,10 @@ public class SettingsControlTest {
|
|||
view.settingsPanel.startGameEvent.emit();
|
||||
assertNotNull(gameSettings);
|
||||
assertEquals(2, gameSettings.getPlayerList().size());
|
||||
assertSame(TurnControlFactory.Type.COMPUTER, gameSettings
|
||||
.getPlayerList().get(0).getTurnControlType());
|
||||
assertSame(TurnControlFactory.Type.HUMAN, gameSettings.getPlayerList()
|
||||
.get(1).getTurnControlType());
|
||||
assertSame(TurnControlFactory.Type.COMPUTER, gameSettings.getPlayerList()
|
||||
.get(0).getTurnControlType());
|
||||
assertSame(TurnControlFactory.Type.HUMAN,
|
||||
gameSettings.getPlayerList().get(1).getTurnControlType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class StoneHeapTest {
|
|||
}
|
||||
|
||||
private int calculateTotalNumberOfStones(GameSettings testSettings) {
|
||||
int totalStones = testSettings.getHighestCard()
|
||||
int totalStones = testSettings.getHighestValue()
|
||||
* testSettings.getStoneSetNumber()
|
||||
* testSettings.getStoneColors().size()
|
||||
+ testSettings.getJokerNumber();
|
||||
|
@ -81,7 +81,7 @@ public class StoneHeapTest {
|
|||
*/
|
||||
@Theory
|
||||
public void fullColor(Pair<GameSettings, StoneHeap> data) {
|
||||
int stonesOfAColor = data.getFirst().getHighestCard()
|
||||
int stonesOfAColor = data.getFirst().getHighestValue()
|
||||
* data.getFirst().getStoneSetNumber();
|
||||
Map<StoneColor, Integer> counters = new HashMap<StoneColor, Integer>();
|
||||
for (StoneColor c : data.getFirst().getStoneColors()) {
|
||||
|
|
|
@ -31,8 +31,8 @@ public class StoneSetTest {
|
|||
moreColorSettings.setStoneColors(EnumSet.allOf(StoneColor.class));
|
||||
lessColorSettings.setStoneColors(new HashSet<StoneColor>(Arrays.asList(
|
||||
StoneColor.BLUE, StoneColor.RED, StoneColor.BLACK)));
|
||||
higherValueSettings.setHighestCard(17);
|
||||
lowerValueSettings.setHighestCard(10);
|
||||
higherValueSettings.setHighestValue(17);
|
||||
lowerValueSettings.setHighestValue(10);
|
||||
}
|
||||
|
||||
private void assertSet(StoneSet.Type expectedType, Integer expectedValue,
|
||||
|
|
Reference in a new issue