diff options
Diffstat (limited to 'src/jrummikub/model/Hand.java')
-rw-r--r-- | src/jrummikub/model/Hand.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java index 69d659b..3e6bfeb 100644 --- a/src/jrummikub/model/Hand.java +++ b/src/jrummikub/model/Hand.java @@ -47,8 +47,8 @@ public class Hand extends StoneTray<Stone> implements IHand { } @Override - protected Pair<Position, Direction> fixInvalidDrop(Stone stone, - Position pos, Direction dir) { + protected Pair<Position, Direction> fixInvalidDrop(Stone stone, Position pos, + Direction dir) { double x = pos.getX(); double y = pos.getY(); @@ -59,11 +59,9 @@ public class Hand extends StoneTray<Stone> implements IHand { return new Pair<Position, Direction>(new Position(0, y), RIGHT); } else { if (getFreeRowSpace((int) y) == 0) { - return new Pair<Position, Direction>(new Position(0, y + 1), - RIGHT); + return new Pair<Position, Direction>(new Position(0, y + 1), RIGHT); } else { - return new Pair<Position, Direction>( - new Position(WIDTH - 1, y), LEFT); + return new Pair<Position, Direction>(new Position(WIDTH - 1, y), LEFT); } } } @@ -96,8 +94,14 @@ public class Hand extends StoneTray<Stone> implements IHand { turnLogic.needIntialMeldThreshold(); return turnLogic.solve(); } - - + + /** + * Increments the count of a stone in the list of all stones + * + * @param stones + * all stones and their respective numbers + * @param stone + */ private static void incrementStoneCount( TreeMap<Pair<Integer, StoneColor>, Integer> stones, Pair<Integer, StoneColor> stone) { @@ -108,6 +112,9 @@ public class Hand extends StoneTray<Stone> implements IHand { } } + /** + * The measure to compare the stones by + */ private final static Comparator<Pair<Integer, StoneColor>> comparator = new Comparator<Pair<Integer, StoneColor>>() { @Override public int compare(Pair<Integer, StoneColor> o1, @@ -120,7 +127,7 @@ public class Hand extends StoneTray<Stone> implements IHand { } } }; - + /** * Counts the numbers of stones * @@ -152,8 +159,7 @@ public class Hand extends StoneTray<Stone> implements IHand { public int getIdenticalStoneCount() { List<Stone> stones = new ArrayList<Stone>(); - for (Iterator<Pair<Stone, Position>> iter = this.iterator(); iter - .hasNext();) { + for (Iterator<Pair<Stone, Position>> iter = this.iterator(); iter.hasNext();) { stones.add(iter.next().getFirst()); } |