Set correct player names :)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@212 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
a64492dc4b
commit
4a860e53cf
5 changed files with 22 additions and 12 deletions
|
@ -53,11 +53,11 @@ public class RoundControl {
|
||||||
view.enableStartTurnPanel(true);
|
view.enableStartTurnPanel(true);
|
||||||
view.getTablePanel().setStoneSets(clonedTable);
|
view.getTablePanel().setStoneSets(clonedTable);
|
||||||
view.setCurrentPlayerName(gameState.getActivePlayer().getName());
|
view.setCurrentPlayerName(gameState.getActivePlayer().getName());
|
||||||
view.getTablePanel().setRightPlayerName(
|
view.getTablePanel().setLeftPlayerName(
|
||||||
gameState.getNthNextPlayer(1).getName());
|
gameState.getNthNextPlayer(1).getName());
|
||||||
view.getTablePanel().setTopPlayerName(
|
view.getTablePanel().setTopPlayerName(
|
||||||
gameState.getNthNextPlayer(2).getName());
|
gameState.getNthNextPlayer(2).getName());
|
||||||
view.getTablePanel().setLeftPlayerName(
|
view.getTablePanel().setRightPlayerName(
|
||||||
gameState.getNthNextPlayer(3).getName());
|
gameState.getNthNextPlayer(3).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@ public class GameState implements IGameState {
|
||||||
public GameState() {
|
public GameState() {
|
||||||
table = new Table();
|
table = new Table();
|
||||||
players = new ArrayList<Player>();
|
players = new ArrayList<Player>();
|
||||||
players.add(new Player("Player 1", Color.RED));
|
players.add(new Player("Ida", Color.RED));
|
||||||
players.add(new Player("Player 2", Color.YELLOW));
|
players.add(new Player("Matthias", Color.YELLOW));
|
||||||
players.add(new Player("Player 3", Color.GREEN));
|
players.add(new Player("Jannis", Color.GREEN));
|
||||||
players.add(new Player("Player 4", Color.BLACK));
|
players.add(new Player("Bennet", Color.BLACK));
|
||||||
activePlayer = 0;
|
activePlayer = 0;
|
||||||
gameHeap = new StoneHeap();
|
gameHeap = new StoneHeap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class StartTurnPanel extends JPanel {
|
||||||
* the player name
|
* the player name
|
||||||
*/
|
*/
|
||||||
void setCurrentPlayerName(String playerName) {
|
void setCurrentPlayerName(String playerName) {
|
||||||
startTurnLabel.setText("'" + playerName + "' ist jetzt an der Reihe.");
|
startTurnLabel.setText(playerName + " ist jetzt an der Reihe.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class View extends JFrame implements IView {
|
||||||
public void setCurrentPlayerName(String playerName) {
|
public void setCurrentPlayerName(String playerName) {
|
||||||
playerPanel.setCurrentPlayerName(playerName);
|
playerPanel.setCurrentPlayerName(playerName);
|
||||||
startTurnPanel.setCurrentPlayerName(playerName);
|
startTurnPanel.setCurrentPlayerName(playerName);
|
||||||
|
winPanel.setCurrentPlayerName(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class WinPanel extends JPanel {
|
||||||
setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET,
|
setBorder(new EmptyBorder(PANEL_INSET, PANEL_INSET, PANEL_INSET,
|
||||||
PANEL_INSET));
|
PANEL_INSET));
|
||||||
|
|
||||||
winLabel = new JLabel("Du hast gewonnen!");
|
winLabel = new JLabel();
|
||||||
winLabel.setHorizontalAlignment(JLabel.CENTER);
|
winLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
winLabel.setHorizontalTextPosition(JLabel.CENTER);
|
winLabel.setHorizontalTextPosition(JLabel.CENTER);
|
||||||
winLabel.setVerticalAlignment(JLabel.CENTER);
|
winLabel.setVerticalAlignment(JLabel.CENTER);
|
||||||
|
@ -73,6 +73,16 @@ public class WinPanel extends JPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the current player
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the player name
|
||||||
|
*/
|
||||||
|
void setCurrentPlayerName(String name) {
|
||||||
|
winLabel.setText("Du hast gewonnen, " + name + "!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The new game event is emitted when the player wants to start a new game
|
* The new game event is emitted when the player wants to start a new game
|
||||||
*
|
*
|
||||||
|
@ -94,8 +104,7 @@ public class WinPanel extends JPanel {
|
||||||
private void rescale() {
|
private void rescale() {
|
||||||
Insets insets = getInsets();
|
Insets insets = getInsets();
|
||||||
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
int x = insets.left, y = insets.top, width = getWidth() - insets.left
|
||||||
- insets.right, height = getHeight() - insets.top
|
- insets.right, height = getHeight() - insets.top - insets.bottom;
|
||||||
- insets.bottom;
|
|
||||||
|
|
||||||
if (width > PANEL_MAX_WIDTH) {
|
if (width > PANEL_MAX_WIDTH) {
|
||||||
x += (width - PANEL_MAX_WIDTH) / 4;
|
x += (width - PANEL_MAX_WIDTH) / 4;
|
||||||
|
@ -114,8 +123,8 @@ public class WinPanel extends JPanel {
|
||||||
buttonWidth, buttonHeight);
|
buttonWidth, buttonHeight);
|
||||||
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
newGameButton.setFont(newGameButton.getFont().deriveFont(fontSize));
|
||||||
|
|
||||||
quitButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y
|
quitButton.setBounds(x + buttonWidth + PANEL_SEPARATOR, y + firstLineHeight
|
||||||
+ firstLineHeight + PANEL_SEPARATOR, buttonWidth, buttonHeight);
|
+ PANEL_SEPARATOR, buttonWidth, buttonHeight);
|
||||||
quitButton.setFont(quitButton.getFont().deriveFont(fontSize));
|
quitButton.setFont(quitButton.getFont().deriveFont(fontSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue