From 8b1e09f0257de32213debc4bcfcebfc061d51bb2 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Sat, 11 Jun 2011 04:09:27 +0200 Subject: Wir haben noch einen classify-Bug gefunden... und behoben git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@412 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/model/StoneSet.java | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/jrummikub') 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, 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(Collections.singletonList(stone)); @@ -33,7 +33,7 @@ public class StoneSet implements Iterable, 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 stones) { this.stones = new ArrayList(stones); @@ -53,7 +53,7 @@ public class StoneSet implements Iterable, 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, 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, Sizeable, Serializable { } if (nonJoker == -1) { - if (stones.size() > settings.getHighestValue()) { + if (stones.size() > settings.getHighestValue() + && stones.size() > settings.getStoneColors().size()) { return new Pair(INVALID, 0); } else if (stones.size() > settings.getStoneColors().size()) { - return new Pair(RUN, - (settings.getHighestValue() * (settings.getHighestValue() + 1)) / 2 + return new Pair( + 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(GROUP, stones.size() * settings.getHighestValue()); @@ -113,7 +118,7 @@ public class StoneSet implements Iterable, 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, Sizeable, Serializable { * Stone Sets * * @param position - * Splitting {@link Position} + * Splitting {@link Position} * @return A pair of StoneSets, one for each split part */ public Pair splitAt(int position) { @@ -183,7 +188,8 @@ public class StoneSet implements Iterable, Sizeable, Serializable { return new Pair(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(firstSet, secondSet); } @@ -191,7 +197,7 @@ public class StoneSet implements Iterable, 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, 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) { -- cgit v1.2.3