Man kann viele FAreben benutzen, alle Test laufen. Man kann auch Karten bis Wert X größer oder kleiner 13 nehmen. Alles nur im Model, aber getestet und toll
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@333 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
f22ff5f0f1
commit
0cb36fb752
1 changed files with 23 additions and 14 deletions
|
@ -73,20 +73,27 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
}
|
}
|
||||||
nonJoker = i;
|
nonJoker = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nonJoker == -1) {
|
if (nonJoker == -1) {
|
||||||
if (stones.size() > 13) {
|
if (stones.size() > settings.getHighestCard()) {
|
||||||
return new Pair<Type, Integer>(INVALID, 0);
|
return new Pair<Type, Integer>(INVALID, 0);
|
||||||
} else if (stones.size() > 4) {
|
} else if (stones.size() > settings.getStoneColors().size()) {
|
||||||
return new Pair<Type, Integer>(RUN, 91 - (stones.size() - 13)*(stones.size() - 14)/2);
|
return new Pair<Type, Integer>(
|
||||||
|
RUN,
|
||||||
|
(settings.getHighestCard() * (settings.getHighestCard() + 1))
|
||||||
|
/ 2
|
||||||
|
- (stones.size() - settings.getHighestCard())
|
||||||
|
* (stones.size() - settings.getHighestCard() - 1)
|
||||||
|
/ 2);
|
||||||
} else {
|
} else {
|
||||||
return new Pair<Type, Integer>(GROUP, stones.size() * 13);
|
return new Pair<Type, Integer>(GROUP, stones.size()
|
||||||
|
* settings.getHighestCard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int runScore = isValidRun(nonJoker);
|
int runScore = isValidRun(nonJoker, settings);
|
||||||
int groupScore = isValidGroup(stones.get(nonJoker).getValue());
|
int groupScore = isValidGroup(stones.get(nonJoker).getValue(), settings);
|
||||||
|
|
||||||
if (runScore > groupScore) {
|
if (runScore > groupScore) {
|
||||||
return new Pair<Type, Integer>(RUN, runScore);
|
return new Pair<Type, Integer>(RUN, runScore);
|
||||||
} else if (groupScore == 0) {
|
} else if (groupScore == 0) {
|
||||||
|
@ -101,13 +108,14 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
*
|
*
|
||||||
* @param referencePosition
|
* @param referencePosition
|
||||||
* position of stone used as reference (any non-joker stone)
|
* position of stone used as reference (any non-joker stone)
|
||||||
|
* @param settings
|
||||||
*/
|
*/
|
||||||
private int isValidRun(int referencePosition) {
|
private int isValidRun(int referencePosition, GameSettings settings) {
|
||||||
StoneColor runColor = stones.get(referencePosition).getColor();
|
StoneColor runColor = stones.get(referencePosition).getColor();
|
||||||
int startValue = stones.get(referencePosition).getValue()
|
int startValue = stones.get(referencePosition).getValue()
|
||||||
- referencePosition;
|
- referencePosition;
|
||||||
int endValue = startValue + stones.size() - 1;
|
int endValue = startValue + stones.size() - 1;
|
||||||
if (startValue < 1 || endValue > 13) {
|
if (startValue < 1 || endValue > settings.getHighestCard()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < stones.size(); i++) {
|
for (int i = 0; i < stones.size(); i++) {
|
||||||
|
@ -115,7 +123,6 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (stones.get(i).getColor() != runColor) {
|
if (stones.get(i).getColor() != runColor) {
|
||||||
// warum macht er das nicht?
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (stones.get(i).getValue() != i + startValue) {
|
if (stones.get(i).getValue() != i + startValue) {
|
||||||
|
@ -131,9 +138,11 @@ public class StoneSet implements Iterable<Stone>, Sizeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for rule conflict within the StoneSet, assuming we have a group
|
* Test for rule conflict within the StoneSet, assuming we have a group
|
||||||
|
*
|
||||||
|
* @param settings
|
||||||
*/
|
*/
|
||||||
private int isValidGroup(int value) {
|
private int isValidGroup(int value, GameSettings settings) {
|
||||||
if (stones.size() > 4) {
|
if (stones.size() > settings.getStoneColors().size()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Set<StoneColor> seenColors = new HashSet<StoneColor>();
|
Set<StoneColor> seenColors = new HashSet<StoneColor>();
|
||||||
|
|
Reference in a new issue