Viele viele Kommentare, einige zu lange oder zu komplexe Methoden gefixt
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@417 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
6ac71b62e3
commit
ce7d43e365
15 changed files with 298 additions and 135 deletions
|
@ -23,7 +23,7 @@ public class GameSettings implements Serializable {
|
|||
private int highestValue;
|
||||
private int stoneSetNumber;
|
||||
private int numberOfStonesDealt;
|
||||
private int time;
|
||||
private int totalTime;
|
||||
private boolean noLimits;
|
||||
private HashSet<StoneColor> stoneColors;
|
||||
|
||||
|
@ -34,6 +34,9 @@ public class GameSettings implements Serializable {
|
|||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the game settings to the default values
|
||||
*/
|
||||
public void reset() {
|
||||
initialMeldThreshold = 30;
|
||||
jokerPoints = 50;
|
||||
|
@ -41,7 +44,7 @@ public class GameSettings implements Serializable {
|
|||
highestValue = 13;
|
||||
stoneSetNumber = 2;
|
||||
numberOfStonesDealt = 14;
|
||||
time = 60;
|
||||
totalTime = 60;
|
||||
noLimits = false;
|
||||
stoneColors = new HashSet<StoneColor>(Arrays.asList(BLACK, BLUE,
|
||||
ORANGE, RED));
|
||||
|
@ -151,12 +154,23 @@ public class GameSettings implements Serializable {
|
|||
this.stoneSetNumber = stoneSets;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
/**
|
||||
* Getter for the time for a turn
|
||||
*
|
||||
* @return time for a turn
|
||||
*/
|
||||
public int getTotalTime() {
|
||||
return totalTime;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
/**
|
||||
* Setter for the time for a turn
|
||||
*
|
||||
* @param totalTime
|
||||
* for a turn
|
||||
*/
|
||||
public void setTotalTime(int totalTime) {
|
||||
this.totalTime = totalTime;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,25 +84,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
|
|||
}
|
||||
|
||||
if (nonJoker == -1) {
|
||||
if (stones.size() > settings.getHighestValue()
|
||||
&& stones.size() > settings.getStoneColors().size()
|
||||
&& !settings.isNoLimits()) {
|
||||
return new Pair<Type, Integer>(INVALID, 0);
|
||||
} else if (stones.size() > settings.getStoneColors().size()) {
|
||||
int value = 0;
|
||||
int stoneValue = settings.getHighestValue();
|
||||
for (int i = 0; i < stones.size(); i++) {
|
||||
value += stoneValue;
|
||||
stoneValue--;
|
||||
if (stoneValue == 0) {
|
||||
stoneValue = settings.getHighestValue();
|
||||
}
|
||||
}
|
||||
return new Pair<Type, Integer>(RUN, value);
|
||||
} else {
|
||||
return new Pair<Type, Integer>(GROUP, stones.size()
|
||||
* settings.getHighestValue());
|
||||
}
|
||||
return classifyJokersOnly(settings, nonJoker);
|
||||
}
|
||||
|
||||
int runScore = isValidRun(nonJoker, settings);
|
||||
|
@ -117,6 +99,29 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
private Pair<Type, Integer> classifyJokersOnly(GameSettings settings,
|
||||
int nonJoker) {
|
||||
if (stones.size() > settings.getHighestValue()
|
||||
&& stones.size() > settings.getStoneColors().size()
|
||||
&& !settings.isNoLimits()) {
|
||||
return new Pair<Type, Integer>(INVALID, 0);
|
||||
} else if (stones.size() > settings.getStoneColors().size()) {
|
||||
int value = 0;
|
||||
int stoneValue = settings.getHighestValue();
|
||||
for (int i = 0; i < stones.size(); i++) {
|
||||
value += stoneValue;
|
||||
stoneValue--;
|
||||
if (stoneValue == 0) {
|
||||
stoneValue = settings.getHighestValue();
|
||||
}
|
||||
}
|
||||
return new Pair<Type, Integer>(RUN, value);
|
||||
} else {
|
||||
return new Pair<Type, Integer>(GROUP, stones.size()
|
||||
* settings.getHighestValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for rule conflict within the StoneSet, assuming we have a run
|
||||
*
|
||||
|
|
Reference in a new issue