Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johan Gustav Thrane-Nielsen
inf101.v20.sem2.losning
Commits
bc3d1743
Commit
bc3d1743
authored
Mar 25, 2020
by
Anna Maria Eilertsen
Browse files
added label text for end of game with no winner
parent
8eb0d71f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/inf101/v20/sem2/mnkgames/GUI/MNKGameGUI.java
View file @
bc3d1743
...
...
@@ -90,14 +90,20 @@ s * Initializes a JFrame in which we place the game
this
.
updateUI
();
}
/**
* Children panels can call this method after being clicked.
*/
private
void
registerClick
()
{
updateGameUI
();
endOfTurn
();
if
(!
multiplayer
)
{
AIPlayerTurn
();
}
}
public
void
updateGameUI
()
{
/**
* Should be called after a click to update the UI to reflect the current game state
*/
private
void
endOfTurn
()
{
clickablePanels
.
forEach
(
item
->
item
.
updateToGame
());
updateMessage
();
MNKGameGUI
.
super
.
updateUI
();
...
...
@@ -107,12 +113,14 @@ s * Initializes a JFrame in which we place the game
}
}
private
void
AIPlayerTurn
()
{
ai
.
makeMove
(
game
);
updateGameUI
();
endOfTurn
();
}
/**
* Should be called once a game stops
*/
private
void
stop
()
{
updateMessage
();
clickablePanels
.
forEach
(
item
->
item
.
removeMouseListeners
());
...
...
@@ -265,8 +273,11 @@ s * Initializes a JFrame in which we place the game
private
void
updateMessage
()
{
if
(
game
.
hasWinner
())
statusMessage
.
setText
(
"The game is over! The winner is "
+
getPlayerName
(
game
.
getWinner
()));
else
else
if
(
game
.
hasPossibleMoves
())
{
statusMessage
.
setText
(
"Next move from "
+
getPlayerName
(
game
.
getCurrent
()));
}
else
{
statusMessage
.
setText
(
"The game is over! No one won."
);
}
}
public
void
collectPlayerInfo
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment