Implemented stone clicking on hand
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@154 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
8c65bafde4
commit
0b66e7d763
1 changed files with 30 additions and 1 deletions
|
@ -5,10 +5,12 @@ import java.util.List;
|
||||||
|
|
||||||
import jrummikub.model.IHand;
|
import jrummikub.model.IHand;
|
||||||
import jrummikub.model.ITable;
|
import jrummikub.model.ITable;
|
||||||
|
import jrummikub.model.Stone;
|
||||||
import jrummikub.util.Connection;
|
import jrummikub.util.Connection;
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
import jrummikub.util.IListener;
|
import jrummikub.util.IListener;
|
||||||
|
import jrummikub.util.IListener2;
|
||||||
import jrummikub.view.IView;
|
import jrummikub.view.IView;
|
||||||
|
|
||||||
public class TurnControl {
|
public class TurnControl {
|
||||||
|
@ -16,6 +18,9 @@ public class TurnControl {
|
||||||
private ITable table;
|
private ITable table;
|
||||||
private ITurnTimer timer;
|
private ITurnTimer timer;
|
||||||
private IView view;
|
private IView view;
|
||||||
|
|
||||||
|
private List<Stone> selectedStones = new ArrayList<Stone>();
|
||||||
|
|
||||||
private Event endOfTurnEvent = new Event();
|
private Event endOfTurnEvent = new Event();
|
||||||
List<Connection> connections = new ArrayList<Connection>();
|
List<Connection> connections = new ArrayList<Connection>();
|
||||||
|
|
||||||
|
@ -44,7 +49,18 @@ public class TurnControl {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener));
|
connections.add(timer.getTimeRunOutEvent().add(endOfTurnListener));
|
||||||
connections.add(view.getPlayerPanel().getEndTurnEvent().add(endOfTurnListener));
|
connections.add(view.getPlayerPanel().getEndTurnEvent()
|
||||||
|
.add(endOfTurnListener));
|
||||||
|
|
||||||
|
connections.add(view.getPlayerPanel().getHandPanel().getStoneClickEvent()
|
||||||
|
.add(new IListener2<Stone, Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Stone stone, Boolean collect) {
|
||||||
|
handStoneClick(stone, collect);
|
||||||
|
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
|
view.getPlayerPanel().getHandPanel().setStones(hand.clone());
|
||||||
view.enableStartTurnPanel(false);
|
view.enableStartTurnPanel(false);
|
||||||
|
@ -60,6 +76,19 @@ public class TurnControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handStoneClick(Stone stone, boolean collect) {
|
||||||
|
if (collect) {
|
||||||
|
if (!selectedStones.remove(stone)) {
|
||||||
|
selectedStones.add(stone);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selectedStones.clear();
|
||||||
|
selectedStones.add(stone);
|
||||||
|
}
|
||||||
|
|
||||||
|
view.setSelectedStones(selectedStones);
|
||||||
|
}
|
||||||
|
|
||||||
private void endOfTurn() {
|
private void endOfTurn() {
|
||||||
timer.stopTimer();
|
timer.stopTimer();
|
||||||
endOfTurnEvent.emit();
|
endOfTurnEvent.emit();
|
||||||
|
|
Reference in a new issue