Fixed all warnings (comments) but one, one TODO important
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@351 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
f1abd1b564
commit
c3b4eef14c
7 changed files with 75 additions and 18 deletions
|
@ -7,6 +7,11 @@ import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface containing shared methods of human and computer turn control
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// TODO zu viele parameter
|
||||||
public interface ITurnControl {
|
public interface ITurnControl {
|
||||||
/**
|
/**
|
||||||
* Start the turn
|
* Start the turn
|
||||||
|
|
|
@ -16,8 +16,16 @@ public abstract class TurnControlFactory {
|
||||||
COMPUTER
|
COMPUTER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public abstract ITurnControl create();
|
public abstract ITurnControl create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the turn control factory for the specified type
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* Human or Computer
|
||||||
|
* @return TurnControlFactory for the player kind
|
||||||
|
*/
|
||||||
static public TurnControlFactory getFactory(Type type) {
|
static public TurnControlFactory getFactory(Type type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HUMAN:
|
case HUMAN:
|
||||||
|
|
|
@ -49,6 +49,9 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
/**
|
/**
|
||||||
* Test for rule conflict within the StoneSet
|
* Test for rule conflict within the StoneSet
|
||||||
*
|
*
|
||||||
|
* @param settings
|
||||||
|
* GameSettings
|
||||||
|
*
|
||||||
* @return true when the set is valid according to the rules
|
* @return true when the set is valid according to the rules
|
||||||
*/
|
*/
|
||||||
public boolean isValid(GameSettings settings) {
|
public boolean isValid(GameSettings settings) {
|
||||||
|
@ -59,6 +62,9 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
* Test for rule conflict within the StoneSet and determine whether the set
|
* Test for rule conflict within the StoneSet and determine whether the set
|
||||||
* is a group or a run
|
* is a group or a run
|
||||||
*
|
*
|
||||||
|
* @param settings
|
||||||
|
* GameSettings
|
||||||
|
*
|
||||||
* @return GROUP or RUN for valid sets, INVALID otherwise
|
* @return GROUP or RUN for valid sets, INVALID otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -80,7 +86,8 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
} else if (stones.size() > settings.getStoneColors().size()) {
|
} else if (stones.size() > settings.getStoneColors().size()) {
|
||||||
return new Pair<Type, Integer>(
|
return new Pair<Type, Integer>(
|
||||||
RUN,
|
RUN,
|
||||||
(settings.getHighestValue() * (settings.getHighestValue() + 1))
|
(settings.getHighestValue() * (settings
|
||||||
|
.getHighestValue() + 1))
|
||||||
/ 2
|
/ 2
|
||||||
- (stones.size() - settings.getHighestValue())
|
- (stones.size() - settings.getHighestValue())
|
||||||
* (stones.size() - settings.getHighestValue() - 1)
|
* (stones.size() - settings.getHighestValue() - 1)
|
||||||
|
|
|
@ -19,6 +19,12 @@ public class Table extends StoneTray<StoneSet> implements ITable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for a table
|
||||||
|
*
|
||||||
|
* @param settings
|
||||||
|
* GameSettings
|
||||||
|
*/
|
||||||
public Table(GameSettings settings) {
|
public Table(GameSettings settings) {
|
||||||
gameSettings = settings;
|
gameSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ public interface ISettingsPanel {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The add player event is emitted when the user wants to add a player to the
|
* The add player event is emitted when the user wants to add a player to
|
||||||
* player list
|
* the player list
|
||||||
*
|
*
|
||||||
* @return the event
|
* @return the event
|
||||||
*/
|
*/
|
||||||
|
@ -83,12 +83,36 @@ public interface ISettingsPanel {
|
||||||
*/
|
*/
|
||||||
public IEvent1<Integer> getChangeInitialMeldThresholdEvent();
|
public IEvent1<Integer> getChangeInitialMeldThresholdEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change StoneSet number event is emitted when the user wants to use
|
||||||
|
* more or less than 2 StoneSets per color
|
||||||
|
*
|
||||||
|
* @return number of SoneSets
|
||||||
|
*/
|
||||||
public IEvent1<Integer> getChangeStoneSetNumberEvent();
|
public IEvent1<Integer> getChangeStoneSetNumberEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change number of Stones dealt event is emitted when the user wants to
|
||||||
|
* be dealt more or less than 14 Stones at the game start
|
||||||
|
*
|
||||||
|
* @return number of Stones dealt
|
||||||
|
*/
|
||||||
public IEvent1<Integer> getChangeNumberOfStonesDealtEvent();
|
public IEvent1<Integer> getChangeNumberOfStonesDealtEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change highest value event is emitted when the user wants to set the
|
||||||
|
* highest Stone value
|
||||||
|
*
|
||||||
|
* @return highest Stone value
|
||||||
|
*/
|
||||||
public IEvent1<Integer> getChangeHighestValueEvent();
|
public IEvent1<Integer> getChangeHighestValueEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The change Stone colors event is emitted when the user chooses the stone
|
||||||
|
* colors to play with. Minimum 3, maximum 8
|
||||||
|
*
|
||||||
|
* @return set of used StoneColors
|
||||||
|
*/
|
||||||
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent();
|
public IEvent1<Set<StoneColor>> getChangeStoneColorsEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ import jrummikub.util.IEvent;
|
||||||
class WinPanel extends JPanel {
|
class WinPanel extends JPanel {
|
||||||
private final static int PANEL_INSET = 15;
|
private final static int PANEL_INSET = 15;
|
||||||
private final static int PANEL_SEPARATOR = 10;
|
private final static int PANEL_SEPARATOR = 10;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private final static float PANEL_FIRST_LINE_HEIGHT = 0.375f;
|
private final static float PANEL_FIRST_LINE_HEIGHT = 0.375f;
|
||||||
private final static int PANEL_MAX_WIDTH = 180;
|
private final static int PANEL_MAX_WIDTH = 180;
|
||||||
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
private final static float MAX_BUTTON_FONT_SIZE = 12;
|
||||||
|
@ -100,7 +101,8 @@ class WinPanel extends JPanel {
|
||||||
private void rescale() {
|
private void rescale() {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
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;
|
||||||
|
|
||||||
if (width > PANEL_MAX_WIDTH) {
|
if (width > PANEL_MAX_WIDTH) {
|
||||||
x += (width - PANEL_MAX_WIDTH) / 4;
|
x += (width - PANEL_MAX_WIDTH) / 4;
|
||||||
|
@ -116,13 +118,14 @@ class WinPanel extends JPanel {
|
||||||
newRoundButton.setBounds(x, y, buttonWidth, buttonHeight);
|
newRoundButton.setBounds(x, y, buttonWidth, buttonHeight);
|
||||||
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
newRoundButton.setFont(newRoundButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y, buttonWidth,
|
newGameButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y,
|
||||||
buttonHeight);
|
buttonWidth, buttonHeight);
|
||||||
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y,
|
endProgramButton.setBounds(x + 2 * (buttonWidth + PANEL_SEPARATOR), y,
|
||||||
buttonWidth, buttonHeight);
|
buttonWidth, buttonHeight);
|
||||||
endProgramButton.setFont(endProgramButton.getFont().deriveFont(fontSize));
|
endProgramButton.setFont(endProgramButton.getFont()
|
||||||
|
.deriveFont(fontSize));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,10 @@ public class RoundControlTest {
|
||||||
view.displayStartTurnPanel = false;
|
view.displayStartTurnPanel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check correctly dealt with more than 14 stones/ different than default
|
||||||
|
* stones
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void checkCorrectlyDealtMoreStones() {
|
public void checkCorrectlyDealtMoreStones() {
|
||||||
testRoundState.getGameSettings().setNumberOfStonesDealt(15);
|
testRoundState.getGameSettings().setNumberOfStonesDealt(15);
|
||||||
|
|
Reference in a new issue