2011-05-04 15:20:52 +02:00
|
|
|
package jrummikub.control;
|
|
|
|
|
2011-05-05 15:57:13 +02:00
|
|
|
import java.util.Set;
|
|
|
|
|
2011-05-04 23:26:01 +02:00
|
|
|
import jrummikub.model.IGameState;
|
2011-05-04 19:24:51 +02:00
|
|
|
import jrummikub.model.IHand;
|
2011-05-05 15:57:13 +02:00
|
|
|
import jrummikub.model.ITable;
|
2011-05-04 19:24:51 +02:00
|
|
|
import jrummikub.model.Position;
|
2011-05-05 15:57:13 +02:00
|
|
|
import jrummikub.model.Stone;
|
2011-05-05 01:33:58 +02:00
|
|
|
import jrummikub.util.IListener;
|
2011-05-04 15:20:52 +02:00
|
|
|
import jrummikub.view.IView;
|
|
|
|
|
2011-05-04 19:09:39 +02:00
|
|
|
public class RoundControl {
|
2011-05-04 23:26:01 +02:00
|
|
|
private IGameState gameState;
|
2011-05-04 15:20:52 +02:00
|
|
|
private IView view;
|
2011-05-05 15:57:13 +02:00
|
|
|
private ITable clonedTable;
|
2011-05-04 15:20:52 +02:00
|
|
|
|
2011-05-04 23:26:01 +02:00
|
|
|
public RoundControl(IGameState gameState, IView view) {
|
2011-05-04 15:20:52 +02:00
|
|
|
this.gameState = gameState;
|
|
|
|
this.view = view;
|
|
|
|
}
|
|
|
|
|
2011-05-04 19:09:39 +02:00
|
|
|
public void startRound() {
|
2011-05-05 01:33:58 +02:00
|
|
|
deal();
|
2011-05-04 19:09:39 +02:00
|
|
|
|
2011-05-05 01:33:58 +02:00
|
|
|
view.getStartTurnEvent().add(new IListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handle() {
|
|
|
|
startTurn();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
view.enableStartTurnPanel(true);
|
2011-05-05 15:57:13 +02:00
|
|
|
clonedTable = (ITable) gameState.getTable().clone();
|
|
|
|
view.getTablePanel().setStoneSets(clonedTable);
|
2011-05-05 01:33:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void startTurn() {
|
|
|
|
TurnControl turnControl = new TurnControl(gameState.getActivePlayer()
|
2011-05-05 15:57:13 +02:00
|
|
|
.getHand(), clonedTable, view);
|
|
|
|
turnControl.getEndOfTurnEvent().add(new IListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handle() {
|
|
|
|
endOfTurn();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// turnControl.startTurn();
|
2011-05-04 19:09:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void deal() {
|
2011-05-04 19:24:51 +02:00
|
|
|
for (int i = 0; i < gameState.getPlayerCount(); i++) {
|
|
|
|
IHand hand = gameState.getPlayer(i).getHand();
|
|
|
|
for (int j = 0; j < 7; j++) {
|
2011-05-05 15:57:13 +02:00
|
|
|
hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
|
|
|
|
0));
|
|
|
|
hand.drop(gameState.getGameHeap().drawStone(), new Position(j,
|
|
|
|
1));
|
2011-05-04 19:24:51 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-04 19:09:39 +02:00
|
|
|
}
|
|
|
|
|
2011-05-04 15:20:52 +02:00
|
|
|
private void endOfTurn() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-05 15:57:13 +02:00
|
|
|
static Set<Stone> tableDifference(ITable oldTable, ITable newTable) {
|
|
|
|
return null;
|
2011-05-04 15:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void resetTable() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void preparePlayerTurn() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void dealStone() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|