Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tristan MAISONNEUVE
projetS2-2021-23-LJ
Commits
fd2d0560
Commit
fd2d0560
authored
Jun 24, 2021
by
Jolan RENOUX
Browse files
maj appp
parent
869ae2cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/Application.java
View file @
fd2d0560
import
PremiereFenetre.PremiereFenetre
;
import
com.mashape.unirest.http.exceptions.UnirestException
;
import
com.sun.jdi.connect.Connector
;
import
info1.network.*
;
import
info1.ships.BadCoordException
;
import
info1.ships.CoordsBadShipException
;
...
...
@@ -23,8 +24,17 @@ public class Application {
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
Game
jeu
;
boolean
done
=
false
;
Player
jaquie
;
int
valtouche
;
Game
jeu
=
null
;
try
{
jeu
=
new
Game
(
0
);
}
catch
(
BadIdException
e
)
{
e
.
printStackTrace
();}
/*
FenetreConnexion fc = new FenetreConnexion("Connexion au serveur et aux parties");
...
...
@@ -44,12 +54,15 @@ public class Application {
//TODO Init fleet avec boucle listener ect
NavyFleet
fleet
=
new
NavyFleet
();
/* flotte de test
try {
fleet.add(new AircraftCarrier("porteavion1","A1","A6"));
fleet.add(new AircraftCarrier("porteavion2","B1","B6"));
fleet.add(new AircraftCarrier("porteavion3","C1","C6"));
fleet.add(new AircraftCarrier("porteavion4","D1","D6"));
} catch (BadCoordException | CoordsBadShipException e) {e.printStackTrace();}
*/
while
(
pf
.
fc
.
isValider
()){
Thread
.
sleep
(
500
);}
jaquie
=
new
Player
(
pf
.
fc
.
getPseudo
());
...
...
@@ -57,23 +70,29 @@ public class Application {
//TODO IHM : combobox avec cette liste
//TODO Init game ou rejoindre
//new game
try
{
Network
.
initNewGame
(
url
,
jaquie
,
fleet
);
}
//rejoindre game
catch
(
UnirestException
|
BadCoordException
|
UncompleteFleetException
e
)
{
e
.
printStackTrace
();
while
(
done
)
{
if
(
pf
.
fc
.
getChoix
()
==
1
)
{
//rejoindre
try
{
jeu
=
pf
.
fc
.
getJeu
();
Network
.
joinGame
(
url
,
pf
.
fc
.
getJeu
(),
jaquie
,
fleet
);
}
catch
(
UnirestException
|
UncompleteFleetException
|
BadCoordException
e
)
{
e
.
printStackTrace
();}
done
=
true
;
}
else
if
(
pf
.
fc
.
getChoix
()
==
2
)
{
//creer partie
try
{
jeu
=
Network
.
initNewGame
(
url
,
jaquie
,
fleet
);
}
catch
(
UnirestException
|
BadCoordException
|
UncompleteFleetException
e
)
{
e
.
printStackTrace
();}
done
=
true
;
}
else
if
(
pf
.
fc
.
getChoix
()
==
0
)
{
//pas encore choisi
}
else
{
//probleme
System
.
out
.
println
(
"PROBLEME"
);
}
}
/*
try {
Network.joinGame(url,LISTENER_GAME_CHOISI_DANS_LA_LISTE,jaquie,fleet);
} catch (UnirestException | UncompleteFleetException | BadCoordException e) {e.printStackTrace();}
*/
/*
...
...
@@ -99,8 +118,11 @@ public class Application {
break
;
case
10
:
System
.
out
.
println
(
"10 c'est au joueur courant de jouer"
);
while
(
FenetreJeux
.
getCoco
()
!=
null
)
Network
.
playOneTurn
(
"http://172.26.82.18//api/v0"
,
GAME
,
jaquie
,
FenetreJeux
.
getCoco
());
while
(
FenetreJeux
.
getCoco
()
!=
null
)
{
try
{
valtouche
=
Network
.
playOneTurn
(
"http://172.26.82.18//api/v0"
,
jeu
,
jaquie
,
FenetreJeux
.
getCoco
());
}
catch
(
UnirestException
|
BadCoordException
e
)
{
e
.
printStackTrace
();}
}
break
;
case
-
10
:
System
.
out
.
println
(
"-10 ce n'est pas au joueur courant de jouer"
);
...
...
src/vue/FenetreConnexion.java
View file @
fd2d0560
...
...
@@ -27,6 +27,7 @@ import java.util.function.BiPredicate;
public
class
FenetreConnexion
extends
JFrame
{
private
boolean
valider
=
false
;
private
int
choix
=
0
;
private
Game
jeu
;
...
...
@@ -229,15 +230,16 @@ public class FenetreConnexion extends JFrame {
rejoindre
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
jeu
=
(
Game
)
pInitialise
.
getSelectedItem
();
choix
=
1
;
//TODO ihm changer fenetre
}
});
creerPartie
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
choix
=
2
;
}
});
...
...
@@ -303,11 +305,11 @@ public class FenetreConnexion extends JFrame {
public
String
getPseudo
(){
return
pseudo
.
getText
();
}
public
boolean
isValider
()
{
return
valider
;}
public
Game
getJeu
()
{
return
jeu
;}
public
int
getChoix
()
{
return
choix
;
}
// public Integer getGameID(){ return gameId; }
public
NavyFleet
getFlotte
(){
return
flotte
;}
public
Boolean
getCreerpartie
()
{
return
true
;
}
public
Game
getgamefromlist
(){
return
(
Game
)
pInitialise
.
getSelectedItem
();}
// Les setters
// public void setGameID(Integer i){ gameId = i; }
...
...
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