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
Quentin DRUAULT-AUBIN
lo23-project
Commits
10d88054
Commit
10d88054
authored
Dec 12, 2017
by
Antonin Deneux
Committed by
Quentin DRUAULT-AUBIN
Dec 15, 2017
Browse files
finishGame() done
parent
66bf55bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Battleship/src/main/java/com/utclo23/ihmtable/IHMTableFacade.java
View file @
10d88054
...
...
@@ -209,7 +209,7 @@ public class IHMTableFacade implements IIHMTableToIHMMain, IIHMTableToData {
*/
@Override
public
void
finishGame
(
StatGame
stGame
)
{
throw
new
UnsupportedOperationException
(
EXCEPTION_MESSAGE
);
controller
.
displayFinishPopup
(
stGame
.
getWinner
().
getPlayerName
()
);
}
/**
...
...
Battleship/src/main/java/com/utclo23/ihmtable/controller/InGameGUIController.java
View file @
10d88054
...
...
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
javafx.animation.KeyFrame
;
import
javafx.animation.Timeline
;
import
javafx.collections.ObservableList
;
...
...
@@ -33,7 +34,10 @@ import javafx.fxml.FXMLLoader;
import
javafx.scene.Node
;
import
javafx.scene.Parent
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Alert
;
import
javafx.scene.control.Alert.AlertType
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.ButtonType
;
import
javafx.scene.control.Label
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.input.MouseEvent
;
...
...
@@ -667,6 +671,34 @@ public class InGameGUIController {
{
placeMine
(
m
.
getCoord
(),
p
);
}
/**
* Method to display popup asking the player to save the game !
* @param winner
*/
public
void
displayFinishPopup
(
String
winner
)
{
String
sMessage
=
"Victory! I'm proud of you General!"
;
if
(!
winner
.
equals
(
facade
.
getFacadeData
().
getMyPublicUserProfile
().
getPlayerName
()))
{
sMessage
=
"Defeat! You should train against AI! Hahahah!"
;
}
Alert
alert
=
new
Alert
(
AlertType
.
CONFIRMATION
);
alert
.
setTitle
(
"End of the Game"
);
alert
.
setHeaderText
(
sMessage
+
"\n"
+
winner
+
"wins this one!!!\n"
);
alert
.
setContentText
(
"Do you want to save this game?"
);
Optional
<
ButtonType
>
result
=
alert
.
showAndWait
();
if
(
result
.
get
()
==
ButtonType
.
OK
)
{
// ... user chose OK
//facade.getFacadeData().save();
}
try
{
facade
.
getFacadeIHMMain
().
toMenu
();
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
InGameGUIController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
private
class
AttackEvent
implements
EventHandler
{
...
...
Write
Preview
Supports
Markdown
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