Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Johann BOURNAZEL
jeu Bridges
Commits
7ea95ae9
Commit
7ea95ae9
authored
Dec 07, 2018
by
etienne912
Browse files
ajout de la gestion des chevauchements de ponts
parent
fce1434c
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Routeur.php
View file @
7ea95ae9
...
...
@@ -25,29 +25,29 @@ class Routeur {
}
else
if
(
isset
(
$_GET
[
"deco"
]))
{
session_destroy
();
header
(
'Location: index.php'
);
}
else
if
(
isset
(
$_GET
[
"newGame"
])){
unset
(
$_SESSION
[
"villes"
]);
unset
(
$_SESSION
[
"villes_old"
]);
$_SESSION
[
"etatDernierePartie"
]
=
"abandonne"
;
header
(
'Location: index.php?statistiques'
);
}
else
if
(
isset
(
$_GET
[
"newGame"
]))
{
unset
(
$_SESSION
[
"villes"
]);
unset
(
$_SESSION
[
"villes_old"
]);
$_SESSION
[
"etatDernierePartie"
]
=
"abandonne"
;
header
(
'Location: index.php?statistiques'
);
}
if
(
isset
(
$_SESSION
[
"villes"
]))
{
$this
->
ControleurJeu
=
new
ControleurJeu
(
unserialize
(
$_SESSION
[
"villes"
]),
unserialize
(
$_SESSION
[
"villes_old"
]));
$this
->
ControleurJeu
=
new
ControleurJeu
(
unserialize
(
$_SESSION
[
"villes"
]),
unserialize
(
$_SESSION
[
"villes_old"
]));
}
else
{
$_SESSION
[
"villes"
]
=
serialize
(
new
Villes
());
$_SESSION
[
"villes_old"
]
=
serialize
(
new
Villes
());
$this
->
ControleurJeu
=
new
ControleurJeu
(
unserialize
(
$_SESSION
[
"villes"
]),
unserialize
(
$_SESSION
[
"villes_old"
]));
$this
->
ControleurJeu
=
new
ControleurJeu
(
unserialize
(
$_SESSION
[
"villes"
]),
unserialize
(
$_SESSION
[
"villes_old"
]));
}
//Si l'utilisateur s'est déjà connecté sur le site
if
(
isset
(
$_SESSION
[
'Auth'
]))
{
//Si l'utilisateur s'est déjà connecté sur le site
if
(
isset
(
$_SESSION
[
'Auth'
]))
{
if
(
isset
(
$_GET
[
'statistiques'
]))
{
if
(
isset
(
$_SESSION
[
"etatDernierePartie"
])){
$this
->
ControleurStatistiques
->
afficheStatistiques
(
$_SESSION
[
"etatDernierePartie"
]);
}
else
{
$this
->
ControleurStatistiques
->
afficheStatistiques
(
null
);
}
if
(
isset
(
$_SESSION
[
"etatDernierePartie"
]))
{
$this
->
ControleurStatistiques
->
afficheStatistiques
(
$_SESSION
[
"etatDernierePartie"
]);
}
else
{
$this
->
ControleurStatistiques
->
afficheStatistiques
(
null
);
}
}
else
if
(
isset
(
$_GET
[
"annulerCoup"
]))
{
$this
->
ControleurJeu
->
annulerCoup
();
}
else
if
(
isset
(
$_GET
[
"actX"
])
&&
isset
(
$_GET
[
"actY"
])
&&
isset
(
$_GET
[
"actLierX"
])
&&
isset
(
$_GET
[
"actLierY"
]))
{
...
...
@@ -56,28 +56,28 @@ class Routeur {
$this
->
ControleurJeu
->
jeu
(
$_GET
[
"actX"
],
$_GET
[
"actY"
],
$_GET
[
"actMauvX"
],
$_GET
[
"actMauvY"
]);
}
}
else
{
if
(
isset
(
$_POST
[
'pseudoConnexion'
])
&&
isset
(
$_POST
[
'motDePasseConnexion'
])){
if
(
$this
->
ControleurAuthentification
->
verifieIdentifiantsConnexion
(
$_POST
[
'pseudoConnexion'
],
$_POST
[
'motDePasseConnexion'
])){
header
(
'Location: index.php'
);
}
else
{
$this
->
ControleurAuthentification
->
mauvaisIdentifiantsConnexion
();
if
(
isset
(
$_POST
[
'pseudoConnexion'
])
&&
isset
(
$_POST
[
'motDePasseConnexion'
]))
{
if
(
$this
->
ControleurAuthentification
->
verifieIdentifiantsConnexion
(
$_POST
[
'pseudoConnexion'
],
$_POST
[
'motDePasseConnexion'
]))
{
header
(
'Location: index.php'
);
}
else
{
$this
->
ControleurAuthentification
->
mauvaisIdentifiantsConnexion
();
}
}
else
{
if
(
isset
(
$_POST
[
'pseudoInscription'
])
&&
isset
(
$_POST
[
'motDePasseInscription'
]))
{
if
(
$this
->
ControleurAuthentification
->
verifieIdentifiantsInscription
(
$_POST
[
'pseudoInscription'
],
$_POST
[
'motDePasseInscription'
])
==
true
)
{
header
(
'Location: index.php'
);
}
else
{
$this
->
ControleurAuthentification
->
mauvaisIdentifiantsInscription
();
}
}
else
{
if
(
!
isset
(
$_GET
[
'inscription'
]))
{
$this
->
ControleurAuthentification
->
demandeAuthentification
();
}
else
{
$this
->
ControleurAuthentification
->
demandeInscription
();
}
}
}
else
{
if
(
isset
(
$_POST
[
'pseudoInscription'
])
&&
isset
(
$_POST
[
'motDePasseInscription'
])){
if
(
$this
->
ControleurAuthentification
->
verifieIdentifiantsInscription
(
$_POST
[
'pseudoInscription'
],
$_POST
[
'motDePasseInscription'
])
==
true
){
header
(
'Location: index.php'
);
}
else
{
$this
->
ControleurAuthentification
->
mauvaisIdentifiantsInscription
();
}
}
else
{
if
(
!
isset
(
$_GET
[
'inscription'
])){
$this
->
ControleurAuthentification
->
demandeAuthentification
();
}
else
{
$this
->
ControleurAuthentification
->
demandeInscription
();
}
}
}
}
}
}
}
...
...
src/config.php
View file @
7ea95ae9
...
...
@@ -7,8 +7,8 @@ define("PATH_MODELES", ROOT . "/modeles");
define
(
"PATH_VUES"
,
ROOT
.
"/vues"
);
define
(
"HOST"
,
"localhost"
);
define
(
"BD"
,
"
bridge
s"
);
define
(
"LOGIN"
,
"
admin
"
);
define
(
"PASSWORD"
,
"
J()
{
-
}
a
nn"
);
define
(
"BD"
,
"
cour
s"
);
define
(
"LOGIN"
,
"
etienne
"
);
define
(
"PASSWORD"
,
"
etie
nn
e
"
);
?>
src/modeles/Villes.php
View file @
7ea95ae9
<?php
// cette classe ne doit pas être modifiée
//require "Ville.php";
class
Villes
{
...
...
@@ -28,6 +27,19 @@ class Villes {
return
$this
->
villes
[
$i
][
$j
];
}
function
getnbVilles
()
{
$nb
=
0
;
for
(
$i
=
0
;
$i
<=
6
;
++
$i
)
{
for
(
$j
=
0
;
$j
<=
6
;
++
$j
)
{
if
(
isset
(
$this
->
villes
[
$i
][
$j
]))
{
$nb
++
;
}
}
}
return
$nb
;
}
function
getVilleId
(
$id
)
{
foreach
(
$this
->
villes
as
$ligne
)
{
foreach
(
$ligne
as
$ville
)
{
...
...
@@ -110,6 +122,15 @@ class Villes {
return
$this
->
villesLiees
;
}
function
estLiee
(
$vilAX
,
$vilAY
,
$vilBX
,
$vilBY
)
{
$villeA
=
$this
->
getVille
(
$vilAX
,
$vilAY
);
$villeB
=
$this
->
getVille
(
$vilBX
,
$vilBY
);
$villeAId
=
$villeA
->
getId
();
$villeBId
=
$villeB
->
getId
();
return
$this
->
villesLiees
[
$villeAId
][
$villeBId
]
!=
0
;
}
function
lierVilles
(
$vilAX
,
$vilAY
,
$vilBX
,
$vilBY
)
{
$villeA
=
$this
->
getVille
(
$vilAX
,
$vilAY
);
$villeB
=
$this
->
getVille
(
$vilBX
,
$vilBY
);
...
...
src/vues/VueJeu.php
View file @
7ea95ae9
...
...
@@ -40,7 +40,8 @@ class VueJeu {
<a
href=
'index.php?annulerCoup'
class=
'link-button mg-top-10'
><img
src=
'vues/css/tick.png'
alt=
'BackImage'
class=
'icon'
>
Vérifier
</a>
<a
href=
'index.php?newGame'
class=
'link-button mg-top-10'
><img
src=
'vues/css/restart.png'
alt=
'BackImage'
class=
'icon'
>
Relancer une nouvelle partie
</a>
class=
'icon'
>
Relancer une nouvelle
partie
</a>
</div>
<br>
...
...
@@ -59,43 +60,23 @@ class VueJeu {
unset
(
$_SESSION
[
"villes"
]);
unset
(
$_SESSION
[
"villes_old"
]);
}
else
if
(
$villes
->
estPerdu
())
{
echo
"<h1>La partie est perdu !</h1><br>"
;
echo
"<a href='index.php?replay'> Rejouer</a>"
;
$_SESSION
[
'etatDernierePartie'
]
=
"perdu"
;
header
(
'Location: index.php?statistiques'
);
unset
(
$_SESSION
[
"villes"
]);
unset
(
$_SESSION
[
"villes_old"
]);
}
else
{
// si mon jeu n'est pas fini
for
(
$i
=
0
;
$i
<=
6
;
++
$i
)
{
// pour chage ligne de ma matrice villes
for
(
$j
=
0
;
$j
<=
6
;
++
$j
)
{
// pour chaque colonne de ma matrice villes
if
(
$villes
->
existe
(
$i
,
$j
))
{
if
(
$actX
!=
-
1
&&
$actY
!=
-
1
)
{
// s'il y à une ville de selectionne
if
(
$i
==
$actX
&&
$j
==
$actY
)
{
$plateau
[
$i
][
$j
]
=
"<td class='active'><a href='index.php'>"
.
$villes
->
getVille
(
$i
,
$j
)
->
getNombrePontsMax
()
.
"</a></td>"
;
}
else
if
(
$i
==
$actX
||
$j
==
$actY
)
{
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?&actX=
$actX
&actY=
$actY
&actLierX=
$i
&actLierY=
$j
'>"
.
$villes
->
getVille
(
$i
,
$j
)
->
getNombrePontsMax
()
.
"</a> </td>"
;
}
else
{
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?actMauvX=
$i
&actMauvY=
$j
'>"
.
$villes
->
getVille
(
$i
,
$j
)
->
getNombrePontsMax
()
.
"</a> </td>"
;
}
}
else
{
if
(
$i
==
$actMauvX
&&
$j
==
$actMauvY
)
$plateau
[
$i
][
$j
]
=
"<td class='activeMauvais'>"
;
else
$plateau
[
$i
][
$j
]
=
"<td class='show'>"
;
$plateau
[
$i
][
$j
]
=
$plateau
[
$i
][
$j
]
.
"<a href='index.php?actX=
$i
&actY=
$j
'>"
.
$villes
->
getVille
(
$i
,
$j
)
->
getNombrePontsMax
()
.
"</a> </td>"
;
}
}
else
{
$plateau
[
$i
][
$j
]
=
"<td> </td>"
;
}
}
}
$pontSimpleHorizontal
=
"<td class='simplehorizontal'></td>"
;
$pontDoubleHorizontal
=
"<td class='doublehorizontal'></td>"
;
$pontSimpleVertical
=
"<td class='simplevertical'></td>"
;
$pontDoubleVertical
=
"<td class='doublevertical'></td>"
;
$ponts
=
$villes
->
getVillesLiees
();
for
(
$i
=
0
;
$i
<=
6
;
++
$i
)
{
for
(
$j
=
$i
;
$j
<=
6
;
++
$j
)
{
$nbVilles
=
$villes
->
getnbVilles
();
for
(
$i
=
0
;
$i
<
$nbVilles
;
++
$i
)
{
for
(
$j
=
$i
;
$j
<
$nbVilles
;
++
$j
)
{
if
(
isset
(
$ponts
[
$i
][
$j
])
&&
$ponts
[
$i
][
$j
]
!=
0
)
{
$vAX
=
$villes
->
getX
(
$i
);
$vAY
=
$villes
->
getY
(
$i
);
...
...
@@ -105,42 +86,94 @@ class VueJeu {
if
(
$vAX
==
$vBX
)
{
$departPont
=
min
(
$vAY
,
$vBY
)
+
1
;
$finPont
=
max
(
$vAY
,
$vBY
)
-
1
;
$tempate
=
$ponts
[
$i
][
$j
]
==
1
?
$pontSimpleHorizontal
:
$pontDoubleHorizontal
;
for
(
$x
=
$departPont
;
$x
<=
$finPont
;
++
$x
)
{
$plateau
[
$vAX
][
$x
]
=
$tempate
;
}
}
else
{
$departPont
=
min
(
$vAX
,
$vBX
)
+
1
;
$finPont
=
max
(
$vAX
,
$vBX
)
-
1
;
$tempate
=
$ponts
[
$i
][
$j
]
==
1
?
$pontSimpleVertical
:
$pontDoubleVertical
;
for
(
$x
=
$departPont
;
$x
<=
$finPont
;
++
$x
)
{
$plateau
[
$x
][
$vAY
]
=
$tempate
;
}
}
}
}
}
for
(
$i
=
0
;
$i
<=
6
;
++
$i
)
{
// pour chage ligne de ma matrice villes
for
(
$j
=
0
;
$j
<=
6
;
++
$j
)
{
// pour chaque colonne de ma matrice villes
if
(
$villes
->
existe
(
$i
,
$j
))
{
$nbPontsMax
=
$villes
->
getVille
(
$i
,
$j
)
->
getNombrePontsMax
();
if
(
$actX
!=
-
1
&&
$actY
!=
-
1
)
{
// s'il y à une ville de selectionne
if
(
$i
==
$actX
&&
$j
==
$actY
)
{
$plateau
[
$i
][
$j
]
=
"<td class='active'><a href='index.php'>
$nbPontsMax
</a></td>"
;
}
else
if
(
$i
==
$actX
)
{
$vide
=
true
;
if
(
!
$villes
->
estLiee
(
$i
,
$j
,
$actX
,
$actY
))
{
$departPont
=
min
(
$j
,
$actY
)
+
1
;
$finPont
=
max
(
$j
,
$actY
)
-
1
;
for
(
$x
=
$departPont
;
$x
<=
$finPont
;
++
$x
)
{
if
(
isset
(
$plateau
[
$actX
][
$x
])
||
$villes
->
existe
(
$actX
,
$x
))
{
$vide
=
false
;
break
;
}
}
}
if
(
$vide
)
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?testX&actX=
$actX
&actY=
$actY
&actLierX=
$i
&actLierY=
$j
'>
$nbPontsMax
</a> </td>"
;
else
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?nontestX&actMauvX=
$i
&actMauvY=
$j
'>
$nbPontsMax
</a> </td>"
;
}
else
if
(
$j
==
$actY
)
{
$vide
=
true
;
if
(
!
$villes
->
estLiee
(
$i
,
$j
,
$actX
,
$actY
))
{
$departPont
=
min
(
$i
,
$actX
)
+
1
;
$finPont
=
max
(
$i
,
$actX
)
-
1
;
for
(
$x
=
$departPont
;
$x
<=
$finPont
;
++
$x
)
{
if
(
isset
(
$plateau
[
$x
][
$actY
])
||
$villes
->
existe
(
$x
,
$actY
))
{
$vide
=
false
;
break
;
}
}
}
if
(
$vide
)
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?testY&actX=
$actX
&actY=
$actY
&actLierX=
$i
&actLierY=
$j
'>
$nbPontsMax
</a> </td>"
;
else
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?nontestY&actMauvX=
$i
&actMauvY=
$j
'>
$nbPontsMax
</a> </td>"
;
}
else
{
$plateau
[
$i
][
$j
]
=
"<td class='show'><a href='index.php?actMauvX=
$i
&actMauvY=
$j
'>
$nbPontsMax
</a> </td>"
;
}
}
else
{
if
(
$i
==
$actMauvX
&&
$j
==
$actMauvY
)
$plateau
[
$i
][
$j
]
=
"<td class='activeMauvais'>"
;
else
$plateau
[
$i
][
$j
]
=
"<td class='show'>"
;
$plateau
[
$i
][
$j
]
=
$plateau
[
$i
][
$j
]
.
"<a href='index.php?actX=
$i
&actY=
$j
'>
$nbPontsMax
</a> </td>"
;
}
}
}
}
foreach
(
$plateau
as
$ligne
)
{
for
(
$i
=
0
;
$i
<=
6
;
++
$i
)
{
// pour chage ligne de ma matrice villes
echo
"<tr>"
;
for
each
(
$ligne
as
$cellule
)
{
echo
$cellule
;
for
(
$j
=
0
;
$j
<=
6
;
++
$j
)
{
// pour chaque colonne de ma matrice villes
echo
isset
(
$plateau
[
$i
][
$j
])
?
$plateau
[
$i
][
$j
]
:
"<td> </td>"
;
}
echo
"</tr>"
;
}
}
?>
</table>
...
...
src/vues/css/master.css
View file @
7ea95ae9
...
...
@@ -199,7 +199,12 @@ table {
border-spacing
:
0
;
}
td
{
td
{
width
:
auto
;
height
:
50px
;
}
div
.jeu
>
table
>
tbody
>
tr
>
td
{
width
:
71px
;
height
:
71px
;
display
:
inline-flex
;
...
...
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