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
2c5653c1
Commit
2c5653c1
authored
Jun 23, 2021
by
Jérémie
Browse files
Merge remote-tracking branch 'origin/master'
parents
b67e4485
cad96cfc
Changes
8
Hide whitespace changes
Inline
Side-by-side
out/production/battleship-student-project-2021/Application.class
View file @
2c5653c1
No preview for this file type
out/production/battleship-student-project-2021/modele/info1/ships/NavyFleet.class
View file @
2c5653c1
No preview for this file type
out/production/battleship-student-project-2021/vue/FenetreConnexion.class
View file @
2c5653c1
No preview for this file type
out/production/battleship-student-project-2021/vue/FenetreJeux.class
View file @
2c5653c1
No preview for this file type
src/Application.java
View file @
2c5653c1
...
...
@@ -31,7 +31,7 @@ public class Application {
*/
PremiereFenetre
pf
=
new
PremiereFenetre
();
Network
.
setProxy
(
"srv-proxy-etu-2.iut-nantes.univ-nantes.prive"
,
3128
);
Network
.
setProxy
(
proxy
,
3128
);
Network
.
enableProxy
(
true
);
//TODO IHM changer le nom de jaquie
...
...
@@ -50,6 +50,10 @@ public class Application {
fleet
.
add
(
new
AircraftCarrier
(
"porteavion3"
,
"C1"
,
"C6"
));
fleet
.
add
(
new
AircraftCarrier
(
"porteavion4"
,
"D1"
,
"D6"
));
}
catch
(
BadCoordException
e
)
{
e
.
printStackTrace
();}
catch
(
CoordsBadShipException
e
)
{
e
.
printStackTrace
();}
while
(
fleet
.
isBelgianConfiguration
()
||
fleet
.
isFrenchConfiguration
()){
}
ArrayList
<
Game
>
parties
=
new
ArrayList
<
Game
>();
...
...
@@ -57,12 +61,19 @@ public class Application {
//TODO Init game ou rejoindre
try
{
Game
newGame
=
new
Game
((
int
)
Math
.
random
());
}
catch
(
BadIdException
e
)
{
e
.
printStackTrace
();}
//new game
try
{
Network
.
initNewGame
(
url
,
jaquie
,
fleet
);
}
catch
(
UnirestException
e
)
{
e
.
printStackTrace
();}
catch
(
UncompleteFleetException
e
)
{
e
.
printStackTrace
();}
catch
(
BadCoordException
e
)
{
e
.
printStackTrace
();}
}
//rejoindre game
catch
(
UnirestException
|
BadCoordException
|
UncompleteFleetException
e
)
{
e
.
printStackTrace
();
}
/*
try {
Network.joinGame(url,LISTENER_GAME_CHOISI_DANS_LA_LISTE,jaquie,fleet);
} catch (UnirestException | UncompleteFleetException | BadCoordException e) {e.printStackTrace();}
*/
/*
1 si la partie est correctement initiée par le joueur courant ;
...
...
src/controleur/BlablaListener.java
deleted
100644 → 0
View file @
b67e4485
package
controleur
;
public
class
BlablaListener
{
}
src/modele/info1/ships/CreationB.java
0 → 100644
View file @
2c5653c1
package
modele.info1.ships
;
import
info1.ships.BadCoordException
;
import
info1.ships.CoordsBadShipException
;
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
public
class
CreationB
{
String
[]
co
=
new
String
[
2
];
Coord
[]
cord1
=
new
Coord
[
2
];
public
CreationB
(
String
str
,
String
str2
)
{
this
.
co
[
0
]
=
str
;
this
.
co
[
1
]
=
str2
;
}
public
Ship
TestCreation
()
throws
CoordsBadShipException
,
BadCoordException
{
try
{
cord1
[
0
]
=
new
Coord
(
co
[
0
]);
}
catch
(
BadCoordException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
try
{
cord1
[
1
]
=
new
Coord
(
co
[
1
]);
}
catch
(
BadCoordException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
int
taille
=
0
;
if
(
cord1
[
0
].
getY
()
==
cord1
[
1
].
getY
())
{
if
(
cord1
[
0
].
getX
()
>
cord1
[
1
].
getX
()){
taille
=
cord1
[
0
].
getX
()
-
cord1
[
1
].
getX
()
+
1
;
}
else
{
taille
=
cord1
[
1
].
getX
()
-
cord1
[
0
].
getX
()
+
1
;
}
}
if
(
cord1
[
0
].
getX
()
==
cord1
[
1
].
getX
())
{
if
(
cord1
[
0
].
getY
()
>
cord1
[
1
].
getY
())
{
taille
=
cord1
[
0
].
getY
()
-
cord1
[
1
].
getY
()
+
1
;
}
else
{
taille
=
cord1
[
1
].
getY
()
-
cord1
[
0
].
getY
()
+
1
;
}
}
else
if
(
cord1
[
0
].
getY
()
!=
cord1
[
1
].
getY
()
&&
cord1
[
0
].
getX
()
!=
cord1
[
1
].
getX
())
{
taille
=
-
1
;
}
switch
(
taille
)
{
case
1
:
try
{
Submarine
s
=
new
Submarine
(
"s"
,
co
[
0
]);
return
s
;
}
catch
(
BadCoordException
|
CoordsBadShipException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
case
2
:
try
{
Destroyer
d
=
new
Destroyer
(
"d"
,
co
[
0
],
co
[
1
]);
return
d
;
}
catch
(
BadCoordException
|
CoordsBadShipException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
case
3
:
try
{
Cruiser
c
=
new
Cruiser
(
"c"
,
co
[
0
],
co
[
1
]);
return
c
;
}
catch
(
BadCoordException
|
CoordsBadShipException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
case
4
:
try
{
Battleship
b
=
new
Battleship
(
"b"
,
co
[
0
],
co
[
1
]);
return
b
;
}
catch
(
BadCoordException
|
CoordsBadShipException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
case
5
:
try
{
AircraftCarrier
a
=
new
AircraftCarrier
(
"a"
,
co
[
0
],
co
[
1
]);
return
a
;
}
catch
(
BadCoordException
|
CoordsBadShipException
badCoordException
)
{
badCoordException
.
printStackTrace
();
}
case
-
1
:
JOptionPane
.
showMessageDialog
(
null
,
"Merci de choisir une bonne taille de bateau, pas de diagonale, la taille doit être comprise entre 1 et 5"
);
return
null
;
default
:
JOptionPane
.
showMessageDialog
(
null
,
"la taille doit être comprise entre 1 et 5"
);
return
null
;
}
}
}
\ No newline at end of file
src/vue/FenetreConnexion.java
View file @
2c5653c1
...
...
@@ -2,13 +2,19 @@ package vue;
import
PremiereFenetre.PremiereFenetre
;
import
info1.network.Player
;
import
info1.ships.BadCoordException
;
import
info1.ships.CoordsBadShipException
;
import
info1.ships.ICoord
;
import
modele.info1.ships.Bouttons
;
import
modele.info1.ships.Coord
;
import
modele.info1.ships.CreationB
;
import
modele.info1.ships.NavyFleet
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.util.List
;
import
java.util.function.BiPredicate
;
...
...
@@ -26,6 +32,8 @@ public class FenetreConnexion extends JFrame {
private
JButton
belgique
;
private
JTextArea
textePays
;
NavyFleet
flotte
=
new
NavyFleet
();
public
FenetreConnexion
(
String
titre
){
super
(
titre
);
...
...
@@ -52,11 +60,12 @@ public class FenetreConnexion extends JFrame {
grille
.
add
(
labellettre
);
}
int
j
=
0
;
int
o
=
0
;
int
j
=
0
;
int
chiffre
=
1
;
char
lettre
=
'A'
;
final
String
[]
co
=
{
null
}
;
final
Coord
[]
cord1
=
new
Coord
[
1
];
final
String
[]
co
=
new
String
[
2
]
;
Bouttons
[]
bouttons
=
new
Bouttons
[
100
];
for
(
int
i
=
0
;
i
<
(
11
*
10
);
i
++)
{
String
[]
nombres
=
{
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
};
...
...
@@ -72,8 +81,41 @@ public class FenetreConnexion extends JFrame {
chiffre
++;
}
final
Bouttons
boutton
=
new
Bouttons
(
new
JButton
(),
lettre
+
String
.
valueOf
(
chiffre
));
bouttons
[
o
]
=
boutton
;
o
++;
boutton
.
getButton
().
setBorder
(
BorderFactory
.
createLineBorder
(
Color
.
BLACK
));
boutton
.
getButton
().
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
co
[
0
]==
null
){
co
[
0
]=
boutton
.
getString
();
}
else
{
co
[
1
]
=
boutton
.
getString
();
CreationB
c
=
new
CreationB
(
co
[
0
],
co
[
1
]);
try
{
if
(
c
.
TestCreation
()!=
null
){
if
(
flotte
.
add
(
c
.
TestCreation
())==
0
){
System
.
out
.
println
(
flotte
.
getShips
());
List
<
ICoord
>
listec
=
c
.
TestCreation
().
getCoords
();
for
(
int
i
=
0
;
i
<
100
;
i
++){
if
(
listec
.
contains
(
new
Coord
(
bouttons
[
i
].
getString
()))){
bouttons
[
i
].
getButton
().
setBackground
(
Color
.
GRAY
);
bouttons
[
i
].
getButton
().
setEnabled
(
false
);
}
}
}
else
{
JOptionPane
.
showMessageDialog
(
null
,
"Flotte déja pleine"
);
}
}
{
co
[
0
]=
null
;
}
}
catch
(
CoordsBadShipException
coordsBadShipException
)
{
coordsBadShipException
.
printStackTrace
();}
catch
(
BadCoordException
badCoordException
)
{
badCoordException
.
printStackTrace
();}
co
[
0
]=
null
;
co
[
1
]=
null
;
}
}
});
grille
.
add
(
boutton
.
getButton
());
}
lettre
++;
...
...
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