Implement settings control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@291 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
5029ff206a
commit
5aa79ea898
4 changed files with 268 additions and 55 deletions
|
@ -8,56 +8,188 @@ import jrummikub.util.Event1;
|
||||||
import jrummikub.util.IEvent1;
|
import jrummikub.util.IEvent1;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
import jrummikub.util.IListener1;
|
import jrummikub.util.IListener1;
|
||||||
|
import jrummikub.util.IListener2;
|
||||||
|
import jrummikub.view.ISettingsPanel;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The settings control controls the settings panel
|
||||||
|
*/
|
||||||
public class SettingsControl {
|
public class SettingsControl {
|
||||||
private IView view;
|
private IView view;
|
||||||
private Event1<GameSettings> startGameEvent = new Event1<GameSettings>();
|
private Event1<GameSettings> startGameEvent = new Event1<GameSettings>();
|
||||||
|
|
||||||
|
private GameSettings settings = new GameSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new settings control
|
||||||
|
*
|
||||||
|
* @param view
|
||||||
|
* the view to use
|
||||||
|
*/
|
||||||
public SettingsControl(IView view) {
|
public SettingsControl(IView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
|
addPlayer();
|
||||||
|
addPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the start game event is emitted when the user wants to start a game and the
|
||||||
|
* settings made are valid
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<GameSettings> getStartGameEvent() {
|
public IEvent1<GameSettings> getStartGameEvent() {
|
||||||
return startGameEvent;
|
return startGameEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startSettings() {
|
/**
|
||||||
/*
|
* Start the operation of the settings control
|
||||||
* view.getSettingsPanel().getSettingsChangeEvent() .add(new
|
|
||||||
* IListener1<GameSettings>() {
|
|
||||||
*
|
|
||||||
* @Override public void handle(GameSettings settings) {
|
|
||||||
* checkSettings(settings); } });
|
|
||||||
* view.getSettingsPanel().getStartGameEvent() .add(new
|
|
||||||
* IListener1<GameSettings>() {
|
|
||||||
*
|
|
||||||
* @Override public void handle(GameSettings settings) {
|
|
||||||
* startGame(settings); } });
|
|
||||||
*/
|
*/
|
||||||
// TODO vvv this is just a temp. fix
|
public void startSettings() {
|
||||||
view.getSettingsPanel().getStartGameEvent().add(new IListener() {
|
view.getSettingsPanel().getStartGameEvent().add(new IListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
GameSettings defaultSettings = new GameSettings();
|
startGame();
|
||||||
defaultSettings.getPlayerList().add(new PlayerSettings("Foo", new Color(1.0f, 0, 0)));
|
|
||||||
defaultSettings.getPlayerList().add(new PlayerSettings("Bar", new Color(0, 1.0f, 0)));
|
|
||||||
startGame(defaultSettings);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
view.getSettingsPanel().getAddPlayerEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
addPlayer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
view.getSettingsPanel().getRemovePlayerEvent()
|
||||||
|
.add(new IListener1<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void handle(Integer i) {
|
||||||
|
removePlayer(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
view.getSettingsPanel().getChangePlayerColorEvent()
|
||||||
|
.add(new IListener2<Integer, Color>() {
|
||||||
|
@Override
|
||||||
|
public void handle(Integer i, Color color) {
|
||||||
|
setPlayerColor(i, color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
view.getSettingsPanel().getChangePlayerNameEvent()
|
||||||
|
.add(new IListener2<Integer, String>() {
|
||||||
|
@Override
|
||||||
|
public void handle(Integer i, String name) {
|
||||||
|
setPlayerName(i, name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
view.showSettingsPanel(true);
|
view.showSettingsPanel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkSettings(GameSettings settings) {
|
private void addPlayer() {
|
||||||
// TODO Check
|
if (settings.getPlayerList().size() >= ISettingsPanel.PLAYER_COLORS.length) {
|
||||||
// TODO Show error
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find unused player name
|
||||||
|
int num = settings.getPlayerList().size();
|
||||||
|
|
||||||
|
nameLoop: while (true) {
|
||||||
|
num++;
|
||||||
|
String playerName = "Spieler " + num;
|
||||||
|
|
||||||
|
for (PlayerSettings player : settings.getPlayerList()) {
|
||||||
|
if (playerName.equals(player.getName())) {
|
||||||
|
continue nameLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, find unused color
|
||||||
|
Color color = null;
|
||||||
|
colorLoop: for (Color c : ISettingsPanel.PLAYER_COLORS) {
|
||||||
|
color = c;
|
||||||
|
for (PlayerSettings player : settings.getPlayerList()) {
|
||||||
|
if (c == player.getColor()) {
|
||||||
|
continue colorLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.getPlayerList().add(new PlayerSettings("Spieler " + num, color));
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePlayer(int i) {
|
||||||
|
settings.getPlayerList().remove(i);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPlayerColor(int i, Color color) {
|
||||||
|
PlayerSettings player = settings.getPlayerList().get(i);
|
||||||
|
|
||||||
|
if (player.getColor() == color) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PlayerSettings other : settings.getPlayerList()) {
|
||||||
|
if (other.getColor() == color) {
|
||||||
|
other.setColor(player.getColor());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setColor(color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPlayerName(int i, String name) {
|
||||||
|
settings.getPlayerList().get(i).setName(name);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update() {
|
||||||
|
view.getSettingsPanel().enableRemovePlayerButtons(
|
||||||
|
settings.getPlayerList().size() > 2);
|
||||||
|
view.getSettingsPanel().enableAddPlayerButton(
|
||||||
|
settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length);
|
||||||
|
|
||||||
|
checkSettings();
|
||||||
|
|
||||||
|
view.getSettingsPanel().setGameSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkSettings() {
|
||||||
|
for (PlayerSettings player : settings.getPlayerList()) {
|
||||||
|
if (player.getName().isEmpty()) {
|
||||||
|
view.getSettingsPanel().setError(
|
||||||
|
ISettingsPanel.SettingsError.NO_PLAYER_NAME);
|
||||||
|
view.getSettingsPanel().enableStartGameButton(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < settings.getPlayerList().size(); ++i) {
|
||||||
|
String name = settings.getPlayerList().get(i).getName();
|
||||||
|
|
||||||
|
for (int j = i + 1; j < settings.getPlayerList().size(); ++j) {
|
||||||
|
if (settings.getPlayerList().get(j).getName().equals(name)) {
|
||||||
|
view.getSettingsPanel().setError(
|
||||||
|
ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME);
|
||||||
|
view.getSettingsPanel().enableStartGameButton(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view.getSettingsPanel().setError(ISettingsPanel.SettingsError.NO_ERROR);
|
||||||
|
view.getSettingsPanel().enableStartGameButton(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGame(GameSettings settings) {
|
private void startGame() {
|
||||||
if (!checkSettings(settings)) {
|
if (!checkSettings()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,65 @@ import jrummikub.util.IEvent2;
|
||||||
* The panel for the game setup
|
* The panel for the game setup
|
||||||
*/
|
*/
|
||||||
public interface ISettingsPanel {
|
public interface ISettingsPanel {
|
||||||
|
/**
|
||||||
|
* The list of player colors
|
||||||
|
*/
|
||||||
|
public final static Color[] PLAYER_COLORS = { new Color(1.0f, 0, 0), // red
|
||||||
|
new Color(0, 1.0f, 0), // lime
|
||||||
|
new Color(1.0f, 1.0f, 0), // yellow
|
||||||
|
new Color(0, 0, 1.0f), // blue
|
||||||
|
new Color(1.0f, 0, 1.0f), // fuchsia
|
||||||
|
new Color(0, 1.0f, 1.0f), // aqua
|
||||||
|
new Color(0.5f, 0, 0), // maroon
|
||||||
|
new Color(0, 0.5f, 0), // green
|
||||||
|
new Color(0.5f, 0.5f, 0), // olive
|
||||||
|
new Color(0, 0, 0.5f), // navy
|
||||||
|
new Color(0.5f, 0, 0.5f), // purple
|
||||||
|
new Color(0, 0.5f, 0.5f), // teal
|
||||||
|
new Color(0, 0, 0), // black
|
||||||
|
new Color(0.5f, 0.5f, 0.5f), // gray
|
||||||
|
new Color(0.75f, 0.75f, 0.75f), // silver
|
||||||
|
new Color(1.0f, 1.0f, 1.0f), // white
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The add player event is emitted when the user wants to add a player to the
|
||||||
|
* player list
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent getAddPlayerEvent();
|
public IEvent getAddPlayerEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The remove player event is emitted when the user wants to remove a player
|
||||||
|
* remove the player list
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<Integer> getRemovePlayerEvent();
|
public IEvent1<Integer> getRemovePlayerEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change player color event is emitted when the user wants change a
|
||||||
|
* player's color
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent2<Integer, Color> getChangePlayerColorEvent();
|
public IEvent2<Integer, Color> getChangePlayerColorEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change player color event is emitted when the user wants change a
|
||||||
|
* player's name
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent2<Integer, String> getChangePlayerNameEvent();
|
public IEvent2<Integer, String> getChangePlayerNameEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change initial meld threshold event is emitted when the user wants
|
||||||
|
* change the initial meld threshold
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<Integer> getChangeInitialMeldThresholdEvent();
|
public IEvent1<Integer> getChangeInitialMeldThresholdEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,17 +79,56 @@ public interface ISettingsPanel {
|
||||||
*/
|
*/
|
||||||
public IEvent getStartGameEvent();
|
public IEvent getStartGameEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets an error to display
|
||||||
|
*
|
||||||
|
* @param error
|
||||||
|
* the kind of error
|
||||||
|
*/
|
||||||
public void setError(SettingsError error);
|
public void setError(SettingsError error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the start game button
|
||||||
|
*
|
||||||
|
* @param enable
|
||||||
|
* specifies if the button is to be enabled or disabled
|
||||||
|
*/
|
||||||
public void enableStartGameButton(boolean enable);
|
public void enableStartGameButton(boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the add player button
|
||||||
|
*
|
||||||
|
* @param enable
|
||||||
|
* specifies if the button is to be enabled or disabled
|
||||||
|
*/
|
||||||
public void enableAddPlayerButton(boolean enable);
|
public void enableAddPlayerButton(boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables the remove player buttons
|
||||||
|
*
|
||||||
|
* @param enable
|
||||||
|
* specifies if the buttons are to be enabled or disabled
|
||||||
|
*/
|
||||||
|
|
||||||
public void enableRemovePlayerButtons(boolean enable);
|
public void enableRemovePlayerButtons(boolean enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the game settings to display
|
||||||
|
*
|
||||||
|
* @param gameSettings
|
||||||
|
* the settings
|
||||||
|
*/
|
||||||
public void setGameSettings(GameSettings gameSettings);
|
public void setGameSettings(GameSettings gameSettings);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the different kinds of settings errors that can be displayed
|
||||||
|
*/
|
||||||
public enum SettingsError {
|
public enum SettingsError {
|
||||||
NO_ERROR, DUPLICATE_PLAYER_NAME, NO_PLAYER_NAME
|
/** Everything is ok */
|
||||||
|
NO_ERROR,
|
||||||
|
/** A player name is used twice */
|
||||||
|
DUPLICATE_PLAYER_NAME,
|
||||||
|
/** A player has an empty name */
|
||||||
|
NO_PLAYER_NAME
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,24 +40,6 @@ import jrummikub.view.ISettingsPanel;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class SettingsPanel extends JPanel implements ISettingsPanel {
|
class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
private final static Color[] PLAYER_COLORS = { new Color(1.0f, 0, 0), // red
|
|
||||||
new Color(0, 1.0f, 0), // lime
|
|
||||||
new Color(1.0f, 1.0f, 0), // yellow
|
|
||||||
new Color(0, 0, 1.0f), // blue
|
|
||||||
new Color(1.0f, 0, 1.0f), // fuchsia
|
|
||||||
new Color(0, 1.0f, 1.0f), // aqua
|
|
||||||
new Color(0.5f, 0, 0), // maroon
|
|
||||||
new Color(0, 0.5f, 0), // green
|
|
||||||
new Color(0.5f, 0.5f, 0), // olive
|
|
||||||
new Color(0, 0, 0.5f), // navy
|
|
||||||
new Color(0.5f, 0, 0.5f), // purple
|
|
||||||
new Color(0, 0.5f, 0.5f), // teal
|
|
||||||
new Color(0, 0, 0), // black
|
|
||||||
new Color(0.5f, 0.5f, 0.5f), // gray
|
|
||||||
new Color(0.75f, 0.75f, 0.75f), // silver
|
|
||||||
new Color(1.0f, 1.0f, 1.0f), // white
|
|
||||||
};
|
|
||||||
|
|
||||||
private JPanel playerSetupPanel;
|
private JPanel playerSetupPanel;
|
||||||
private JPanel playerSettingsViewport;
|
private JPanel playerSettingsViewport;
|
||||||
private JPanel ruleSetupPanel;
|
private JPanel ruleSetupPanel;
|
||||||
|
@ -97,8 +79,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerSettingsPanel panel = new PlayerSettingsPanel("Spieler " + num,
|
PlayerSettingsPanel panel = new PlayerSettingsPanel("Spieler " + num, color);
|
||||||
color);
|
|
||||||
playerSettingsPanels.add(panel);
|
playerSettingsPanels.add(panel);
|
||||||
playerSettingsViewport.add(panel,
|
playerSettingsViewport.add(panel,
|
||||||
playerSettingsViewport.getComponentCount() - 1);
|
playerSettingsViewport.getComponentCount() - 1);
|
||||||
|
@ -124,8 +105,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
playerSettingsViewport.add(addPlayerPanel);
|
playerSettingsViewport.add(addPlayerPanel);
|
||||||
|
|
||||||
JButton addPlayerButton = new JButton("+");
|
JButton addPlayerButton = new JButton("+");
|
||||||
addPlayerButton
|
addPlayerButton.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD));
|
||||||
.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD));
|
|
||||||
addPlayerButton.addActionListener(new ActionListener() {
|
addPlayerButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -175,8 +155,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
});
|
});
|
||||||
add(startButton, c);
|
add(startButton, c);
|
||||||
|
|
||||||
setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
|
setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(
|
||||||
new EmptyBorder(10, 10, 10, 10)));
|
10, 10, 10, 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerSettingsPanel extends JPanel {
|
private class PlayerSettingsPanel extends JPanel {
|
||||||
|
@ -195,8 +175,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColor() {
|
private void updateColor() {
|
||||||
colorButton.setIcon(ImageUtil.createColorIcon(settings.getColor(),
|
colorButton
|
||||||
16, 2));
|
.setIcon(ImageUtil.createColorIcon(settings.getColor(), 16, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setName() {
|
private void setName() {
|
||||||
|
|
|
@ -12,11 +12,13 @@ import jrummikub.view.MockView;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/** */
|
||||||
public class SettingsControlTest {
|
public class SettingsControlTest {
|
||||||
MockView view = new MockView();
|
MockView view = new MockView();
|
||||||
SettingsControl settingsControl = new SettingsControl(view);
|
SettingsControl settingsControl = new SettingsControl(view);
|
||||||
GameSettings gameSettings = null;
|
GameSettings gameSettings = null;
|
||||||
|
|
||||||
|
/** */
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() {
|
settingsControl.getStartGameEvent().add(new IListener1<GameSettings>() {
|
||||||
|
@ -24,21 +26,23 @@ public class SettingsControlTest {
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSettings value) {
|
public void handle(GameSettings value) {
|
||||||
gameSettings = value;
|
gameSettings = value;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
settingsControl.startSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void initialStateTest() {
|
public void initialStateTest() {
|
||||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR,
|
assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error);
|
||||||
view.settingsPanel.error);
|
|
||||||
view.settingsPanel.startGameEvent.emit();
|
view.settingsPanel.startGameEvent.emit();
|
||||||
assertNotNull(gameSettings);
|
assertNotNull(gameSettings);
|
||||||
assertEquals(2, gameSettings.getPlayerList().size());
|
assertEquals(2, gameSettings.getPlayerList().size());
|
||||||
assertFalse(view.settingsPanel.removePlayerButtonsEnabled);
|
assertFalse(view.settingsPanel.removePlayerButtonsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void addPlayerTest() {
|
public void addPlayerTest() {
|
||||||
view.settingsPanel.addPlayerEvent.emit();
|
view.settingsPanel.addPlayerEvent.emit();
|
||||||
|
@ -48,6 +52,7 @@ public class SettingsControlTest {
|
||||||
assertTrue(view.settingsPanel.removePlayerButtonsEnabled);
|
assertTrue(view.settingsPanel.removePlayerButtonsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void add14PlayerTest() {
|
public void add14PlayerTest() {
|
||||||
for (int i = 0; i < 14; i++) {
|
for (int i = 0; i < 14; i++) {
|
||||||
|
@ -60,6 +65,7 @@ public class SettingsControlTest {
|
||||||
assertFalse(view.settingsPanel.addPlayerButtonEnabled);
|
assertFalse(view.settingsPanel.addPlayerButtonEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void add14RemovePlayerTest() {
|
public void add14RemovePlayerTest() {
|
||||||
for (int i = 0; i < 14; i++) {
|
for (int i = 0; i < 14; i++) {
|
||||||
|
@ -73,6 +79,7 @@ public class SettingsControlTest {
|
||||||
assertTrue(view.settingsPanel.addPlayerButtonEnabled);
|
assertTrue(view.settingsPanel.addPlayerButtonEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void removePlayerTest() {
|
public void removePlayerTest() {
|
||||||
view.settingsPanel.addPlayerEvent.emit();
|
view.settingsPanel.addPlayerEvent.emit();
|
||||||
|
@ -83,6 +90,7 @@ public class SettingsControlTest {
|
||||||
assertFalse(view.settingsPanel.removePlayerButtonsEnabled);
|
assertFalse(view.settingsPanel.removePlayerButtonsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void takenColorTest() {
|
public void takenColorTest() {
|
||||||
Color color1 = Color.RED;
|
Color color1 = Color.RED;
|
||||||
|
@ -97,6 +105,7 @@ public class SettingsControlTest {
|
||||||
assertSame(color1, gameSettings.getPlayerList().get(1).getColor());
|
assertSame(color1, gameSettings.getPlayerList().get(1).getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void unusedColorTest() {
|
public void unusedColorTest() {
|
||||||
Color color1 = Color.RED;
|
Color color1 = Color.RED;
|
||||||
|
@ -112,6 +121,7 @@ public class SettingsControlTest {
|
||||||
assertSame(color3, gameSettings.getPlayerList().get(1).getColor());
|
assertSame(color3, gameSettings.getPlayerList().get(1).getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void takenNameTest() {
|
public void takenNameTest() {
|
||||||
String name1 = "Julia";
|
String name1 = "Julia";
|
||||||
|
@ -126,6 +136,7 @@ public class SettingsControlTest {
|
||||||
assertNull(gameSettings);
|
assertNull(gameSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void fixTakenNameTest() {
|
public void fixTakenNameTest() {
|
||||||
String name1 = "Julia";
|
String name1 = "Julia";
|
||||||
|
@ -143,13 +154,13 @@ public class SettingsControlTest {
|
||||||
view.settingsPanel.changePlayerNameEvent.emit(1, name2);
|
view.settingsPanel.changePlayerNameEvent.emit(1, name2);
|
||||||
|
|
||||||
assertTrue(view.settingsPanel.startButtonEnabled);
|
assertTrue(view.settingsPanel.startButtonEnabled);
|
||||||
assertSame(ISettingsPanel.SettingsError.NO_ERROR,
|
assertSame(ISettingsPanel.SettingsError.NO_ERROR, view.settingsPanel.error);
|
||||||
view.settingsPanel.error);
|
|
||||||
|
|
||||||
view.settingsPanel.startGameEvent.emit();
|
view.settingsPanel.startGameEvent.emit();
|
||||||
assertNotNull(gameSettings);
|
assertNotNull(gameSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
@Test
|
@Test
|
||||||
public void emptyNameTest() {
|
public void emptyNameTest() {
|
||||||
String name1 = "";
|
String name1 = "";
|
||||||
|
|
Reference in a new issue