summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/model/StoneSet.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index 5412a3a..edd6f3f 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -23,7 +23,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Create a new single stone stone set
*
* @param stone
- * single stone of the set
+ * single stone of the set
*/
public StoneSet(Stone stone) {
stones = new ArrayList<Stone>(Collections.singletonList(stone));
@@ -33,7 +33,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Create a stone set from a list of stones
*
* @param stones
- * list of stones to build a set of
+ * list of stones to build a set of
*/
public StoneSet(List<Stone> stones) {
this.stones = new ArrayList<Stone>(stones);
@@ -53,7 +53,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Test for rule conflict within the StoneSet
*
* @param settings
- * GameSettings
+ * GameSettings
*
* @return true when the set is valid according to the rules
*/
@@ -62,11 +62,11 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
}
/**
- * Test for rule conflict within the StoneSet and determine whether the set is
- * a group or a run
+ * Test for rule conflict within the StoneSet and determine whether the set
+ * is a group or a run
*
* @param settings
- * GameSettings
+ * GameSettings
*
* @return GROUP or RUN for valid sets, INVALID otherwise
*/
@@ -84,13 +84,18 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
}
if (nonJoker == -1) {
- if (stones.size() > settings.getHighestValue()) {
+ if (stones.size() > settings.getHighestValue()
+ && stones.size() > settings.getStoneColors().size()) {
return new Pair<Type, Integer>(INVALID, 0);
} else if (stones.size() > settings.getStoneColors().size()) {
- return new Pair<Type, Integer>(RUN,
- (settings.getHighestValue() * (settings.getHighestValue() + 1)) / 2
+ return new Pair<Type, Integer>(
+ RUN,
+ (settings.getHighestValue() * (settings
+ .getHighestValue() + 1))
+ / 2
- (stones.size() - settings.getHighestValue())
- * (stones.size() - settings.getHighestValue() - 1) / 2);
+ * (stones.size() - settings.getHighestValue() - 1)
+ / 2);
} else {
return new Pair<Type, Integer>(GROUP, stones.size()
* settings.getHighestValue());
@@ -113,7 +118,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Test for rule conflict within the StoneSet, assuming we have a run
*
* @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, GameSettings settings) {
@@ -173,7 +178,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Stone Sets
*
* @param position
- * Splitting {@link Position}
+ * Splitting {@link Position}
* @return A pair of StoneSets, one for each split part
*/
public Pair<StoneSet, StoneSet> splitAt(int position) {
@@ -183,7 +188,8 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
return new Pair<StoneSet, StoneSet>(this, null);
}
StoneSet firstSet = new StoneSet(stones.subList(0, position));
- StoneSet secondSet = new StoneSet(stones.subList(position, stones.size()));
+ StoneSet secondSet = new StoneSet(stones.subList(position,
+ stones.size()));
return new Pair<StoneSet, StoneSet>(firstSet, secondSet);
}
@@ -191,7 +197,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Joins StoneSet to another StoneSet and returns the resulting new StoneSet
*
* @param other
- * StoneSet to be joined to active StoneSet
+ * StoneSet to be joined to active StoneSet
* @return the combined StoneSet
*/
public StoneSet join(StoneSet other) {
@@ -214,7 +220,7 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
* Returns the i-th stone of the set (starting with 0)
*
* @param i
- * number of the stone to return
+ * number of the stone to return
* @return the i-th stone
*/
public Stone get(int i) {