Feedback
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@461 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
c50fd5d701
commit
823ef9d4fe
10 changed files with 192 additions and 44 deletions
|
@ -29,4 +29,10 @@ public class MockStoneCollectionPanel implements IStoneCollectionPanel {
|
||||||
return setClickEvent;
|
return setClickEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHidden(boolean enable) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,12 @@ public class MockView implements IView {
|
||||||
return startTurnEvent;
|
return startTurnEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent getAcknowledgeInvalidEvent() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getEndProgramEvent() {
|
public IEvent getEndProgramEvent() {
|
||||||
return quitEvent;
|
return quitEvent;
|
||||||
|
@ -212,4 +218,22 @@ public class MockView implements IView {
|
||||||
return gameListPanel;
|
return gameListPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldError(int points) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStoneCollectionHidden(boolean enable) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldFirstError() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package jrummikub.control;
|
||||||
import static jrummikub.model.PlayerSettings.Type.*;
|
import static jrummikub.model.PlayerSettings.Type.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -42,6 +43,8 @@ public class RoundControl {
|
||||||
private List<Connection> connections = new ArrayList<Connection>();
|
private List<Connection> connections = new ArrayList<Connection>();
|
||||||
private ITurnControl turnControl;
|
private ITurnControl turnControl;
|
||||||
private boolean roundFinished;
|
private boolean roundFinished;
|
||||||
|
private boolean lastTurnNotEnoughPoints;
|
||||||
|
private boolean lastTurnMeldError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new RoundControl using the given gameState and view
|
* Create a new RoundControl using the given gameState and view
|
||||||
|
@ -84,6 +87,13 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
connections.add(view.getAcknowledgeInvalidEvent().add(new IListener() {
|
||||||
|
@Override
|
||||||
|
public void handle() {
|
||||||
|
nextPlayer();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
prepareTurn();
|
prepareTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +149,7 @@ public class RoundControl {
|
||||||
TurnMode turnMode = TurnMode.NORMAL_TURN;
|
TurnMode turnMode = TurnMode.NORMAL_TURN;
|
||||||
|
|
||||||
if (roundState.getTurnNumber() < 1) {
|
if (roundState.getTurnNumber() < 1) {
|
||||||
|
view.setStoneCollectionHidden(true);
|
||||||
turnMode = TurnMode.INSPECT_ONLY;
|
turnMode = TurnMode.INSPECT_ONLY;
|
||||||
if (clonedHand.getIdenticalStoneCount() >= 3) {
|
if (clonedHand.getIdenticalStoneCount() >= 3) {
|
||||||
turnMode = TurnMode.MAY_REDEAL;
|
turnMode = TurnMode.MAY_REDEAL;
|
||||||
|
@ -199,10 +210,39 @@ public class RoundControl {
|
||||||
private void endOfTurn() {
|
private void endOfTurn() {
|
||||||
turnControl = null;
|
turnControl = null;
|
||||||
roundState.getActivePlayer().setHand(clonedHand);
|
roundState.getActivePlayer().setHand(clonedHand);
|
||||||
|
boolean goToNextPlayer = true;
|
||||||
|
lastTurnNotEnoughPoints = false;
|
||||||
|
lastTurnMeldError = false;
|
||||||
if (roundState.getTurnNumber() >= 1) {
|
if (roundState.getTurnNumber() >= 1) {
|
||||||
checkTurn();
|
goToNextPlayer = checkTurn();
|
||||||
}
|
}
|
||||||
|
if (goToNextPlayer) {
|
||||||
|
nextPlayer();
|
||||||
|
} else {
|
||||||
|
view.setBottomPanel(BottomPanelType.INVALID_TURN_PANEL);
|
||||||
|
if (lastTurnNotEnoughPoints) {
|
||||||
|
view.setInitialMeldError(roundState.getGameSettings()
|
||||||
|
.getInitialMeldThreshold());
|
||||||
|
} else if (lastTurnMeldError) {
|
||||||
|
view.setInitialMeldFirstError();
|
||||||
|
} else {
|
||||||
|
List<Stone> markedStones = new ArrayList<Stone>();
|
||||||
|
for (Pair<StoneSet, Position> set : clonedTable) {
|
||||||
|
if (!set.getFirst().isValid(roundState.getGameSettings())) {
|
||||||
|
for (Stone stone : set.getFirst()) {
|
||||||
|
markedStones.add(stone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
view.setStoneCollectionHidden(true);
|
||||||
|
view.setSelectedStones(markedStones);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void nextPlayer() {
|
||||||
|
view.setSelectedStones(Collections.<Stone> emptyList());
|
||||||
|
view.setStoneCollectionHidden(false);
|
||||||
if (roundState.getLastPlayer() == null) {
|
if (roundState.getLastPlayer() == null) {
|
||||||
if (roundState.getGameHeap().getSize() == 0) {
|
if (roundState.getGameHeap().getSize() == 0) {
|
||||||
roundState.setLastPlayer(roundState.getNthNextPlayer(0));
|
roundState.setLastPlayer(roundState.getNthNextPlayer(0));
|
||||||
|
@ -225,21 +265,23 @@ public class RoundControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTurn() {
|
private boolean checkTurn() {
|
||||||
if (!clonedTable.isValid()) {
|
if (!clonedTable.isValid()) {
|
||||||
rejectMove();
|
rejectMove();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!roundState.getActivePlayer().getLaidOut()) {
|
if (!roundState.getActivePlayer().getLaidOut()) {
|
||||||
// Player touched forbidden stones
|
// Player touched forbidden stones
|
||||||
if (!tableSetDifference(clonedTable, roundState.getTable())
|
if (!tableSetDifference(clonedTable, roundState.getTable())
|
||||||
.isEmpty()) {
|
.isEmpty()) {
|
||||||
rejectMove();
|
rejectMove();
|
||||||
return;
|
lastTurnMeldError = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (!laidOutValidPoints()) {
|
if (!laidOutValidPoints()) {
|
||||||
rejectMove();
|
rejectMove();
|
||||||
return;
|
lastTurnNotEnoughPoints = true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<Stone> tableDiff = tableDifference(roundState.getTable(),
|
Set<Stone> tableDiff = tableDifference(roundState.getTable(),
|
||||||
|
@ -256,6 +298,7 @@ public class RoundControl {
|
||||||
endOfRound();
|
endOfRound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rejectMove() {
|
private void rejectMove() {
|
||||||
|
@ -358,8 +401,8 @@ public class RoundControl {
|
||||||
.getGameSettings());
|
.getGameSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
bestScore = updateBestScore(bestScore, -stonePoints, playerHand
|
bestScore = updateBestScore(bestScore, -stonePoints,
|
||||||
.getSize());
|
playerHand.getSize());
|
||||||
|
|
||||||
points.add(-stonePoints);
|
points.add(-stonePoints);
|
||||||
pointSum += stonePoints;
|
pointSum += stonePoints;
|
||||||
|
@ -381,8 +424,8 @@ public class RoundControl {
|
||||||
private static Pair<Integer, Integer> updateBestScore(
|
private static Pair<Integer, Integer> updateBestScore(
|
||||||
Pair<Integer, Integer> bestScore, int stonePoints, int size) {
|
Pair<Integer, Integer> bestScore, int stonePoints, int size) {
|
||||||
if (bestScore.getFirst() == stonePoints) {
|
if (bestScore.getFirst() == stonePoints) {
|
||||||
return new Pair<Integer, Integer>(stonePoints, Math.min(bestScore
|
return new Pair<Integer, Integer>(stonePoints, Math.min(
|
||||||
.getSecond(), size));
|
bestScore.getSecond(), size));
|
||||||
} else if (bestScore.getFirst() < stonePoints) {
|
} else if (bestScore.getFirst() < stonePoints) {
|
||||||
return new Pair<Integer, Integer>(stonePoints, size);
|
return new Pair<Integer, Integer>(stonePoints, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,12 +441,12 @@ public class HumanTurnControl extends AbstractTurnControl {
|
||||||
|
|
||||||
private void endOfTurn(boolean redeal) {
|
private void endOfTurn(boolean redeal) {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
|
view.setSelectedStones(new ArrayList<Stone>());
|
||||||
if (redeal) {
|
if (redeal) {
|
||||||
redealEvent.emit();
|
redealEvent.emit();
|
||||||
} else {
|
} else {
|
||||||
endOfTurnEvent.emit();
|
endOfTurnEvent.emit();
|
||||||
}
|
}
|
||||||
view.setSelectedStones(new ArrayList<Stone>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private int compareJokers(Stone s1, Stone s2) {
|
static private int compareJokers(Stone s1, Stone s2) {
|
||||||
|
|
|
@ -4,4 +4,6 @@ package jrummikub.view;
|
||||||
* The view of the collection that shows the stones a player has selected
|
* The view of the collection that shows the stones a player has selected
|
||||||
*/
|
*/
|
||||||
public interface IStoneCollectionPanel extends IStonePanel {
|
public interface IStoneCollectionPanel extends IStonePanel {
|
||||||
|
|
||||||
|
void setHidden(boolean enable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,14 @@ public interface IView {
|
||||||
*/
|
*/
|
||||||
public IEvent getStartTurnEvent();
|
public IEvent getStartTurnEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start turn event is emitted when the player knows what invalid stones
|
||||||
|
* he played
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
|
IEvent getAcknowledgeInvalidEvent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The quit event is emitted when the player wants to quit the game
|
* The quit event is emitted when the player wants to quit the game
|
||||||
*
|
*
|
||||||
|
@ -237,6 +245,8 @@ public interface IView {
|
||||||
/** */
|
/** */
|
||||||
START_TURN_PANEL,
|
START_TURN_PANEL,
|
||||||
/** */
|
/** */
|
||||||
|
INVALID_TURN_PANEL,
|
||||||
|
/** */
|
||||||
HUMAN_HAND_PANEL,
|
HUMAN_HAND_PANEL,
|
||||||
/** */
|
/** */
|
||||||
COMPUTER_HAND_PANEL,
|
COMPUTER_HAND_PANEL,
|
||||||
|
@ -244,4 +254,10 @@ public interface IView {
|
||||||
WIN_PANEL
|
WIN_PANEL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setInitialMeldError(int points);
|
||||||
|
|
||||||
|
void setStoneCollectionHidden(boolean enable);
|
||||||
|
|
||||||
|
void setInitialMeldFirstError();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
import jrummikub.util.Event;
|
import jrummikub.util.Event;
|
||||||
import jrummikub.util.IEvent;
|
import jrummikub.util.IEvent;
|
||||||
|
import jrummikub.view.IView.BottomPanelType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel that is displayed before a player's turn
|
* A panel that is displayed before a player's turn
|
||||||
|
@ -29,6 +30,9 @@ class StartTurnPanel extends JPanel {
|
||||||
private JButton startTurnButton;
|
private JButton startTurnButton;
|
||||||
|
|
||||||
private Event startTurnEvent = new Event();
|
private Event startTurnEvent = new Event();
|
||||||
|
private Event acknowledgeInvalidEvent = new Event();
|
||||||
|
|
||||||
|
private Event buttonEvent = startTurnEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new StartTurnPanel
|
* Creates a new StartTurnPanel
|
||||||
|
@ -50,7 +54,7 @@ class StartTurnPanel extends JPanel {
|
||||||
startTurnButton.addActionListener(new ActionListener() {
|
startTurnButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
startTurnEvent.emit();
|
buttonEvent.emit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(startTurnButton);
|
add(startTurnButton);
|
||||||
|
@ -66,10 +70,22 @@ class StartTurnPanel extends JPanel {
|
||||||
void setCurrentPlayerName(String playerName) {
|
void setCurrentPlayerName(String playerName) {
|
||||||
startTurnLabel.setText(playerName + " ist jetzt an der Reihe.");
|
startTurnLabel.setText(playerName + " ist jetzt an der Reihe.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setInitialMeldError(int points) {
|
||||||
|
startTurnLabel.setText("Es wurden weniger als " + points + " Punkte ausgelegt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInitialMeldFirstError() {
|
||||||
|
startTurnLabel.setText("Vor dem Rauskommen darf nicht angelegt werden.");
|
||||||
|
}
|
||||||
|
|
||||||
IEvent getStartTurnEvent() {
|
IEvent getStartTurnEvent() {
|
||||||
return startTurnEvent;
|
return startTurnEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEvent getAcknowledgeInvalidEvent() {
|
||||||
|
return acknowledgeInvalidEvent;
|
||||||
|
}
|
||||||
|
|
||||||
private void rescale() {
|
private void rescale() {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
|
@ -93,4 +109,19 @@ class StartTurnPanel extends JPanel {
|
||||||
buttonWidth, buttonHeight);
|
buttonWidth, buttonHeight);
|
||||||
startTurnButton.setFont(startTurnButton.getFont().deriveFont(fontSize));
|
startTurnButton.setFont(startTurnButton.getFont().deriveFont(fontSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setType(BottomPanelType type) {
|
||||||
|
switch (type) {
|
||||||
|
case START_TURN_PANEL:
|
||||||
|
startTurnButton.setText("Zug beginnen");
|
||||||
|
buttonEvent = startTurnEvent;
|
||||||
|
break;
|
||||||
|
case INVALID_TURN_PANEL:
|
||||||
|
startTurnLabel.setText("Es liegen ung\u00FCltige Serien auf dem Tisch.");
|
||||||
|
startTurnButton.setText("N\u00E4chster Spieler");
|
||||||
|
buttonEvent = acknowledgeInvalidEvent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements
|
||||||
|
|
||||||
private Event1<Point> otherClickEvent = new Event1<Point>();
|
private Event1<Point> otherClickEvent = new Event1<Point>();
|
||||||
|
|
||||||
private boolean pauseMode = false;
|
private boolean hidden = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new StoneCollection instance
|
* Creates a new StoneCollection instance
|
||||||
|
@ -123,7 +123,7 @@ class StoneCollectionPanel extends AbstractStonePanel implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pauseMode) {
|
if (hidden) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +155,9 @@ class StoneCollectionPanel extends AbstractStonePanel implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enablePauseMode(boolean enable) {
|
@Override
|
||||||
pauseMode = enable;
|
public void setHidden(boolean enable) {
|
||||||
|
hidden = enable;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
void enablePauseMode(boolean enable) {
|
void enablePauseMode(boolean enable) {
|
||||||
stoneCollection.enablePauseMode(enable);
|
stoneCollection.setHidden(enable);
|
||||||
|
|
||||||
pauseMode = enable;
|
pauseMode = enable;
|
||||||
setScale();
|
setScale();
|
||||||
|
|
|
@ -154,7 +154,8 @@ public class View extends JFrame implements IView {
|
||||||
showSettingsPanel(false);
|
showSettingsPanel(false);
|
||||||
showLoginPanel(false);
|
showLoginPanel(false);
|
||||||
showGameListPanel(false);
|
showGameListPanel(false);
|
||||||
getHandPanel().setStones(Collections.<Pair<Stone, Position>> emptyList());
|
getHandPanel().setStones(
|
||||||
|
Collections.<Pair<Stone, Position>> emptyList());
|
||||||
getTablePanel().setStoneSets(
|
getTablePanel().setStoneSets(
|
||||||
Collections.<Pair<StoneSet, Position>> emptyList());
|
Collections.<Pair<StoneSet, Position>> emptyList());
|
||||||
setSelectedStones(Collections.<Stone> emptyList());
|
setSelectedStones(Collections.<Stone> emptyList());
|
||||||
|
@ -305,8 +306,8 @@ public class View extends JFrame implements IView {
|
||||||
mainLayer.add(table);
|
mainLayer.add(table);
|
||||||
|
|
||||||
playerPanel = new PlayerPanel();
|
playerPanel = new PlayerPanel();
|
||||||
playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0, 0,
|
playerPanel.setBorder(new MatteBorder(PLAYER_PANEL_BORDER_WIDTH, 0, 0,
|
||||||
Color.BLACK));
|
0, Color.BLACK));
|
||||||
mainLayer.add(playerPanel);
|
mainLayer.add(playerPanel);
|
||||||
|
|
||||||
startTurnPanel = new StartTurnPanel();
|
startTurnPanel = new StartTurnPanel();
|
||||||
|
@ -397,6 +398,16 @@ public class View extends JFrame implements IView {
|
||||||
startTurnPanel.setCurrentPlayerName(playerName);
|
startTurnPanel.setCurrentPlayerName(playerName);
|
||||||
pausePanel.setCurrentPlayerName(playerName);
|
pausePanel.setCurrentPlayerName(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldError(int points) {
|
||||||
|
startTurnPanel.setInitialMeldError(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInitialMeldFirstError() {
|
||||||
|
startTurnPanel.setInitialMeldFirstError();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrentPlayerColor(Color color) {
|
public void setCurrentPlayerColor(Color color) {
|
||||||
|
@ -413,6 +424,11 @@ public class View extends JFrame implements IView {
|
||||||
return startTurnPanel.getStartTurnEvent();
|
return startTurnPanel.getStartTurnEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEvent getAcknowledgeInvalidEvent() {
|
||||||
|
return startTurnPanel.getAcknowledgeInvalidEvent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent getNewRoundEvent() {
|
public IEvent getNewRoundEvent() {
|
||||||
return winPanel.getNewRoundEvent();
|
return winPanel.getNewRoundEvent();
|
||||||
|
@ -430,24 +446,24 @@ public class View extends JFrame implements IView {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private List<Pair<Stone, Position>> createDecorationStones() {
|
private List<Pair<Stone, Position>> createDecorationStones() {
|
||||||
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(-'J',
|
Pair<Stone, Position> stoneJ = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(2.5f, 0));
|
-'J', StoneColor.BLACK), new Position(2.5f, 0));
|
||||||
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(-'R',
|
Pair<Stone, Position> stoneR = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.ORANGE), new Position(3.5f, 0));
|
-'R', StoneColor.ORANGE), new Position(3.5f, 0));
|
||||||
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(-'u',
|
Pair<Stone, Position> stoneu1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLUE), new Position(4.5f, 0));
|
-'u', StoneColor.BLUE), new Position(4.5f, 0));
|
||||||
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(-'m',
|
Pair<Stone, Position> stonem1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.RED), new Position(5.5f, 0));
|
-'m', StoneColor.RED), new Position(5.5f, 0));
|
||||||
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(-'m',
|
Pair<Stone, Position> stonem2 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.GREEN), new Position(6.5f, 0));
|
-'m', StoneColor.GREEN), new Position(6.5f, 0));
|
||||||
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(-'i',
|
Pair<Stone, Position> stonei = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.VIOLET), new Position(7.5f, 0));
|
-'i', StoneColor.VIOLET), new Position(7.5f, 0));
|
||||||
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(-'k',
|
Pair<Stone, Position> stonek = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.AQUA), new Position(8.5f, 0));
|
-'k', StoneColor.AQUA), new Position(8.5f, 0));
|
||||||
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(-'u',
|
Pair<Stone, Position> stoneu2 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.GRAY), new Position(9.5f, 0));
|
-'u', StoneColor.GRAY), new Position(9.5f, 0));
|
||||||
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(-'b',
|
Pair<Stone, Position> stoneb = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(10.5f, 0));
|
-'b', StoneColor.BLACK), new Position(10.5f, 0));
|
||||||
|
|
||||||
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
|
Pair<Stone, Position> stone1 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.RED), new Position(2, 1));
|
StoneColor.RED), new Position(2, 1));
|
||||||
|
@ -462,9 +478,9 @@ public class View extends JFrame implements IView {
|
||||||
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone(
|
Pair<Stone, Position> stone6 = new Pair<Stone, Position>(new Stone(
|
||||||
StoneColor.BLACK), new Position(11, 1));
|
StoneColor.BLACK), new Position(11, 1));
|
||||||
|
|
||||||
return Arrays
|
return Arrays.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei,
|
||||||
.asList(stoneJ, stoneR, stoneu1, stonem1, stonem2, stonei, stonek,
|
stonek, stoneu2, stoneb, stone1, stone2, stone3, stone4,
|
||||||
stoneu2, stoneb, stone1, stone2, stone3, stone4, stone5, stone6);
|
stone5, stone6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -475,17 +491,26 @@ public class View extends JFrame implements IView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSetBottomPanel(BottomPanelType type) {
|
private void doSetBottomPanel(BottomPanelType type) {
|
||||||
startTurnPanel.setVisible(type == BottomPanelType.START_TURN_PANEL);
|
boolean showStartTurnPanel = type == BottomPanelType.START_TURN_PANEL
|
||||||
|
|| type == BottomPanelType.INVALID_TURN_PANEL;
|
||||||
|
startTurnPanel.setVisible(showStartTurnPanel);
|
||||||
|
startTurnPanel.setType(type);
|
||||||
winPanel.setVisible(type == BottomPanelType.WIN_PANEL);
|
winPanel.setVisible(type == BottomPanelType.WIN_PANEL);
|
||||||
playerPanel.setVisible(type != BottomPanelType.START_TURN_PANEL
|
playerPanel.setVisible((!showStartTurnPanel)
|
||||||
&& type != BottomPanelType.WIN_PANEL && type != null);
|
&& type != BottomPanelType.WIN_PANEL && type != null);
|
||||||
|
|
||||||
if (type == BottomPanelType.START_GAME_PANEL) {
|
if (type == BottomPanelType.START_GAME_PANEL) {
|
||||||
table.setStoneSets(Collections.<Pair<StoneSet, Position>> emptyList());
|
table.setStoneSets(Collections
|
||||||
|
.<Pair<StoneSet, Position>> emptyList());
|
||||||
playerPanel.getHandPanel().setStones(createDecorationStones());
|
playerPanel.getHandPanel().setStones(createDecorationStones());
|
||||||
}
|
}
|
||||||
|
|
||||||
playerPanel.showButtons(type != BottomPanelType.START_GAME_PANEL);
|
playerPanel.showButtons(type != BottomPanelType.START_GAME_PANEL);
|
||||||
playerPanel.enableButtons(type != BottomPanelType.COMPUTER_HAND_PANEL);
|
playerPanel.enableButtons(type != BottomPanelType.COMPUTER_HAND_PANEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStoneCollectionHidden(boolean enable) {
|
||||||
|
table.getStoneCollectionPanel().setHidden(enable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue