model vollständig dukumentiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@546 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
5e3ce21569
commit
e4e66240bf
2 changed files with 28 additions and 13 deletions
|
@ -47,8 +47,8 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Position, Direction> fixInvalidDrop(Stone stone, Position pos,
|
protected Pair<Position, Direction> fixInvalidDrop(Stone stone,
|
||||||
Direction dir) {
|
Position pos, Direction dir) {
|
||||||
double x = pos.getX();
|
double x = pos.getX();
|
||||||
double y = pos.getY();
|
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);
|
return new Pair<Position, Direction>(new Position(0, y), RIGHT);
|
||||||
} else {
|
} else {
|
||||||
if (getFreeRowSpace((int) y) == 0) {
|
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 {
|
} else {
|
||||||
return new Pair<Position, Direction>(new Position(WIDTH - 1, y), LEFT);
|
return new Pair<Position, Direction>(
|
||||||
|
new Position(WIDTH - 1, y), LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,6 +103,7 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
* @param stones
|
* @param stones
|
||||||
* all stones and their respective numbers
|
* all stones and their respective numbers
|
||||||
* @param stone
|
* @param stone
|
||||||
|
* the start stone
|
||||||
*/
|
*/
|
||||||
private static void incrementStoneCount(
|
private static void incrementStoneCount(
|
||||||
TreeMap<Pair<Integer, StoneColor>, Integer> stones,
|
TreeMap<Pair<Integer, StoneColor>, Integer> stones,
|
||||||
|
@ -159,7 +162,8 @@ public class Hand extends StoneTray<Stone> implements IHand {
|
||||||
public int getIdenticalStoneCount() {
|
public int getIdenticalStoneCount() {
|
||||||
List<Stone> stones = new ArrayList<Stone>();
|
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());
|
stones.add(iter.next().getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,22 @@ public class Table extends StoneTray<StoneSet> implements ITable {
|
||||||
return info.set;
|
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) {
|
private void splitSet(StoneSet set, Position setPosition, int stonePosition) {
|
||||||
pickUp(set);
|
pickUp(set);
|
||||||
|
|
||||||
Pair<StoneSet, StoneSet> firstSplit = set.splitAt(stonePosition);
|
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 leftSet = firstSplit.getFirst();
|
||||||
StoneSet rightSet = secondSplit.getSecond();
|
StoneSet rightSet = secondSplit.getSecond();
|
||||||
|
@ -101,8 +112,8 @@ public class Table extends StoneTray<StoneSet> implements ITable {
|
||||||
if (set.classify(gameSettings).getFirst() == StoneSet.Type.RUN) {
|
if (set.classify(gameSettings).getFirst() == StoneSet.Type.RUN) {
|
||||||
Position leftPosition, rightPosition;
|
Position leftPosition, rightPosition;
|
||||||
leftPosition = setPosition;
|
leftPosition = setPosition;
|
||||||
rightPosition = new Position(setPosition.getX() + stonePosition + 1,
|
rightPosition = new Position(
|
||||||
setPosition.getY());
|
setPosition.getX() + stonePosition + 1, setPosition.getY());
|
||||||
|
|
||||||
drop(leftSet, leftPosition);
|
drop(leftSet, leftPosition);
|
||||||
drop(rightSet, rightPosition);
|
drop(rightSet, rightPosition);
|
||||||
|
|
Reference in a new issue