summaryrefslogtreecommitdiffstats
path: root/src/jrummikub
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub')
-rw-r--r--src/jrummikub/model/Hand.java18
-rw-r--r--src/jrummikub/model/Table.java23
2 files changed, 28 insertions, 13 deletions
diff --git a/src/jrummikub/model/Hand.java b/src/jrummikub/model/Hand.java
index 3e6bfeb..1388187 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,9 +59,11 @@ 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);
}
}
}
@@ -99,8 +101,9 @@ public class Hand extends StoneTray<Stone> implements IHand {
* Increments the count of a stone in the list of all stones
*
* @param stones
- * all stones and their respective numbers
+ * all stones and their respective numbers
* @param stone
+ * the start stone
*/
private static void incrementStoneCount(
TreeMap<Pair<Integer, StoneColor>, Integer> stones,
@@ -132,7 +135,7 @@ public class Hand extends StoneTray<Stone> implements IHand {
* Counts the numbers of stones
*
* @param stones
- * the stones to count
+ * the stones to count
* @return the numbers for all stones
*/
private static Pair<TreeMap<Pair<Integer, StoneColor>, Integer>, Integer> countStones(
@@ -159,7 +162,8 @@ 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());
}
diff --git a/src/jrummikub/model/Table.java b/src/jrummikub/model/Table.java
index 1b355db..3fb9b5c 100644
--- a/src/jrummikub/model/Table.java
+++ b/src/jrummikub/model/Table.java
@@ -25,7 +25,7 @@ public class Table extends StoneTray<StoneSet> implements ITable {
* Constructor for a table
*
* @param settings
- * GameSettings
+ * GameSettings
*/
public Table(GameSettings settings) {
gameSettings = settings;
@@ -35,7 +35,7 @@ public class Table extends StoneTray<StoneSet> implements ITable {
* Removes {@link Stone} from the Table
*
* @param stone
- * stone to pick up
+ * stone to pick up
*/
@Override
public void pickUpStone(Stone stone) {
@@ -50,7 +50,7 @@ public class Table extends StoneTray<StoneSet> implements ITable {
* Finds {@link StoneInfo}
*
* @param stone
- * the stone
+ * the stone
* @return the info
*/
private StoneInfo findStoneInfo(Stone stone) {
@@ -89,11 +89,22 @@ public class Table extends StoneTray<StoneSet> implements ITable {
return info.set;
}
+ /**
+ * Splits a stone set at a specified position
+ *
+ * @param set
+ * the stone set to split
+ * @param setPosition
+ * the set's position on the table
+ * @param stonePosition
+ * the stone after which splitting should occur
+ */
private void splitSet(StoneSet set, Position setPosition, int stonePosition) {
pickUp(set);
Pair<StoneSet, StoneSet> firstSplit = set.splitAt(stonePosition);
- Pair<StoneSet, StoneSet> secondSplit = firstSplit.getSecond().splitAt(1);
+ Pair<StoneSet, StoneSet> secondSplit = firstSplit.getSecond()
+ .splitAt(1);
StoneSet leftSet = firstSplit.getFirst();
StoneSet rightSet = secondSplit.getSecond();
@@ -101,8 +112,8 @@ public class Table extends StoneTray<StoneSet> implements ITable {
if (set.classify(gameSettings).getFirst() == StoneSet.Type.RUN) {
Position leftPosition, rightPosition;
leftPosition = setPosition;
- rightPosition = new Position(setPosition.getX() + stonePosition + 1,
- setPosition.getY());
+ rightPosition = new Position(
+ setPosition.getX() + stonePosition + 1, setPosition.getY());
drop(leftSet, leftPosition);
drop(rightSet, rightPosition);