diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-29 18:51:06 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-29 18:51:06 +0200 |
commit | c09a94a359de9f2d13b36dc58b9ac55022379861 (patch) | |
tree | 48b1015ba018b11a95c1f27ba1374a9f3dc741b3 /src/jrummikub | |
parent | cb50f92edd8c66851fe402eaf8cd09cb598ee70c (diff) | |
download | JRummikub-c09a94a359de9f2d13b36dc58b9ac55022379861.tar JRummikub-c09a94a359de9f2d13b36dc58b9ac55022379861.zip |
Classify for more than two jokers
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@305 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub')
-rw-r--r-- | src/jrummikub/model/StoneSet.java | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/jrummikub/model/StoneSet.java b/src/jrummikub/model/StoneSet.java index 604d6ac..2700889 100644 --- a/src/jrummikub/model/StoneSet.java +++ b/src/jrummikub/model/StoneSet.java @@ -66,40 +66,33 @@ public class StoneSet implements Iterable<Stone>, Sizeable { if (stones.size() < 3) { return new Pair<Type, Integer>(INVALID, 0); } - int nonJoker1 = -1, nonJoker2 = -1; + int nonJoker = -1; for (int i = 0; i < stones.size(); i++) { if (stones.get(i).isJoker()) { continue; } - nonJoker2 = nonJoker1; - nonJoker1 = i; + nonJoker = i; } - if (nonJoker2 == -1) { - // Z first - if (nonJoker1 == 0 && stones.get(nonJoker1).getValue() < 12) { - return new Pair<Type, Integer>(RUN, isValidRun(nonJoker1)); + + if (nonJoker == -1) { + if (stones.size() > 13) { + return new Pair<Type, Integer>(INVALID, 0); + } else if (stones.size() > 4) { + return new Pair<Type, Integer>(RUN, 91 - (stones.size() - 13)*(stones.size() - 14)/2); } else { - int value = stones.get(nonJoker1).getValue() * stones.size(); - return new Pair<Type, Integer>(GROUP, value); + return new Pair<Type, Integer>(GROUP, stones.size() * 13); } } - - // is run - if (stones.get(nonJoker1).getColor() == stones.get(nonJoker2) - .getColor()) { - if (isValidRun(nonJoker1) > 0) { - return new Pair<Type, Integer>(RUN, isValidRun(nonJoker1)); - } - return new Pair<Type, Integer>(INVALID, 0); - - } - // is group - else { - if (isValidGroup(stones.get(nonJoker1).getValue()) > 0) { - return new Pair<Type, Integer>(GROUP, isValidGroup(stones.get( - nonJoker1).getValue())); - } + + int runScore = isValidRun(nonJoker); + int groupScore = isValidGroup(stones.get(nonJoker).getValue()); + + if (runScore > groupScore) { + return new Pair<Type, Integer>(RUN, runScore); + } else if (groupScore == 0) { return new Pair<Type, Integer>(INVALID, 0); + } else { + return new Pair<Type, Integer>(GROUP, groupScore); } } |