Fixed a bunch of network synchronization bugs

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@510 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Matthias Schiffer 2011-06-20 06:41:15 +02:00
parent 74d8205f30
commit 0c3eb9a283
15 changed files with 137 additions and 94 deletions

View file

@ -48,7 +48,10 @@ public class GameControlTest {
@Test
public void testEndOfRound() {
gameControl.startGame();
// Manipulate first players hand, to allow player1 to win
view.startTurnEvent.emit();
// Manipulate first player's hand, to allow player1 to win
IHand playerHand = gameControl.roundControl.clonedHand;
for (Pair<Stone, Position> entry : playerHand.clone()) {
playerHand.pickUp(entry.getFirst());
@ -61,7 +64,6 @@ public class GameControlTest {
playerHand.drop(stone3, new Position(0, 0));
// Done setting up first players hand
view.startTurnEvent.emit();
view.playerPanel.endTurnEvent.emit();
view.startTurnEvent.emit();
view.playerPanel.endTurnEvent.emit();

View file

@ -899,12 +899,12 @@ public class RoundControlTest {
@Test
public void testRedealDisallowed() {
testRound.startRound();
view.startTurnEvent.emit();
Hand hand = new Hand();
hand.drop(new Stone(1, RED), new Position(0, 0));
hand.drop(new Stone(1, BLACK), new Position(0, 0));
hand.drop(new Stone(1, BLUE), new Position(0, 0));
testRound.clonedHand = hand;
view.startTurnEvent.emit();
assertEquals(TurnMode.INSPECT_ONLY, view.playerPanel.turnMode);
for (int i = 0; i < 4; i++) {
view.playerPanel.endTurnEvent.emit();

View file

@ -103,7 +103,8 @@ public class NetworkRoundControlTest {
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getTable());
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
.getHand(), testRoundState.getTable(), testRoundState.getTable());
assertSame(testRoundState.getNthPlayer(3), testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
@ -111,7 +112,8 @@ public class NetworkRoundControlTest {
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getTable());
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
.getHand(), testRoundState.getTable(), testRoundState.getTable());
assertSame(testRoundState.getNthPlayer(0), testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
@ -144,7 +146,8 @@ public class NetworkRoundControlTest {
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getTable());
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
.getHand(), testRoundState.getTable(), testRoundState.getTable());
assertSame(testRoundState.getNthPlayer(1), testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);
@ -152,7 +155,8 @@ public class NetworkRoundControlTest {
connectionControl.turnStartEvent.emit(testRoundState);
assertFalse(connectionControl.turnEnded);
connectionControl.turnEndEvent.emit(testRoundState.getTable());
connectionControl.turnEndEvent.emit(testRoundState.getActivePlayer()
.getHand(), testRoundState.getTable(), testRoundState.getTable());
assertSame(testRoundState.getNthPlayer(2), testRoundState.getActivePlayer());
assertFalse(connectionControl.turnStarted);

View file

@ -16,7 +16,7 @@ import jrummikub.model.Stone;
import jrummikub.model.StoneColor;
import jrummikub.model.Table;
import jrummikub.util.IListener;
import jrummikub.util.IListener1;
import jrummikub.util.IListener3;
import jrummikub.view.MockView;
import org.junit.Before;
@ -48,9 +48,9 @@ public class AIControlTest {
turnEnded = false;
redealt = false;
aiControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
aiControl.getEndOfTurnEvent().add(new IListener3<IHand, ITable, ITable>() {
@Override
public void handle(ITable newTable) {
public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
turnEnded = true;
}

View file

@ -25,7 +25,7 @@ import jrummikub.model.StoneSet;
import jrummikub.model.Table;
import jrummikub.util.Event;
import jrummikub.util.IEvent;
import jrummikub.util.IListener1;
import jrummikub.util.IListener3;
import jrummikub.util.Pair;
import jrummikub.view.IView.BottomPanelType;
import jrummikub.view.MockView;
@ -182,9 +182,9 @@ public class TurnControlTest {
eventFired = false;
mockTimer.timerRunning = true;
testControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
testControl.getEndOfTurnEvent().add(new IListener3<IHand, ITable, ITable>() {
@Override
public void handle(ITable newTable) {
public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
eventFired = true;
}
});
@ -204,9 +204,9 @@ public class TurnControlTest {
eventFired = false;
mockTimer.timerRunning = true;
testControl.getEndOfTurnEvent().add(new IListener1<ITable>() {
testControl.getEndOfTurnEvent().add(new IListener3<IHand, ITable, ITable>() {
@Override
public void handle(ITable newTable) {
public void handle(IHand oldHand, ITable oldTable, ITable newTable) {
eventFired = true;
}
});