Nantes Université
Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
projetS2-2021-08-AL
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Service d'assistance
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Jacques ZHENG
projetS2-2021-08-AL
Validations
ce167e21
Valider
ce167e21
rédigé
il y a 3 ans
par
Jacques ZHENG
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
mise a jour bateau coulé dans ModeleController
parent
4ec56ed7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/info1/controller/ModeleController.java
+154
-0
154 ajouts, 0 suppression
src/info1/controller/ModeleController.java
avec
154 ajouts
et
0 suppression
src/info1/controller/ModeleController.java
+
154
−
0
Voir le fichier @
ce167e21
...
...
@@ -6,6 +6,7 @@ import info1.network.Game;
import
info1.network.Network
;
import
info1.network.Player
;
import
info1.ships.BadCoordException
;
import
info1.ships.Coord
;
import
info1.ships.ICoord
;
import
info1.ships.INavyFleet
;
import
info1.view.Accueil
;
...
...
@@ -142,6 +143,159 @@ public class ModeleController implements MouseMotionListener, MouseListener, Act
}
else
if
(
res
==
10
)
{
//Pour mettre tout le bateau en rouge car coulé//
plateau
.
setBateauCoule
(
coord
);
ICoord
temp
=
coord
;
List
<
ICoord
>
coordContiguAtemp
=
new
ArrayList
<>();
coordContiguAtemp
.
add
(
temp
);
//Pour l'horizontale droit
int
x
=
temp
.
getX
()+
1
;
if
(
x
<=
10
)
{
ICoord
tmp
=
new
Coord
(
x
,
temp
.
getY
());
while
(
x
<=
10
&&
coord_touchees
.
contains
(
tmp
))
{
if
(
x
==
10
)
{
coordContiguAtemp
.
add
(
tmp
);
x
++;
}
else
{
coordContiguAtemp
.
add
(
tmp
);
x
++;
tmp
=
new
Coord
(
x
,
temp
.
getY
());
}
}
}
//Horizontale gauche
x
=
temp
.
getX
()-
1
;
if
(
x
>=
1
)
{
ICoord
tmp
=
new
Coord
(
x
,
temp
.
getY
());
while
(
x
>=
1
&&
coord_touchees
.
contains
(
tmp
))
{
if
(
x
==
1
)
{
coordContiguAtemp
.
add
(
tmp
);
x
--;
}
else
{
coordContiguAtemp
.
add
(
tmp
);
x
--;
tmp
=
new
Coord
(
x
,
temp
.
getY
());
}
}
}
//Verticale bas
int
y
=
temp
.
getY
()+
1
;
if
(
y
<=
10
)
{
ICoord
tmp
=
new
Coord
(
temp
.
getX
(),
y
);
while
(
y
<=
10
&&
coord_touchees
.
contains
(
tmp
))
{
if
(
y
==
10
)
{
coordContiguAtemp
.
add
(
tmp
);
y
++;
}
else
{
coordContiguAtemp
.
add
(
tmp
);
y
++;
tmp
=
new
Coord
(
temp
.
getX
(),
y
);
}
}
}
//Verticale Haut
y
=
temp
.
getY
()-
1
;
if
(
y
>=
1
)
{
ICoord
tmp
=
new
Coord
(
temp
.
getX
(),
y
);
while
(
y
>=
1
&&
coord_touchees
.
contains
(
tmp
))
{
if
(
y
==
1
)
{
coordContiguAtemp
.
add
(
tmp
);
y
--;
}
else
{
coordContiguAtemp
.
add
(
tmp
);
y
--;
tmp
=
new
Coord
(
temp
.
getX
(),
y
);
}
}
}
//Pour L'horizontale gauche
/*
x = temp.getX();
tmp = new Coord(temp.getX()-1,temp.getY());
while(x>=0 && coord_touchees.contains(tmp)){
coordContiguAtemp.add(temp);
x--;
tmp = new Coord(tmp.getX()-1, temp.getY());
}
*/
for
(
ICoord
c
:
coordContiguAtemp
){
plateau
.
setBateauCoule
(
c
);
}
/*
for(ICoord c: coord_touchees){
boolean tempChanger = false;
//Verticale haut
if(c.getY()==temp.getY() && temp.getX()+1==c.getX()) {
plateau.setBateauCoule(c);
tempChanger = true;
temp = c;
System.out.println('X');
}
//Horizontale droit
if(c.getX()==temp.getX() && (temp.getY()+1)==c.getY() && !tempChanger) {
plateau.setBateauCoule(c);
temp = c;
System.out.println('Y');
}
}
temp=coord;
for(ICoord c: coord_touchees){
boolean tempChanger = false;
if(c.getY()==temp.getY() && temp.getX()-1==c.getX()) {
plateau.setBateauCoule(c);
temp=c;
tempChanger = true;
}if(c.getX()==temp.getX() && ((temp.getY()-1))==c.getY() && !tempChanger) {
plateau.setBateauCoule(c);
temp=c;
}
}
*/
/*char axe = '0';
List<ICoord> axeX = new ArrayList<>();
List<ICoord> axeY = new ArrayList<>();
for(ICoord c: coord_touchees){
if(c.getY()==coord.getY()){
axeY.add(c);
if (coord.getX()+1==c.getX() || coord.getX()-1==c.getX()) {
plateau.setBateauCoule(c);
axe = 'Y';
}
}if(c.getX()==coord.getX()){
axeX.add(c);
if((coord.getY()+10)%10==c.getY() || (((coord.getY()-10)%10)+10)==c.getY()) {
plateau.setBateauCoule(c);
axe = 'X';
}
}
}*/
/*if(axe=='Y'){
axeY.sort(Comparator.comparingInt(ICoord::getX));
for(ICoord c: axeY){
if()
}
}if(axe=='X'){
axeX.sort(new Comparator<ICoord>() {
@Override
public int compare(ICoord o1, ICoord o2) {
return o1.getY();
}
});
for(ICoord c: axeY){
}
}*/
plateau
.
modifierAffichage
(
"C'est coulé !"
);
plateau
.
setScore
(
score
++);
}
else
if
(
res
==
100
){
...
...
This diff is collapsed.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter