Zwischencommit weil Ida so müde ist, eigentlich nichts passiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@177 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
35cd080bcd
commit
ec2936a034
3 changed files with 56 additions and 25 deletions
|
@ -5,7 +5,9 @@ import java.util.List;
|
||||||
|
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
|
import jrummikub.model.Position;
|
||||||
import jrummikub.model.Stone;
|
import jrummikub.model.Stone;
|
||||||
|
import jrummikub.model.StoneSet;
|
||||||
import jrummikub.util.Connection;
|
import jrummikub.util.Connection;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
@ -107,6 +109,18 @@ public class TurnControl {
|
||||||
|
|
||||||
view.setSelectedStones(selectedStones);
|
view.setSelectedStones(selectedStones);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void leftConnectorClick(StoneSet set){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rightConnectorClick(StoneSet set){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tableClick(Position position){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void endOfTurn() {
|
private void endOfTurn() {
|
||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
package jrummikub.control;
|
package jrummikub.control;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static jrummikub.model.StoneColor.BLACK;
|
||||||
|
import static jrummikub.model.StoneColor.BLUE;
|
||||||
|
import static jrummikub.model.StoneColor.RED;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jrummikub.model.MockHand;
|
import jrummikub.model.MockHand;
|
||||||
|
@ -23,8 +28,6 @@ import jrummikub.view.MockView;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static jrummikub.model.StoneColor.*;
|
|
||||||
|
|
||||||
public class TurnControlTest {
|
public class TurnControlTest {
|
||||||
static class AccessibleTable extends Table{
|
static class AccessibleTable extends Table{
|
||||||
StoneSet[] getSetArray(){
|
StoneSet[] getSetArray(){
|
||||||
|
|
|
@ -14,70 +14,84 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class TableTest {
|
public class TableTest {
|
||||||
Table testTable;
|
Table testTable;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
testTable = new Table();
|
testTable = new Table();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsValid() {
|
public void testIsValid() {
|
||||||
testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK),
|
testTable.drop(
|
||||||
new Stone(1, BLACK))), new Position(0,0));
|
new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK),
|
||||||
testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), new Stone(2, RED),
|
new Stone(1, BLACK))), new Position(0, 0));
|
||||||
new Stone(3, RED))), new Position(0,0));
|
testTable.drop(
|
||||||
|
new StoneSet(Arrays.asList(new Stone(1, RED),
|
||||||
|
new Stone(2, RED), new Stone(3, RED))), new Position(0,
|
||||||
|
0));
|
||||||
assertTrue(testTable.isValid());
|
assertTrue(testTable.isValid());
|
||||||
|
|
||||||
testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))), new Position(0,0));
|
testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))),
|
||||||
|
new Position(0, 0));
|
||||||
assertFalse(testTable.isValid());
|
assertFalse(testTable.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyIsValid() {
|
public void testEmptyIsValid() {
|
||||||
assertTrue(testTable.isValid());
|
assertTrue(testTable.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void testPickUpStoneGroup() {
|
public void testPickUpStoneGroup() {
|
||||||
Stone targetStone = new Stone(BLACK);
|
Stone targetStone = new Stone(BLACK);
|
||||||
testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), targetStone,
|
testTable.drop(
|
||||||
new Stone(1, BLACK))), new Position(0,0));
|
new StoneSet(Arrays.asList(new Stone(RED), targetStone,
|
||||||
|
new Stone(1, BLACK))), new Position(0, 0));
|
||||||
assertTrue(testTable.isValid());
|
assertTrue(testTable.isValid());
|
||||||
testTable.pickUpStone(targetStone);
|
testTable.pickUpStone(targetStone);
|
||||||
assertFalse(testTable.isValid());
|
assertFalse(testTable.isValid());
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Object i : testTable) {
|
for (Object i : testTable) {
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
assertEquals(1, counter);
|
assertEquals(1, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPickLonelyStone() {
|
||||||
|
Stone targetStone = new Stone(BLACK);
|
||||||
|
testTable.drop(new StoneSet(targetStone), new Position(0, 0));
|
||||||
|
testTable.pickUpStone(targetStone);
|
||||||
|
assertEquals(0, testTable.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void testPickUpStoneRun() {
|
public void testPickUpStoneRun() {
|
||||||
Stone targetStone = new Stone(BLACK);
|
Stone targetStone = new Stone(BLACK);
|
||||||
testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), targetStone,
|
testTable.drop(
|
||||||
new Stone(3, RED))), new Position(0,0));
|
new StoneSet(Arrays.asList(new Stone(1, RED), targetStone,
|
||||||
|
new Stone(3, RED))), new Position(0, 0));
|
||||||
assertTrue(testTable.isValid());
|
assertTrue(testTable.isValid());
|
||||||
testTable.pickUpStone(targetStone);
|
testTable.pickUpStone(targetStone);
|
||||||
assertFalse(testTable.isValid());
|
assertFalse(testTable.isValid());
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Object i : testTable) {
|
for (Object i : testTable) {
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
assertEquals(2, counter);
|
assertEquals(2, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindSet() {
|
public void testFindSet() {
|
||||||
Stone targetStone = new Stone(BLACK);
|
Stone targetStone = new Stone(BLACK);
|
||||||
StoneSet testSet = new StoneSet(Arrays.asList(new Stone(1, RED), targetStone,
|
StoneSet testSet = new StoneSet(Arrays.asList(new Stone(1, RED),
|
||||||
new Stone(3, RED)));
|
targetStone, new Stone(3, RED)));
|
||||||
testTable.drop(testSet, new Position(0,0));
|
testTable.drop(testSet, new Position(0, 0));
|
||||||
|
|
||||||
StoneSet foundSet = testTable.findStoneSet(targetStone);
|
StoneSet foundSet = testTable.findStoneSet(targetStone);
|
||||||
assertSame(testSet, foundSet);
|
assertSame(testSet, foundSet);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue