summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/model/StoneSet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/model/StoneSet.java')
-rw-r--r--src/jrummikub/model/StoneSet.java35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java
index 1bb0823..5412a3a 100644
--- a/src/jrummikub/model/StoneSet.java
+++ b/src/jrummikub/model/StoneSet.java
@@ -14,7 +14,7 @@ import static jrummikub.model.StoneSet.Type.*;
/** Class managing {@link Stone}s joined together to form sets */
public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
private static final long serialVersionUID = -3852631195648599398L;
-
+
static final float VERTICAL_BORDER = 0.5f;
static final float HORIZONTAL_BORDER = 0.125f;
private ArrayList<Stone> stones;
@@ -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
*/
@@ -87,14 +87,10 @@ public class StoneSet implements Iterable<Stone>, Sizeable, Serializable {
if (stones.size() > settings.getHighestValue()) {
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());
@@ -117,7 +113,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) {
@@ -177,7 +173,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) {
@@ -187,8 +183,7 @@ 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);
}
@@ -196,7 +191,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) {
@@ -219,7 +214,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) {