diff options
author | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-13 18:22:55 +0200 |
---|---|---|
committer | Ida Massow <massow@informatik.uni-luebeck.de> | 2011-06-13 18:22:55 +0200 |
commit | 70d6ae6d749d11ced007fa781ce65c6e27229007 (patch) | |
tree | 67beb90aeafcc48130188cf54dfc8b8847b62db0 | |
parent | a4faa8db23589930a828250816ebaeddf787c689 (diff) | |
download | JRummikub-70d6ae6d749d11ced007fa781ce65c6e27229007.tar JRummikub-70d6ae6d749d11ced007fa781ce65c6e27229007.zip |
Player Type in player settings verschoben
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@420 72836036-5685-4462-b002-a69064685172
-rw-r--r-- | mock/jrummikub/view/MockSettingsPanel.java | 5 | ||||
-rw-r--r-- | src/jrummikub/control/RoundControl.java | 2 | ||||
-rw-r--r-- | src/jrummikub/control/SettingsControl.java | 39 | ||||
-rw-r--r-- | src/jrummikub/control/turn/TurnControlFactory.java | 14 | ||||
-rw-r--r-- | src/jrummikub/model/PlayerSettings.java | 28 | ||||
-rw-r--r-- | src/jrummikub/view/ISettingsPanel.java | 4 | ||||
-rw-r--r-- | src/jrummikub/view/impl/SettingsPanel.java | 112 | ||||
-rw-r--r-- | test/jrummikub/control/SettingsControlTest.java | 28 | ||||
-rw-r--r-- | test/jrummikub/control/turn/BaseAIControlTest.java | 15 |
9 files changed, 132 insertions, 115 deletions
diff --git a/mock/jrummikub/view/MockSettingsPanel.java b/mock/jrummikub/view/MockSettingsPanel.java index d0ac7c6..7689672 100644 --- a/mock/jrummikub/view/MockSettingsPanel.java +++ b/mock/jrummikub/view/MockSettingsPanel.java @@ -4,9 +4,8 @@ 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.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; @@ -27,7 +26,7 @@ public class MockSettingsPanel implements ISettingsPanel { /** */ public MockEvent2<Integer, String> changePlayerNameEvent = new MockEvent2<Integer, String>(); /** */ - public MockEvent2<Integer, TurnControlFactory.Type> changePlayerTypeEvent = new MockEvent2<Integer, TurnControlFactory.Type>(); + public MockEvent2<Integer, Type> changePlayerTypeEvent = new MockEvent2<Integer, Type>(); /** */ public MockEvent startGameEvent = new MockEvent(); /** */ diff --git a/src/jrummikub/control/RoundControl.java b/src/jrummikub/control/RoundControl.java index 281b367..a420b6d 100644 --- a/src/jrummikub/control/RoundControl.java +++ b/src/jrummikub/control/RoundControl.java @@ -1,6 +1,6 @@ package jrummikub.control; -import static jrummikub.control.turn.TurnControlFactory.Type.*; +import static jrummikub.model.PlayerSettings.Type.*; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/jrummikub/control/SettingsControl.java b/src/jrummikub/control/SettingsControl.java index ad88b70..0da2f19 100644 --- a/src/jrummikub/control/SettingsControl.java +++ b/src/jrummikub/control/SettingsControl.java @@ -6,10 +6,9 @@ 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.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.Connection; import jrummikub.util.Event1; @@ -34,9 +33,9 @@ public class SettingsControl { * Create a new settings control * * @param view - * the view to use + * the view to use * @param settings - * initial game settings + * initial game settings */ public SettingsControl(IView view, GameSettings settings) { this.view = view; @@ -44,8 +43,8 @@ public class SettingsControl { } /** - * the start game event is emitted when the user wants to start a game and the - * settings made are valid + * the start game event is emitted when the user wants to start a game and + * the settings made are valid * * @return the event */ @@ -78,7 +77,8 @@ public class SettingsControl { private void addOptionListeners1() { connections.add(view.getSettingsPanel() - .getChangeInitialMeldThresholdEvent().add(new IListener1<Integer>() { + .getChangeInitialMeldThresholdEvent() + .add(new IListener1<Integer>() { @Override public void handle(Integer value) { settings.setInitialMeldThreshold(value); @@ -103,7 +103,8 @@ public class SettingsControl { update(); } })); - connections.add(view.getSettingsPanel().getChangeNumberOfStonesDealtEvent() + connections.add(view.getSettingsPanel() + .getChangeNumberOfStonesDealtEvent() .add(new IListener1<Integer>() { @Override public void handle(Integer value) { @@ -206,9 +207,9 @@ public class SettingsControl { } })); connections.add(view.getSettingsPanel().getChangePlayerTypeEvent() - .add(new IListener2<Integer, TurnControlFactory.Type>() { + .add(new IListener2<Integer, Type>() { @Override - public void handle(Integer i, TurnControlFactory.Type type) { + public void handle(Integer i, Type type) { setPlayerType(i, type); } })); @@ -246,7 +247,8 @@ public class SettingsControl { break; } - settings.getPlayerList().add(new PlayerSettings("Spieler " + num, color)); + settings.getPlayerList().add( + new PlayerSettings("Spieler " + num, color)); update(); } @@ -287,8 +289,9 @@ public class SettingsControl { protected void update() { view.getSettingsPanel().enableRemovePlayerButtons( settings.getPlayerList().size() > 2); - view.getSettingsPanel().enableAddPlayerButton( - settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); + view.getSettingsPanel() + .enableAddPlayerButton( + settings.getPlayerList().size() < ISettingsPanel.PLAYER_COLORS.length); checkSettings(); @@ -322,8 +325,9 @@ public class SettingsControl { 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_ERROR); + view.getSettingsPanel() + .setError( + ISettingsPanel.SettingsError.DUPLICATE_PLAYER_NAME_ERROR); view.getSettingsPanel().enableStartGameButton(false); return false; } @@ -332,7 +336,8 @@ public class SettingsControl { int totalStonesDealt = settings.getNumberOfStonesDealt() * settings.getPlayerList().size(); - int totalStones = settings.getHighestValue() * settings.getStoneSetNumber() + int totalStones = settings.getHighestValue() + * settings.getStoneSetNumber() * settings.getStoneColors().size() + settings.getJokerNumber(); if (totalStones <= totalStonesDealt) { @@ -361,7 +366,7 @@ public class SettingsControl { boolean humanPlayerFound = false; for (PlayerSettings player : settings.getPlayerList()) { - if (player.getTurnControlType() == TurnControlFactory.Type.HUMAN) { + if (player.getTurnControlType() == Type.HUMAN) { humanPlayerFound = true; break; } diff --git a/src/jrummikub/control/turn/TurnControlFactory.java b/src/jrummikub/control/turn/TurnControlFactory.java index b42f7ff..4d143e7 100644 --- a/src/jrummikub/control/turn/TurnControlFactory.java +++ b/src/jrummikub/control/turn/TurnControlFactory.java @@ -1,5 +1,7 @@ package jrummikub.control.turn; +import jrummikub.model.PlayerSettings; + /** * Creates a turn control for the active player, regarding if layer is human or * computer @@ -7,16 +9,6 @@ package jrummikub.control.turn; */ public abstract class TurnControlFactory { /** - * Type of turn control. - */ - public enum Type { - /** */ - HUMAN, - /** */ - COMPUTER - }; - - /** * Creates a new turn control instance * * @return the turn control @@ -30,7 +22,7 @@ public abstract class TurnControlFactory { * Human or Computer * @return TurnControlFactory for the player kind */ - static public TurnControlFactory getFactory(Type type) { + static public TurnControlFactory getFactory(PlayerSettings.Type type) { switch (type) { case HUMAN: return HumanTurnControl.getFactory(); diff --git a/src/jrummikub/model/PlayerSettings.java b/src/jrummikub/model/PlayerSettings.java index 17e521c..afa610c 100644 --- a/src/jrummikub/model/PlayerSettings.java +++ b/src/jrummikub/model/PlayerSettings.java @@ -9,24 +9,34 @@ import jrummikub.control.turn.TurnControlFactory; * The settings of a player */ public class PlayerSettings implements Serializable { + /** + * Type of turn control. + */ + public enum Type { + /** */ + HUMAN, + /** */ + COMPUTER + } + private static final long serialVersionUID = 1963640115089275992L; private String name; private Color color; - private TurnControlFactory.Type turnControlType; + private Type turnControlType; /** * Create a new human player * * @param name - * the player's name + * the player's name * @param color - * the player's color + * the player's color */ public PlayerSettings(String name, Color color) { this.name = name; this.color = color; - this.turnControlType = TurnControlFactory.Type.HUMAN; + this.turnControlType = Type.HUMAN; } /** @@ -51,7 +61,7 @@ public class PlayerSettings implements Serializable { * Sets the player's color * * @param color - * the new color + * the new color */ public void setColor(Color color) { this.color = color; @@ -61,7 +71,7 @@ public class PlayerSettings implements Serializable { * Sets the player's name * * @param name - * the new name + * the new name */ public void setName(String name) { this.name = name; @@ -71,9 +81,9 @@ public class PlayerSettings implements Serializable { * Set the player's TurnControlFactory type * * @param turnControlType - * player's TurnControlFactory type + * player's TurnControlFactory type */ - public void setTurnControlType(TurnControlFactory.Type turnControlType) { + public void setTurnControlType(Type turnControlType) { this.turnControlType = turnControlType; } @@ -82,7 +92,7 @@ public class PlayerSettings implements Serializable { * * @return player's TurnControlFactory type */ - public TurnControlFactory.Type getTurnControlType() { + public Type getTurnControlType() { return turnControlType; } } diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java index 4fca9ad..e5a73ed 100644 --- a/src/jrummikub/view/ISettingsPanel.java +++ b/src/jrummikub/view/ISettingsPanel.java @@ -3,8 +3,8 @@ package jrummikub.view; import java.awt.Color; import java.util.Set; -import jrummikub.control.turn.TurnControlFactory; import jrummikub.model.GameSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; @@ -73,7 +73,7 @@ public interface ISettingsPanel { * * @return the event */ - public IEvent2<Integer, TurnControlFactory.Type> getChangePlayerTypeEvent(); + public IEvent2<Integer, Type> getChangePlayerTypeEvent(); /** * The change initial meld threshold event is emitted when the user wants diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java index 271be53..cc34a35 100644 --- a/src/jrummikub/view/impl/SettingsPanel.java +++ b/src/jrummikub/view/impl/SettingsPanel.java @@ -48,9 +48,9 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import jrummikub.control.turn.TurnControlFactory; -import jrummikub.control.turn.TurnControlFactory.Type; import jrummikub.model.GameSettings; import jrummikub.model.PlayerSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.Event; import jrummikub.util.Event1; @@ -93,7 +93,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel { private Event1<Integer> removePlayerEvent = new Event1<Integer>(); private Event2<Integer, Color> changePlayerColorEvent = new Event2<Integer, Color>(); private Event2<Integer, String> changePlayerNameEvent = new Event2<Integer, String>(); - private Event2<Integer, TurnControlFactory.Type> changePlayerTypeEvent = new Event2<Integer, TurnControlFactory.Type>(); + private Event2<Integer, Type> changePlayerTypeEvent = new Event2<Integer, Type>(); private Event1<Integer> changeInitialMeldThresholdEvent = new Event1<Integer>(); private Event1<Integer> changeJokerNumberEvent = new Event1<Integer>(); private Event1<Integer> changeStoneSetNumberEvent = new Event1<Integer>(); @@ -196,37 +196,37 @@ class SettingsPanel extends JPanel implements ISettingsPanel { @Override public void setError(SettingsError error) { switch (error) { - case NO_ERROR: - errorMessageLabel.setText(" "); - break; - case DUPLICATE_PLAYER_NAME_ERROR: - errorMessageLabel - .setText("Jeder Spielername darf nur einmal verwendet werden."); - errorMessageLabel.setForeground(Color.RED); - break; - case NO_PLAYER_NAME_ERROR: - errorMessageLabel.setText("Jeder Spieler muss einen Namen haben."); - errorMessageLabel.setForeground(Color.RED); - break; - case NOT_ENOUGH_STONES_ERROR: - errorMessageLabel - .setText("Es gibt nicht genug Steine f\u00fcr die gew\u00e4hlte Spieleranzahl."); - errorMessageLabel.setForeground(Color.RED); - break; - case NOT_ENOUGH_COLORS_ERROR: - errorMessageLabel - .setText("Es m\u00fcssen mindestens drei Farben ausgew\u00e4hlt werden."); - errorMessageLabel.setForeground(Color.RED); - break; - case COMPUTER_PLAYERS_ONLY_WARNING: - errorMessageLabel.setText("Es gibt keinen menschlichen Spieler."); - errorMessageLabel.setForeground(Color.ORANGE.darker()); - break; - case TOO_HIGH_THRESHOLD_WARNING: - errorMessageLabel - .setText("Die gew\u00e4hlte Schranke ist m\u00f6glicherweise zu hoch"); - errorMessageLabel.setForeground(Color.ORANGE.darker()); - break; + case NO_ERROR: + errorMessageLabel.setText(" "); + break; + case DUPLICATE_PLAYER_NAME_ERROR: + errorMessageLabel + .setText("Jeder Spielername darf nur einmal verwendet werden."); + errorMessageLabel.setForeground(Color.RED); + break; + case NO_PLAYER_NAME_ERROR: + errorMessageLabel.setText("Jeder Spieler muss einen Namen haben."); + errorMessageLabel.setForeground(Color.RED); + break; + case NOT_ENOUGH_STONES_ERROR: + errorMessageLabel + .setText("Es gibt nicht genug Steine f\u00fcr die gew\u00e4hlte Spieleranzahl."); + errorMessageLabel.setForeground(Color.RED); + break; + case NOT_ENOUGH_COLORS_ERROR: + errorMessageLabel + .setText("Es m\u00fcssen mindestens drei Farben ausgew\u00e4hlt werden."); + errorMessageLabel.setForeground(Color.RED); + break; + case COMPUTER_PLAYERS_ONLY_WARNING: + errorMessageLabel.setText("Es gibt keinen menschlichen Spieler."); + errorMessageLabel.setForeground(Color.ORANGE.darker()); + break; + case TOO_HIGH_THRESHOLD_WARNING: + errorMessageLabel + .setText("Die gew\u00e4hlte Schranke ist m\u00f6glicherweise zu hoch"); + errorMessageLabel.setForeground(Color.ORANGE.darker()); + break; } } @@ -251,7 +251,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { @Override public void setGameSettings(GameSettings gameSettings) { - while (playerSettingsPanels.size() > gameSettings.getPlayerList().size()) { + while (playerSettingsPanels.size() > gameSettings.getPlayerList() + .size()) { removePlayerSettingsPanel(); } @@ -259,11 +260,12 @@ class SettingsPanel extends JPanel implements ISettingsPanel { updatePlayerSettingsPanel(i, gameSettings.getPlayerList().get(i)); } - initialMeldThresholdSpinner - .setValue(gameSettings.getInitialMeldThreshold()); + initialMeldThresholdSpinner.setValue(gameSettings + .getInitialMeldThreshold()); stoneSetNumberSpinner.setValue(gameSettings.getStoneSetNumber()); highestValueSpinner.setValue(gameSettings.getHighestValue()); - numberOfStonesDealtSpinner.setValue(gameSettings.getNumberOfStonesDealt()); + numberOfStonesDealtSpinner.setValue(gameSettings + .getNumberOfStonesDealt()); jokerNumberSpinner.setValue(gameSettings.getJokerNumber()); timeSpinner.setValue(gameSettings.getTotalTime()); noLimitsBox.setSelected(gameSettings.isNoLimits()); @@ -292,8 +294,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { } private void removePlayerSettingsPanel() { - PlayerSettingsPanel p = playerSettingsPanels.remove(playerSettingsPanels - .size() - 1); + PlayerSettingsPanel p = playerSettingsPanels + .remove(playerSettingsPanels.size() - 1); playerSettingsViewport.remove(p); } @@ -315,7 +317,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { playerSettingsViewport.add(addPlayerPanel); addPlayerButton = new JButton("+"); - addPlayerButton.setFont(addPlayerButton.getFont().deriveFont(Font.BOLD)); + addPlayerButton + .setFont(addPlayerButton.getFont().deriveFont(Font.BOLD)); addPlayerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -480,8 +483,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { c.insets = new Insets(2, 2, 2, 2); final JSpinner spinner = new JSpinner(); spinner.setModel(new SpinnerNumberModel(min, min, max, step)); - spinner - .setPreferredSize(new Dimension(60, spinner.getMinimumSize().height)); + spinner.setPreferredSize(new Dimension(60, + spinner.getMinimumSize().height)); spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -544,8 +547,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { c.gridwidth = GridBagConstraints.REMAINDER; addButton("Netzwerkspiel...", networkGameEvent, c); - setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder( - 10, 10, 10, 10))); + setBorder(new CompoundBorder(new LineBorder(Color.BLACK), + new EmptyBorder(10, 10, 10, 10))); } void resetTabbedPane() { @@ -577,13 +580,13 @@ class SettingsPanel extends JPanel implements ISettingsPanel { nameField.setText(settings.getName()); } // playerType.setSelectedIndex(0); - int index = Arrays.binarySearch(TurnControlFactory.Type.values(), + int index = Arrays.binarySearch(Type.values(), settings.getTurnControlType()); if (index != playerType.getSelectedIndex()) { playerType.setSelectedIndex(index); } - colorButton - .setIcon(ImageUtil.createColorIcon(settings.getColor(), 16, 2)); + colorButton.setIcon(ImageUtil.createColorIcon(settings.getColor(), + 16, 2)); } public void enableRemoveButton(boolean enable) { @@ -631,7 +634,8 @@ class SettingsPanel extends JPanel implements ISettingsPanel { c.gridy = 0; add(colorButton, c); - nameField.getDocument().addDocumentListener(new NameChangeListener()); + nameField.getDocument().addDocumentListener( + new NameChangeListener()); c2.gridy = 0; c2.weightx = 1; c2.fill = GridBagConstraints.HORIZONTAL; @@ -664,8 +668,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel { public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); for (Component component : this.getComponents()) { - preferredSize - .setSize(preferredSize.width, Math.max(preferredSize.height, + preferredSize.setSize( + preferredSize.width, + Math.max(preferredSize.height, component.getPreferredSize().height)); } return preferredSize; @@ -675,8 +680,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel { public Dimension getMaximumSize() { Dimension preferredSize = super.getPreferredSize(); for (Component component : this.getComponents()) { - preferredSize - .setSize(Integer.MAX_VALUE, Math.max(preferredSize.height, + preferredSize.setSize( + Integer.MAX_VALUE, + Math.max(preferredSize.height, component.getPreferredSize().height)); } return preferredSize; @@ -692,7 +698,7 @@ class SettingsPanel extends JPanel implements ISettingsPanel { private void changeType() { changePlayerTypeEvent.emit(playerNumber, - TurnControlFactory.Type.values()[playerType.getSelectedIndex()]); + Type.values()[playerType.getSelectedIndex()]); } private void remove() { diff --git a/test/jrummikub/control/SettingsControlTest.java b/test/jrummikub/control/SettingsControlTest.java index 534904d..a8e9849 100644 --- a/test/jrummikub/control/SettingsControlTest.java +++ b/test/jrummikub/control/SettingsControlTest.java @@ -9,6 +9,7 @@ import java.util.HashSet; import jrummikub.control.turn.TurnControlFactory; import jrummikub.model.GameSettings; +import jrummikub.model.PlayerSettings.Type; import jrummikub.model.StoneColor; import jrummikub.util.IListener1; import jrummikub.view.ISettingsPanel; @@ -41,7 +42,8 @@ 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()); @@ -162,7 +164,8 @@ 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); @@ -243,8 +246,8 @@ public class SettingsControlTest { assertEquals(initialSettings.getStoneColors(), view.settingsPanel.stoneColors); - view.settingsPanel.changeStoneColorsEvent.emit(new HashSet<StoneColor>(Arrays.asList( - BLUE, RED, BLACK))); + 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()); @@ -253,19 +256,16 @@ public class SettingsControlTest { /** */ @Test public void typeChangeTest() { - view.settingsPanel.changePlayerTypeEvent.emit(0, - TurnControlFactory.Type.COMPUTER); - view.settingsPanel.changePlayerTypeEvent.emit(1, - TurnControlFactory.Type.COMPUTER); - view.settingsPanel.changePlayerTypeEvent.emit(1, - TurnControlFactory.Type.HUMAN); + view.settingsPanel.changePlayerTypeEvent.emit(0, Type.COMPUTER); + view.settingsPanel.changePlayerTypeEvent.emit(1, Type.COMPUTER); + view.settingsPanel.changePlayerTypeEvent.emit(1, Type.HUMAN); 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(Type.COMPUTER, gameSettings.getPlayerList().get(0) + .getTurnControlType()); + assertSame(Type.HUMAN, gameSettings.getPlayerList().get(1) + .getTurnControlType()); } } diff --git a/test/jrummikub/control/turn/BaseAIControlTest.java b/test/jrummikub/control/turn/BaseAIControlTest.java index fe06398..51b1f1f 100644 --- a/test/jrummikub/control/turn/BaseAIControlTest.java +++ b/test/jrummikub/control/turn/BaseAIControlTest.java @@ -10,6 +10,7 @@ import jrummikub.model.IPlayer; import jrummikub.model.ITable;
import jrummikub.model.Player;
import jrummikub.model.PlayerSettings;
+import jrummikub.model.PlayerSettings.Type;
import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
@@ -36,8 +37,7 @@ public class BaseAIControlTest { /** */
@Before
public void setUp() {
- aiControl = TurnControlFactory.getFactory(TurnControlFactory.Type.COMPUTER)
- .create();
+ aiControl = TurnControlFactory.getFactory(Type.COMPUTER).create();
gameSettings = new GameSettings();
playerSettings = new PlayerSettings("ROBOT_01", Color.GRAY);
player = new Player(playerSettings);
@@ -75,7 +75,8 @@ public class BaseAIControlTest { */
@Test(timeout = 10000)
public void testTurnZeroRedealing() throws InterruptedException {
- aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.MAY_REDEAL), gameSettings, view);
+ aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(),
+ player.getLaidOut(), TurnMode.MAY_REDEAL), gameSettings, view);
aiControl.startTurn();
while (!redealt) {
Thread.sleep(100);
@@ -89,7 +90,10 @@ public class BaseAIControlTest { */
@Test(timeout = 10000)
public void testTurnZeroNotMelding() throws InterruptedException {
- aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.INSPECT_ONLY), gameSettings, view);
+ aiControl
+ .setup(new ITurnControl.TurnInfo(table, player.getHand(),
+ player.getLaidOut(), TurnMode.INSPECT_ONLY),
+ gameSettings, view);
aiControl.startTurn();
while (!turnEnded) {
Thread.sleep(100);
@@ -103,7 +107,8 @@ public class BaseAIControlTest { */
@Test(timeout = 10000)
public void testNormalTurnMelding() throws InterruptedException {
- aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(), player.getLaidOut(), TurnMode.NORMAL_TURN), gameSettings, view);
+ aiControl.setup(new ITurnControl.TurnInfo(table, player.getHand(),
+ player.getLaidOut(), TurnMode.NORMAL_TURN), gameSettings, view);
aiControl.startTurn();
while (!turnEnded) {
Thread.sleep(100);
|