1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,201 +0,0 @@ |
1 |
-<?php |
|
2 |
- |
|
3 |
-include('backend.php'); |
|
4 |
- |
|
5 |
-include('../include/partie.php'); |
|
6 |
-include('../include/joueur.php'); |
|
7 |
-include('../include/session.php'); |
|
8 |
- |
|
9 |
- |
|
10 |
-if( !$scMoi->exist() ) |
|
11 |
- exit(); |
|
12 |
- |
|
13 |
-/* |
|
14 |
- * LANCER UNE NOUVELLE PARTIE |
|
15 |
- */ |
|
16 |
-if( isset($_GET['new']) ) { |
|
17 |
- $db->req("UPDATE parties SET statut=0 WHERE id=".$scPartie->id.";"); |
|
18 |
- $db->req("UPDATE joueurs SET statut=0 WHERE partie_id=".$scPartie->id.";"); |
|
19 |
- exit(); |
|
20 |
-} |
|
21 |
- |
|
22 |
-/* |
|
23 |
- * POSITIONNER UN MEEPLE |
|
24 |
- */ |
|
25 |
-if( isset($_GET['meeple']) ) { |
|
26 |
- if($scPartie->statut % 2 != 1 && $scPartie->statut >= 9) |
|
27 |
- exit(); |
|
28 |
- |
|
29 |
- $meepleId = ($scPartie->statut + 1) / 2; |
|
30 |
- $db->req("UPDATE joueurs SET position_meeple".$meepleId."=".(100 + intval($_GET['meeple']))." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
31 |
- $db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
32 |
- exit(); |
|
33 |
-} |
|
34 |
- |
|
35 |
-/* |
|
36 |
- * POSITIONNER UN TEMPLE |
|
37 |
- */ |
|
38 |
-if( isset($_GET['temple']) ) { |
|
39 |
- if($scPartie->statut % 2 != 0 && $scPartie->statut >= 9) |
|
40 |
- exit(); |
|
41 |
- |
|
42 |
- $templeId = $scPartie->statut / 2; |
|
43 |
- $db->req("UPDATE joueurs SET position_temple".$templeId."=".intval($_GET['temple'])." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
44 |
- $db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
45 |
- exit(); |
|
46 |
-} |
|
47 |
- |
|
48 |
-/* |
|
49 |
- * JOUE |
|
50 |
- */ |
|
51 |
-function compileDernierCoup($j, $tuile) { |
|
52 |
- global $db, $scPartie; |
|
53 |
- |
|
54 |
- $dcAction = $j->dernier_coup[0]; |
|
55 |
- $dcVal = substr($j->dernier_coup, 1); |
|
56 |
- |
|
57 |
- // Pose de la tuile sur le plateau |
|
58 |
- if($dcAction == 'c') { |
|
59 |
- $j->plateau[ $dcVal - 1 ] = $tuile; |
|
60 |
- } |
|
61 |
- // Deplacement d'un meeple |
|
62 |
- elseif($dcAction == 'm') { |
|
63 |
- $dcMeeple = $dcVal[0]; |
|
64 |
- $dcActionType = $dcVal[1]; |
|
65 |
- $dcInfo = substr($dcVal, 2); |
|
66 |
- |
|
67 |
- // Deplacement du meeple sur une case du plateau |
|
68 |
- if($dcActionType == 'c') { |
|
69 |
- $caseHasPepite = substr($j->plateau[ $dcInfo - 1 ], -1); |
|
70 |
- if($caseHasPepite == 'o' || $caseHasPepite == 'd') { |
|
71 |
- $j->plateau[ $dcInfo - 1 ] = substr( $j->plateau[ $dcInfo - 1 ], 0, -1 ); |
|
72 |
- if($caseHasPepite == 'o') $j->or++; |
|
73 |
- if($caseHasPepite == 'd') $j->diamant++; |
|
74 |
- } |
|
75 |
- $j->meeple[ $dcMeeple - 1 ] = $dcInfo; |
|
76 |
- } |
|
77 |
- // Deplacement du meeple sur un temple |
|
78 |
- elseif($dcActionType == 't') { |
|
79 |
- $templeId = 0; |
|
80 |
- for($i = 0 ; $i < count($j->temple) ; $i++) |
|
81 |
- if($j->temple[$i] == $dcInfo) |
|
82 |
- $templeId = $i; |
|
83 |
- $j->tresor[$templeId] = $scPartie->gagneTresor($templeId); |
|
84 |
- $j->meeple[ $dcMeeple - 1 ] = $dcInfo + 200; |
|
85 |
- } |
|
86 |
- } |
|
87 |
- |
|
88 |
- $db->req("UPDATE joueurs SET plateau='".$j->plateauTxt()."', tresor1='".$j->tresor[0]."', tresor2='".$j->tresor[1]."', tresor3='".$j->tresor[2]."', tresor4='".$j->tresor[3]."', pepite_diamant=".$j->diamant.", pepite_or=".$j->or.", dernier_coup='', position_meeple1=".$j->meeple[0].", position_temple1=".$j->temple[0].", position_meeple2=".$j->meeple[1].", position_temple2=".$j->temple[1].", position_meeple3=".$j->meeple[2].", position_temple3=".$j->temple[2].", position_meeple4=".$j->meeple[3].", position_temple4=".$j->temple[3]." WHERE id=".$j->id.";"); |
|
89 |
-} |
|
90 |
- |
|
91 |
-function verifFinPartie($j) { |
|
92 |
- $fin = 0; |
|
93 |
- |
|
94 |
- for($i = 0 ; $i < count($j->meeple) ; $i++) |
|
95 |
- if($j->meeple[$i] >= 200) |
|
96 |
- $fin++; |
|
97 |
- |
|
98 |
- if( $fin == count($j->meeple) ) |
|
99 |
- return true; |
|
100 |
- |
|
101 |
- return false; |
|
102 |
-} |
|
103 |
- |
|
104 |
- |
|
105 |
-if( isset($_GET['dc']) ) { |
|
106 |
- $db->req("UPDATE joueurs SET dernier_coup='".$_GET['dc']."' WHERE id=".$scMoi->id.";"); |
|
107 |
- $scMoi->dernier_coup = $_GET['dc']; |
|
108 |
- |
|
109 |
- |
|
110 |
- /* |
|
111 |
- * SI TOUT LE MONDE A DEJA JOUE |
|
112 |
- */ |
|
113 |
- $nbDejaJoue = 0; |
|
114 |
- foreach($scJoueurs as $j) { |
|
115 |
- if($j->dernier_coup != "") |
|
116 |
- $nbDejaJoue++; |
|
117 |
- } |
|
118 |
- |
|
119 |
- if($nbDejaJoue == count($scJoueurs)) { |
|
120 |
- // Extrait la 1ere tuile de la pioche |
|
121 |
- $tuile = array_shift( $scPartie->pioche ); |
|
122 |
- |
|
123 |
- compileDernierCoup($scMoi, $tuile); |
|
124 |
- foreach($scJoueurs as $j) |
|
125 |
- compileDernierCoup($j, $tuile); |
|
126 |
- |
|
127 |
- // Verification des conditions de fin de partie |
|
128 |
- $fin = false; |
|
129 |
- |
|
130 |
- if( count($scPartie->pioche) == 0 ) |
|
131 |
- $fin = true; |
|
132 |
- |
|
133 |
- if( verifFinPartie($scMoi) ) |
|
134 |
- $fin = true; |
|
135 |
- foreach($scJoueurs as $j) |
|
136 |
- if( verifFinPartie($j) ) |
|
137 |
- $fin = true; |
|
138 |
- |
|
139 |
- if($fin) |
|
140 |
- $scPartie->statut++; |
|
141 |
- |
|
142 |
- |
|
143 |
- $db->req("UPDATE parties SET statut='".$scPartie->statut."', pioche='".$scPartie->piocheTxt()."', tresor1='".$scPartie->tresor[0]."', tresor2='".$scPartie->tresor[1]."', tresor3='".$scPartie->tresor[2]."', tresor4='".$scPartie->tresor[3]."' WHERE id=".$scPartie->id.";"); |
|
144 |
- |
|
145 |
- } |
|
146 |
- |
|
147 |
- exit(); |
|
148 |
-} |
|
149 |
- |
|
150 |
- |
|
151 |
- |
|
152 |
- |
|
153 |
-/* |
|
154 |
- * ENVOI LES INFOS |
|
155 |
- */ |
|
156 |
- |
|
157 |
-// Affiche un tableau |
|
158 |
-function JsonTab($data) { |
|
159 |
- $echoreturn = '['; |
|
160 |
- for($i = 0 ; $i < count($data) ; $i++) { |
|
161 |
- if($i > 0) $echoreturn .= ", "; |
|
162 |
- $echoreturn .= '"'.$data[$i].'"'; |
|
163 |
- } |
|
164 |
- $echoreturn .= ']'; |
|
165 |
- return $echoreturn; |
|
166 |
-} |
|
167 |
- |
|
168 |
-// Affiche les infos d'un joueur |
|
169 |
-function JsonJoueur($j) { |
|
170 |
- $echoreturn = '"'.$j->id.'":{'; |
|
171 |
-// $echoreturn .= '"id":'.$j->id.', '; |
|
172 |
- $echoreturn .= '"tresor":'.JsonTab($j->tresor).', '; |
|
173 |
- $echoreturn .= '"diamant":'.$j->diamant.', '; |
|
174 |
- $echoreturn .= '"or":'.$j->or.', '; |
|
175 |
- $echoreturn .= '"dernier_coup":"'.$j->dernier_coup.'", '; |
|
176 |
- $echoreturn .= '"meeple":'.JsonTab($j->meeple).', '; |
|
177 |
- $echoreturn .= '"temple":'.JsonTab($j->temple).', '; |
|
178 |
- $echoreturn .= '"plateau":'.JsonTab($j->plateau); |
|
179 |
- $echoreturn .= '}'; |
|
180 |
- return $echoreturn; |
|
181 |
-} |
|
182 |
- |
|
183 |
- |
|
184 |
-// Debut du JSON |
|
185 |
-// * Partie |
|
186 |
-echo '{"statut":'.$scPartie->statut.', '; |
|
187 |
-echo '"pioche":"'.$scPartie->pioche[0].'", '; |
|
188 |
-echo '"nbpioche":'.(count($scPartie->pioche) - 1).', '; |
|
189 |
-echo '"tresor":'.JsonTab( $scPartie->nextTresor() ).', '; |
|
190 |
- |
|
191 |
-// * Joueurs |
|
192 |
-echo '"joueur":{'; |
|
193 |
-echo JsonJoueur( $scMoi ); |
|
194 |
-foreach($scJoueurs as $j) |
|
195 |
- echo ', '.JsonJoueur($j); |
|
196 |
-echo '}'; |
|
197 |
- |
|
198 |
-echo '}'; |
|
199 |
-// Fin du JSON |
|
200 |
- |
|
201 |
-?> |
... | ... |
@@ -78,9 +78,9 @@ function compileDernierCoup($j, $tuile) { |
78 | 78 |
elseif($dcActionType == 't') { |
79 | 79 |
$templeId = 0; |
80 | 80 |
for($i = 0 ; $i < count($j->temple) ; $i++) |
81 |
- if($t == $dcInfo) |
|
81 |
+ if($j->temple[$i] == $dcInfo) |
|
82 | 82 |
$templeId = $i; |
83 |
- $j->tresor[$i] = $scPartie->gagneTresor($i); |
|
83 |
+ $j->tresor[$templeId] = $scPartie->gagneTresor($templeId); |
|
84 | 84 |
$j->meeple[ $dcMeeple - 1 ] = $dcInfo + 200; |
85 | 85 |
} |
86 | 86 |
} |
... | ... |
@@ -111,9 +111,10 @@ if( isset($_GET['dc']) ) { |
111 | 111 |
* SI TOUT LE MONDE A DEJA JOUE |
112 | 112 |
*/ |
113 | 113 |
$nbDejaJoue = 0; |
114 |
- foreach($scJoueurs as $j) |
|
115 |
- if($scJoueurs->dernier_coup != "") |
|
114 |
+ foreach($scJoueurs as $j) { |
|
115 |
+ if($j->dernier_coup != "") |
|
116 | 116 |
$nbDejaJoue++; |
117 |
+ } |
|
117 | 118 |
|
118 | 119 |
if($nbDejaJoue == count($scJoueurs)) { |
119 | 120 |
// Extrait la 1ere tuile de la pioche |
... | ... |
@@ -23,6 +23,9 @@ if( isset($_GET['new']) ) { |
23 | 23 |
* POSITIONNER UN MEEPLE |
24 | 24 |
*/ |
25 | 25 |
if( isset($_GET['meeple']) ) { |
26 |
+ if($scPartie->statut % 2 != 1 && $scPartie->statut >= 9) |
|
27 |
+ exit(); |
|
28 |
+ |
|
26 | 29 |
$meepleId = ($scPartie->statut + 1) / 2; |
27 | 30 |
$db->req("UPDATE joueurs SET position_meeple".$meepleId."=".(100 + intval($_GET['meeple']))." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
28 | 31 |
$db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
... | ... |
@@ -33,6 +36,9 @@ if( isset($_GET['meeple']) ) { |
33 | 36 |
* POSITIONNER UN TEMPLE |
34 | 37 |
*/ |
35 | 38 |
if( isset($_GET['temple']) ) { |
39 |
+ if($scPartie->statut % 2 != 0 && $scPartie->statut >= 9) |
|
40 |
+ exit(); |
|
41 |
+ |
|
36 | 42 |
$templeId = $scPartie->statut / 2; |
37 | 43 |
$db->req("UPDATE joueurs SET position_temple".$templeId."=".intval($_GET['temple'])." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
38 | 44 |
$db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
... | ... |
@@ -160,8 +166,8 @@ function JsonTab($data) { |
160 | 166 |
|
161 | 167 |
// Affiche les infos d'un joueur |
162 | 168 |
function JsonJoueur($j) { |
163 |
- $echoreturn = '{'; |
|
164 |
- $echoreturn .= '"id":'.$j->id.', '; |
|
169 |
+ $echoreturn = '"'.$j->id.'":{'; |
|
170 |
+// $echoreturn .= '"id":'.$j->id.', '; |
|
165 | 171 |
$echoreturn .= '"tresor":'.JsonTab($j->tresor).', '; |
166 | 172 |
$echoreturn .= '"diamant":'.$j->diamant.', '; |
167 | 173 |
$echoreturn .= '"or":'.$j->or.', '; |
... | ... |
@@ -182,11 +188,11 @@ echo '"nbpioche":'.(count($scPartie->pioche) - 1).', '; |
182 | 188 |
echo '"tresor":'.JsonTab( $scPartie->nextTresor() ).', '; |
183 | 189 |
|
184 | 190 |
// * Joueurs |
185 |
-echo '"joueur":['; |
|
191 |
+echo '"joueur":{'; |
|
186 | 192 |
echo JsonJoueur( $scMoi ); |
187 | 193 |
foreach($scJoueurs as $j) |
188 | 194 |
echo ', '.JsonJoueur($j); |
189 |
-echo ']'; |
|
195 |
+echo '}'; |
|
190 | 196 |
|
191 | 197 |
echo '}'; |
192 | 198 |
// Fin du JSON |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,194 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+include('backend.php'); |
|
4 |
+ |
|
5 |
+include('../include/partie.php'); |
|
6 |
+include('../include/joueur.php'); |
|
7 |
+include('../include/session.php'); |
|
8 |
+ |
|
9 |
+ |
|
10 |
+if( !$scMoi->exist() ) |
|
11 |
+ exit(); |
|
12 |
+ |
|
13 |
+/* |
|
14 |
+ * LANCER UNE NOUVELLE PARTIE |
|
15 |
+ */ |
|
16 |
+if( isset($_GET['new']) ) { |
|
17 |
+ $db->req("UPDATE parties SET statut=0 WHERE id=".$scPartie->id.";"); |
|
18 |
+ $db->req("UPDATE joueurs SET statut=0 WHERE partie_id=".$scPartie->id.";"); |
|
19 |
+ exit(); |
|
20 |
+} |
|
21 |
+ |
|
22 |
+/* |
|
23 |
+ * POSITIONNER UN MEEPLE |
|
24 |
+ */ |
|
25 |
+if( isset($_GET['meeple']) ) { |
|
26 |
+ $meepleId = ($scPartie->statut + 1) / 2; |
|
27 |
+ $db->req("UPDATE joueurs SET position_meeple".$meepleId."=".(100 + intval($_GET['meeple']))." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
28 |
+ $db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
29 |
+ exit(); |
|
30 |
+} |
|
31 |
+ |
|
32 |
+/* |
|
33 |
+ * POSITIONNER UN TEMPLE |
|
34 |
+ */ |
|
35 |
+if( isset($_GET['temple']) ) { |
|
36 |
+ $templeId = $scPartie->statut / 2; |
|
37 |
+ $db->req("UPDATE joueurs SET position_temple".$templeId."=".intval($_GET['temple'])." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
38 |
+ $db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
39 |
+ exit(); |
|
40 |
+} |
|
41 |
+ |
|
42 |
+/* |
|
43 |
+ * JOUE |
|
44 |
+ */ |
|
45 |
+function compileDernierCoup($j, $tuile) { |
|
46 |
+ global $db, $scPartie; |
|
47 |
+ |
|
48 |
+ $dcAction = $j->dernier_coup[0]; |
|
49 |
+ $dcVal = substr($j->dernier_coup, 1); |
|
50 |
+ |
|
51 |
+ // Pose de la tuile sur le plateau |
|
52 |
+ if($dcAction == 'c') { |
|
53 |
+ $j->plateau[ $dcVal - 1 ] = $tuile; |
|
54 |
+ } |
|
55 |
+ // Deplacement d'un meeple |
|
56 |
+ elseif($dcAction == 'm') { |
|
57 |
+ $dcMeeple = $dcVal[0]; |
|
58 |
+ $dcActionType = $dcVal[1]; |
|
59 |
+ $dcInfo = substr($dcVal, 2); |
|
60 |
+ |
|
61 |
+ // Deplacement du meeple sur une case du plateau |
|
62 |
+ if($dcActionType == 'c') { |
|
63 |
+ $caseHasPepite = substr($j->plateau[ $dcInfo - 1 ], -1); |
|
64 |
+ if($caseHasPepite == 'o' || $caseHasPepite == 'd') { |
|
65 |
+ $j->plateau[ $dcInfo - 1 ] = substr( $j->plateau[ $dcInfo - 1 ], 0, -1 ); |
|
66 |
+ if($caseHasPepite == 'o') $j->or++; |
|
67 |
+ if($caseHasPepite == 'd') $j->diamant++; |
|
68 |
+ } |
|
69 |
+ $j->meeple[ $dcMeeple - 1 ] = $dcInfo; |
|
70 |
+ } |
|
71 |
+ // Deplacement du meeple sur un temple |
|
72 |
+ elseif($dcActionType == 't') { |
|
73 |
+ $templeId = 0; |
|
74 |
+ for($i = 0 ; $i < count($j->temple) ; $i++) |
|
75 |
+ if($t == $dcInfo) |
|
76 |
+ $templeId = $i; |
|
77 |
+ $j->tresor[$i] = $scPartie->gagneTresor($i); |
|
78 |
+ $j->meeple[ $dcMeeple - 1 ] = $dcInfo + 200; |
|
79 |
+ } |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ $db->req("UPDATE joueurs SET plateau='".$j->plateauTxt()."', tresor1='".$j->tresor[0]."', tresor2='".$j->tresor[1]."', tresor3='".$j->tresor[2]."', tresor4='".$j->tresor[3]."', pepite_diamant=".$j->diamant.", pepite_or=".$j->or.", dernier_coup='', position_meeple1=".$j->meeple[0].", position_temple1=".$j->temple[0].", position_meeple2=".$j->meeple[1].", position_temple2=".$j->temple[1].", position_meeple3=".$j->meeple[2].", position_temple3=".$j->temple[2].", position_meeple4=".$j->meeple[3].", position_temple4=".$j->temple[3]." WHERE id=".$j->id.";"); |
|
83 |
+} |
|
84 |
+ |
|
85 |
+function verifFinPartie($j) { |
|
86 |
+ $fin = 0; |
|
87 |
+ |
|
88 |
+ for($i = 0 ; $i < count($j->meeple) ; $i++) |
|
89 |
+ if($j->meeple[$i] >= 200) |
|
90 |
+ $fin++; |
|
91 |
+ |
|
92 |
+ if( $fin == count($j->meeple) ) |
|
93 |
+ return true; |
|
94 |
+ |
|
95 |
+ return false; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+ |
|
99 |
+if( isset($_GET['dc']) ) { |
|
100 |
+ $db->req("UPDATE joueurs SET dernier_coup='".$_GET['dc']."' WHERE id=".$scMoi->id.";"); |
|
101 |
+ $scMoi->dernier_coup = $_GET['dc']; |
|
102 |
+ |
|
103 |
+ |
|
104 |
+ /* |
|
105 |
+ * SI TOUT LE MONDE A DEJA JOUE |
|
106 |
+ */ |
|
107 |
+ $nbDejaJoue = 0; |
|
108 |
+ foreach($scJoueurs as $j) |
|
109 |
+ if($scJoueurs->dernier_coup != "") |
|
110 |
+ $nbDejaJoue++; |
|
111 |
+ |
|
112 |
+ if($nbDejaJoue == count($scJoueurs)) { |
|
113 |
+ // Extrait la 1ere tuile de la pioche |
|
114 |
+ $tuile = array_shift( $scPartie->pioche ); |
|
115 |
+ |
|
116 |
+ compileDernierCoup($scMoi, $tuile); |
|
117 |
+ foreach($scJoueurs as $j) |
|
118 |
+ compileDernierCoup($j, $tuile); |
|
119 |
+ |
|
120 |
+ // Verification des conditions de fin de partie |
|
121 |
+ $fin = false; |
|
122 |
+ |
|
123 |
+ if( count($scPartie->pioche) == 0 ) |
|
124 |
+ $fin = true; |
|
125 |
+ |
|
126 |
+ if( verifFinPartie($scMoi) ) |
|
127 |
+ $fin = true; |
|
128 |
+ foreach($scJoueurs as $j) |
|
129 |
+ if( verifFinPartie($j) ) |
|
130 |
+ $fin = true; |
|
131 |
+ |
|
132 |
+ if($fin) |
|
133 |
+ $scPartie->statut++; |
|
134 |
+ |
|
135 |
+ |
|
136 |
+ $db->req("UPDATE parties SET statut='".$scPartie->statut."', pioche='".$scPartie->piocheTxt()."', tresor1='".$scPartie->tresor[0]."', tresor2='".$scPartie->tresor[1]."', tresor3='".$scPartie->tresor[2]."', tresor4='".$scPartie->tresor[3]."' WHERE id=".$scPartie->id.";"); |
|
137 |
+ |
|
138 |
+ } |
|
139 |
+ |
|
140 |
+ exit(); |
|
141 |
+} |
|
142 |
+ |
|
143 |
+ |
|
144 |
+ |
|
145 |
+ |
|
146 |
+/* |
|
147 |
+ * ENVOI LES INFOS |
|
148 |
+ */ |
|
149 |
+ |
|
150 |
+// Affiche un tableau |
|
151 |
+function JsonTab($data) { |
|
152 |
+ $echoreturn = '['; |
|
153 |
+ for($i = 0 ; $i < count($data) ; $i++) { |
|
154 |
+ if($i > 0) $echoreturn .= ", "; |
|
155 |
+ $echoreturn .= '"'.$data[$i].'"'; |
|
156 |
+ } |
|
157 |
+ $echoreturn .= ']'; |
|
158 |
+ return $echoreturn; |
|
159 |
+} |
|
160 |
+ |
|
161 |
+// Affiche les infos d'un joueur |
|
162 |
+function JsonJoueur($j) { |
|
163 |
+ $echoreturn = '{'; |
|
164 |
+ $echoreturn .= '"id":'.$j->id.', '; |
|
165 |
+ $echoreturn .= '"tresor":'.JsonTab($j->tresor).', '; |
|
166 |
+ $echoreturn .= '"diamant":'.$j->diamant.', '; |
|
167 |
+ $echoreturn .= '"or":'.$j->or.', '; |
|
168 |
+ $echoreturn .= '"dernier_coup":"'.$j->dernier_coup.'", '; |
|
169 |
+ $echoreturn .= '"meeple":'.JsonTab($j->meeple).', '; |
|
170 |
+ $echoreturn .= '"temple":'.JsonTab($j->temple).', '; |
|
171 |
+ $echoreturn .= '"plateau":'.JsonTab($j->plateau); |
|
172 |
+ $echoreturn .= '}'; |
|
173 |
+ return $echoreturn; |
|
174 |
+} |
|
175 |
+ |
|
176 |
+ |
|
177 |
+// Debut du JSON |
|
178 |
+// * Partie |
|
179 |
+echo '{"statut":'.$scPartie->statut.', '; |
|
180 |
+echo '"pioche":"'.$scPartie->pioche[0].'", '; |
|
181 |
+echo '"nbpioche":'.(count($scPartie->pioche) - 1).', '; |
|
182 |
+echo '"tresor":'.JsonTab( $scPartie->nextTresor() ).', '; |
|
183 |
+ |
|
184 |
+// * Joueurs |
|
185 |
+echo '"joueur":['; |
|
186 |
+echo JsonJoueur( $scMoi ); |
|
187 |
+foreach($scJoueurs as $j) |
|
188 |
+ echo ', '.JsonJoueur($j); |
|
189 |
+echo ']'; |
|
190 |
+ |
|
191 |
+echo '}'; |
|
192 |
+// Fin du JSON |
|
193 |
+ |
|
194 |
+?> |