2011-05-04 23:26:01 +02:00
|
|
|
package jrummikub.model;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2011-05-10 01:39:32 +02:00
|
|
|
import java.util.HashSet;
|
2011-05-04 23:26:01 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
2011-05-10 01:39:32 +02:00
|
|
|
import java.util.Set;
|
2011-05-04 23:26:01 +02:00
|
|
|
|
|
|
|
import jrummikub.util.Pair;
|
2011-05-10 16:31:09 +02:00
|
|
|
|
2011-05-10 03:54:48 +02:00
|
|
|
/**
|
|
|
|
* Mock class for {@link Hand}
|
|
|
|
*/
|
2011-06-07 21:51:20 +02:00
|
|
|
@SuppressWarnings("serial")
|
2011-05-04 23:26:01 +02:00
|
|
|
public class MockHand implements IHand {
|
2011-05-10 03:54:48 +02:00
|
|
|
/** */
|
2011-05-09 00:33:34 +02:00
|
|
|
public List<Pair<Stone, Position>> stones = new ArrayList<Pair<Stone, Position>>();
|
2011-05-10 03:54:48 +02:00
|
|
|
/** */
|
2011-05-10 16:31:09 +02:00
|
|
|
public Set<Stone> pickups = new HashSet<Stone>();
|
2011-05-10 03:54:48 +02:00
|
|
|
/** */
|
2011-05-05 00:00:16 +02:00
|
|
|
public Iterable<Pair<Stone, Position>> iterable;
|
2011-05-04 23:26:01 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drop(Stone object, Position position) {
|
2011-05-09 00:33:34 +02:00
|
|
|
stones.add(new Pair<Stone, Position>(object, position));
|
2011-05-04 23:26:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Position getPosition(Stone object) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-05-10 01:39:32 +02:00
|
|
|
public boolean pickUp(Stone object) {
|
2011-05-10 16:31:09 +02:00
|
|
|
List<Pair<Stone, Position>> itList = new ArrayList<Pair<Stone, Position>>(
|
|
|
|
stones);
|
2011-05-09 00:33:34 +02:00
|
|
|
for (Pair<Stone, Position> entry : itList) {
|
|
|
|
if (entry.getFirst() == object) {
|
|
|
|
stones.remove(entry);
|
2011-05-10 01:39:32 +02:00
|
|
|
pickups.add(object);
|
|
|
|
return true;
|
2011-05-09 00:33:34 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-10 01:39:32 +02:00
|
|
|
return false;
|
2011-05-04 23:26:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getSize() {
|
|
|
|
return stones.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterator<Pair<Stone, Position>> iterator() {
|
2011-05-09 00:33:34 +02:00
|
|
|
if (iterable != null) {
|
|
|
|
return iterable.iterator();
|
|
|
|
} else {
|
|
|
|
return stones.iterator();
|
|
|
|
}
|
2011-05-04 23:26:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public MockHand clone() {
|
2011-05-05 00:19:02 +02:00
|
|
|
try {
|
|
|
|
return (MockHand) super.clone();
|
|
|
|
} catch (CloneNotSupportedException e) {
|
|
|
|
return null;
|
|
|
|
}
|
2011-05-04 23:26:01 +02:00
|
|
|
}
|
2011-05-16 22:01:02 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRowCount() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getFreeRowSpace(int row) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-24 01:51:56 +02:00
|
|
|
|
|
|
|
@Override
|
2011-05-31 03:45:32 +02:00
|
|
|
public int getStonePoints(GameSettings settings) {
|
2011-05-24 01:51:56 +02:00
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-24 01:51:58 +02:00
|
|
|
|
2011-05-31 03:45:32 +02:00
|
|
|
public boolean isInitialMeldPossible(GameSettings settings) {
|
2011-05-24 01:51:58 +02:00
|
|
|
return false;
|
|
|
|
}
|
2011-05-25 17:27:18 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getIdenticalStoneCount() {
|
|
|
|
return 0;
|
|
|
|
}
|
2011-06-19 00:14:27 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean contains(Stone object) {
|
|
|
|
for (Pair<Stone, Position> stone : stones) {
|
|
|
|
if (stone.getFirst() == object) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-05-04 23:26:01 +02:00
|
|
|
}
|