Browse code

Affichage static de l'ecran de jeu

schardon authored on 24/04/2020 13:42:47
Showing 9 changed files
... ...
@@ -4,13 +4,11 @@ function isAjax() {
4 4
   return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
5 5
 }
6 6
 
7
-
8 7
 if( !isAjax() ) {
9 8
   header('Location: ../index.php');
10 9
   exit();
11 10
 }
12 11
 
13
-
14 12
 $racine = '..';
15 13
 include('../include/db.php');
16 14
 
... ...
@@ -42,14 +42,10 @@ if( isset($_GET['go']) && $scMoi->exist() ) {
42 42
 if( isset($_POST['ajouter']) ) {
43 43
   $ajouter = htmlentities($_POST['ajouter'], ENT_QUOTES);
44 44
 
45
-  if( $scPartie->exist() ) {
46
-    $db->req("INSERT INTO joueurs VALUES (NULL, '".$ajouter."', ".$scPartie->id.", '', 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 0);");
47
-    echo $db->reqFirst("SELECT id FROM joueurs WHERE partie_id=".$scPartie->id." ORDER BY id DESC LIMIT 1;")['id'];
48
-  }
49
-  else {
50
-    $db->req("INSERT INTO parties VALUES (NULL, '".$ajouter."', '', 0, '', '', '', '', 0);");
51
-    echo $db->reqFirst("SELECT id FROM parties ORDER BY id DESC LIMIT 1;")['id'];
52
-  }
45
+  if( $scPartie->exist() )
46
+    echo $scMoi->creer($ajouter, $scPartie->id);
47
+  else
48
+    echo $scPartie->creer($ajouter);
53 49
 
54 50
   exit();
55 51
 }
56 52
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
+?>
... ...
@@ -0,0 +1,240 @@
1
+html,
2
+body {
3
+  margin: 0;
4
+  padding: 0;
5
+  font-family: calibri;
6
+}
7
+
8
+
9
+.jeu-btn {
10
+  border-radius: 5px;
11
+  padding: 5px 10px;
12
+  color: white;
13
+  cursor: pointer;
14
+  text-align: center;
15
+}
16
+
17
+.clickable {
18
+  cursor: pointer;
19
+}
20
+
21
+
22
+/*
23
+ * CONF GLOBAL DES PLATEAUX
24
+ */
25
+table,
26
+table tr,
27
+table tr td {
28
+  margin: 0;
29
+  padding: 0;
30
+  border-spacing: 0;
31
+  text-align: center;
32
+}
33
+
34
+table.plateau tr td {
35
+  position: relative;
36
+}
37
+
38
+table.plateau tr td img {
39
+  position: absolute;
40
+  top: 0;
41
+  left: 0;
42
+}
43
+
44
+.nbr-infos {
45
+  position: absolute;
46
+  top: 0;
47
+  left: 0;
48
+  width: 100%;
49
+  text-align: center;
50
+  font-weight: bold;
51
+  text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
52
+}
53
+
54
+.nbr-diamant {
55
+}
56
+
57
+.nbr-or {
58
+}
59
+
60
+.nbr-temple1 {
61
+  color: #55a;
62
+}
63
+.nbr-temple2 {
64
+  color: #882;
65
+}
66
+.nbr-temple3 {
67
+  color: #a22;
68
+}
69
+.nbr-temple4 {
70
+  color: #a5a;
71
+}
72
+
73
+.calcul-total {
74
+  font-weight: bold;
75
+}
76
+
77
+
78
+/*
79
+ * ZONE DES AUTRES JOUEURS
80
+ */
81
+
82
+.zone-autres {
83
+  width: 100%;
84
+  margin: 10px 0;
85
+  text-align: center;
86
+}
87
+
88
+.zone-autres-plateau {
89
+  display: inline-block;
90
+  border: 2px solid black;
91
+  margin: 0px auto;
92
+  width: 243px; /* 27 x 9 */
93
+}
94
+
95
+.zone-autres-plateau table.plateau {
96
+}
97
+
98
+.zone-autres-plateau table.plateau tr td {
99
+  width: 27px;
100
+  height: 27px;
101
+}
102
+
103
+.zone-autres-plateau table.plateau tr td img {
104
+  width: 27px;
105
+}
106
+
107
+.plateau-nom {
108
+  text-align: center;
109
+}
110
+
111
+
112
+/*
113
+ * MA ZONE D'AFFICHAGE
114
+ */
115
+.zone-moi {
116
+  margin: 10px 0;
117
+  width: 100%;
118
+  text-align: center;
119
+}
120
+
121
+.zone-moi table tr td {
122
+  width: 60px;
123
+  height: 60px;
124
+}
125
+
126
+.zone-moi table tr td img {
127
+  width: 60px;
128
+}
129
+
130
+/*
131
+ * MA ZONE DE TOUTES LES INFOS
132
+ */
133
+.zone-moi-infos {
134
+  display: inline-block;
135
+  border: 3px solid black;
136
+  margin: 0px 10px 0px auto;
137
+  width: 60px;
138
+}
139
+
140
+.zone-moi-infos table {
141
+}
142
+
143
+.zone-moi-infos table tr td {
144
+  position: relative;
145
+}
146
+
147
+.zone-moi-infos-tuile-jeter {
148
+  position: absolute;
149
+  top: 10px;
150
+  left: 0;
151
+  padding: 5px 0;
152
+  width: 100%;
153
+  color: #fff;
154
+  font-weight: bold;
155
+  text-align: center;
156
+  border: 1px solid black;
157
+  background-color: #0008;
158
+  display: none;
159
+}
160
+
161
+.zone-moi-infos-temple1 {
162
+}
163
+.zone-moi-infos-temple2 {
164
+}
165
+.zone-moi-infos-temple3 {
166
+}
167
+.zone-moi-infos-temple4 {
168
+}
169
+
170
+/*
171
+ * MON PLATEAU
172
+ */
173
+.zone-moi-plateau {
174
+  display: inline-block;
175
+  border: 3px solid black;
176
+  margin: 0px 10px 0px auto;
177
+  width: 540px; /* 60 x 9 */
178
+}
179
+
180
+.zone-moi-plateau table.plateau {
181
+}
182
+
183
+.zone-moi-plateau .nbr-infos,
184
+.zone-moi-plateau .calcul-total {
185
+  font-size: 200%;
186
+  margin-top: 5px;
187
+}
188
+
189
+
190
+/*
191
+ * BAS DE L'ECRAN
192
+ */
193
+.bas-btn {
194
+  margin: 10px auto;
195
+}
196
+
197
+.bas-btn-terminer {
198
+  background-color: #49D;
199
+  border: 1px solid #27E;
200
+  width: 150px;
201
+  margin: 0 auto;
202
+}
203
+
204
+/*
205
+ * FIN DE PARTIE
206
+ */
207
+.finpartie {
208
+  display: none;
209
+  position: absolute;
210
+  left: 0;
211
+  top: 50%;
212
+  width: 20%;
213
+  border-radius: 10px;
214
+  margin: 20px;
215
+  text-align: center;
216
+  background-color: #AE8;
217
+  border: 3px solid #7B5;
218
+  box-shadow: 0 0 0 10px #fff;
219
+}
220
+
221
+.finpartie-titre {
222
+  text-align: center;
223
+  width: 80%;
224
+  margin: auto;
225
+  padding: 15px;
226
+  font-size: 30px;
227
+}
228
+
229
+.finpartie-info {
230
+}
231
+
232
+.finpartie-btn {
233
+  width: 150px;
234
+  margin: 10px auto;
235
+  background-color: #49D;
236
+  border: 1px solid #27E;
237
+}
238
+
239
+
240
+
... ...
@@ -28,6 +28,13 @@ class JoueurInfos {
28 28
     return $this->_exist;
29 29
   }
30 30
 
31
+  public function creer($nom, $partie_id) {
32
+    global $db;
33
+
34
+    $db->req("INSERT INTO joueurs VALUES (NULL, '".$nom."', ".$partie_id.", '', 0, 0, 0, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 0, 0, 0);");
35
+    return $db->reqFirst("SELECT id FROM joueurs WHERE partie_id=".$partie_id." ORDER BY id DESC LIMIT 1;")['id'];
36
+  }
37
+
31 38
   public function refresh() {
32 39
     global $db;
33 40
 
... ...
@@ -46,9 +53,9 @@ class JoueurInfos {
46 53
     $this->dernier_coup = $req['dernier_coup'];
47 54
 
48 55
     for($i = 0 ; $i < 4 ; $i++) {
49
-      $this->temple[$i] = $req['position_temple'.$i];
50
-      $this->meeple[$i] = $req['position_meeple'.$i];
51
-      $this->tresor[$i] = $req['tresor'.$i];
56
+      $this->temple[$i] = $req['position_temple'.($i + 1)];
57
+      $this->meeple[$i] = $req['position_meeple'.($i + 1)];
58
+      $this->tresor[$i] = $req['tresor'.($i + 1)];
52 59
     }
53 60
 
54 61
     $this->plateau = explode(',', $req['plateau']);
... ...
@@ -11,6 +11,8 @@ class PartieInfos {
11 11
   public $nbjoueurs;
12 12
   public $joueurs;
13 13
 
14
+  private $_tresorDejaPris = [0, 0, 0, 0];
15
+
14 16
   private $_exist;
15 17
 
16 18
   public function __construct() {
... ...
@@ -22,6 +24,30 @@ class PartieInfos {
22 24
     $this->refresh();
23 25
   }
24 26
 
27
+  public function creer($nom) {
28
+    global $db;
29
+
30
+    $db->req("INSERT INTO parties VALUES (NULL, '".$nom."', '', 0, '', '', '', '', 0);");
31
+    return $db->reqFirst("SELECT id FROM parties ORDER BY id DESC LIMIT 1;")['id'];
32
+  }
33
+
34
+  public function nextTresor() {
35
+    $nextTresor = [];
36
+    for($i = 0 ; $i < count($this->tresor) ; $i++)
37
+      $nextTresor[$i] = $this->tresor[$i][0];
38
+    return $nextTresor;
39
+  }
40
+
41
+  public function gagneTresor($n) {
42
+    $tresor = $this->tresor[$n][0];
43
+    $this->tresor[$n] = substr($this->tresor[$n], 1);
44
+    if($this->tresorDejaPris[$n] > 0)
45
+      $tresor = $this->_tresorDejaPris[$n];
46
+    else
47
+      $this->_tresorDejaPris[$n] = $tresor;
48
+    return $tresor;
49
+  }
50
+
25 51
   public function exist() {
26 52
     return $this->_exist;
27 53
   }
... ...
@@ -41,10 +67,10 @@ class PartieInfos {
41 67
     $this->wait = $req['wait'];
42 68
 
43 69
     for($i = 0 ; $i < 4 ; $i++) {
44
-      $this->tresor[$i] = $req['tresor'.$i];
70
+      $this->tresor[$i] = $req['tresor'.($i + 1)];
45 71
     }
46 72
 
47
-    $this->pioche = $req['pioche'];
73
+    $this->pioche = explode(',', $req['pioche']);
48 74
 
49 75
     $this->joueurs = [];
50 76
     $req = $db->req("SELECT id FROM joueurs WHERE partie_id=".$this->id." AND statut>0;");
... ...
@@ -77,7 +103,15 @@ class PartieInfos {
77 103
                       '4d', '4', '5', '5', '6', '6', '7', '7',            // T
78 104
                       '8d', '8d', '9d', '9', '10d', '10', '11d', '11' ];  // L
79 105
 
80
-    shuffle($pioche);
106
+    shuffle($this->pioche);
107
+
108
+    $piocheTxt = '';
109
+    $first = true;
110
+    foreach($this->pioche as $p) {
111
+      if($first) $first = false;
112
+      else $piocheTxt .= ',';
113
+      $piocheTxt .= $p;
114
+    }
81 115
 
82 116
     if($this->nbjoueurs == 2) $tresors = '53';
83 117
     if($this->nbjoueurs == 3) $tresors = '532';
... ...
@@ -92,12 +126,10 @@ class PartieInfos {
92 126
     if($this->nbjoueurs >= 12) $tresors = '555444333222';
93 127
 
94 128
 
95
-    for($i = 0 ; $i < $ccNbJoueurs ; $i++) {
96
-      $req = $db->req("UPDATE joueurs SET plateau=',,,,,,,,,,,,,,,,,,,,,,,,,,,,,', tresor1='0', tresor2='0', tresor3='0', tresor4='0', pepite_diamant='0', pepite_or='0', dernier_coup='', position_meeple1=0, position_temple1=0, position_meeple2=0, position_temple2=0, position_meeple3=0, position_temple3=0, position_meeple4=0, position_temple4=0  WHERE partie_id=".$this->id." AND statut>0;");
97
-      if(!$req) return false;
98
-    }
129
+    $req = $db->req("UPDATE joueurs SET plateau=',,,,,,,,,,,,,,,,,,,,,,,,,,,,,', tresor1='0', tresor2='0', tresor3='0', tresor4='0', pepite_diamant='0', pepite_or='0', dernier_coup='', position_meeple1=0, position_temple1=0, position_meeple2=0, position_temple2=0, position_meeple3=0, position_temple3=0, position_meeple4=0, position_temple4=0 WHERE partie_id=".$this->id." AND statut>0;");
130
+    if(!$req) return false;
99 131
  
100
-    $req = $db->req("UPDATE parties SET pioche='".$this->pioche."', statut=1, tresor1=".$tresors.", tresor2=".$tresors.", tresor3=".$tresors.", tresor4=".$tresors.", wait=0 WHERE id=".$this->id.";");
132
+    $req = $db->req("UPDATE parties SET pioche='".$piocheTxt."', statut=1, tresor1=".$tresors.", tresor2=".$tresors.", tresor3=".$tresors.", tresor4=".$tresors.", wait=0 WHERE id=".$this->id.";");
101 133
     if(!$req) return false;
102 134
 
103 135
     return true;
... ...
@@ -16,4 +16,16 @@ if( !$scPartie->exist() && isset($_GET['p']) ) {
16 16
   $scPartie->init( intval($_GET['p']) );
17 17
 }
18 18
 
19
+
20
+if( $scPartie->exist() ) {
21
+  foreach($scPartie->joueurs as $j) {
22
+    if($j != $scMoi->id) {
23
+      $scJoueurs[] = new JoueurInfos();
24
+      $scJoueurs[ count($scJoueurs) - 1 ]->init($j);
25
+    }
26
+  }
27
+}
28
+
29
+
30
+
19 31
 ?>
... ...
@@ -15,14 +15,80 @@ if( !$scPartie->exist() || $scPartie->statut == 0 ) {
15 15
 
16 16
 
17 17
 
18
+function affichePlateauCase($l, $c, $j) {
19
+  echo '<td';
20
+    if( (($l == 0 || $l == 6) && ($c > 0 && $c < 7)) || ($l > 0 && $l < 6) ) {
21
+      echo ' id="PlateauCase_User'.$j->id;
22
+
23
+      if($l == 0) {
24
+        //if($c > 0 && $c < 7)
25
+        echo '_Temple'.$c;
26
+      }
27
+      elseif($l == 6) {
28
+        //if($c > 0 && $c < 7)
29
+        echo '_Meeple'.($c + 5);
30
+      }
31
+      else {
32
+        if($c == 0) echo '_Meeple'.$l;
33
+        elseif($c == 7) echo '_Temple'.($l + 6);
34
+        else echo '_Case'.(($l - 1) * 6 + $c);
35
+      }
36
+
37
+      echo '"';
38
+    }
39
+  echo '>';
40
+
41
+  echo '<img src="src/plateau_';
42
+    if($l == 0) {
43
+      if($c == 0) echo 'haut-gauche';
44
+      elseif($c == 1) echo 'haut-presquegauche';
45
+      elseif($c == 7) echo 'haut-droite';
46
+      else echo 'haut';
47
+    }
48
+    elseif($l == 6) {
49
+      if($c == 0) echo 'bas-gauche';
50
+      elseif($c == 7) echo 'bas-droite';
51
+      else echo 'bas';
52
+    }
53
+    else {
54
+      if($c == 0) echo 'gauche';
55
+      elseif($c == 7) {
56
+        if($l == 5) echo 'presquebas-droite';
57
+        else echo 'droite';
58
+      }
59
+      else echo 'case';
60
+    }
61
+  echo '.png" />';
62
+
63
+  echo '</td>';
64
+}
65
+
66
+
67
+
68
+function affichePlateauJoueur($j) {
69
+  global $scMoi;
70
+
71
+  echo '<table class="plateau">';
18 72
 
73
+  if($j->id != $scMoi->id)
74
+    echo '<tr><td colspan=8 class="plateau-nom">'.$j->nom.'</td><td id="Plateau_User'.$j->id.'_Joue"></td></tr>';
19 75
 
76
+  for($l = 0 ; $l < 7 ; $l++) {
77
+    echo '<tr>';
78
+    for($c = 0 ; $c < 8 ; $c++)
79
+      affichePlateauCase($l, $c, $j);
20 80
 
21
-foreach($scPartie->joueurs as $j) {
22
-  if($j != $scMoi->id) {
23
-    $scJoueurs[] = new JoueurInfos();
24
-    $scJoueurs[ count($scJoueurs) - 1 ]->init( $req1['id'] );
81
+    if($l == 0) echo '<td><img src="src/diamant_gros.png" /><div class="nbr-diamant nbr-infos" id="Plateau_User'.$j->id.'_DiamantNbr">0</div></td>';
82
+    elseif($l == 1) echo '<td><img src="src/or_gros.png" /><div class="nbr-or nbr-infos" id="Plateau_User'.$j->id.'_OrNbr">0</div></td>';
83
+    elseif($l == 6) echo '<td><div class="calcul-total" id="Plateau_User'.$j->id.'_TotalNbr">0</div></td>';
84
+    else echo '<td><img src="src/temple'.($l - 1).'.png" /><div class="nbr-temple'.($l - 1).' nbr-infos" id="Plateau_User'.$j->id.'_Temple'.($l - 1).'Nbr"></div></td>';
85
+
86
+    echo '</tr>';
87
+    echo "\n";
25 88
   }
89
+
90
+
91
+  echo '</table>';
26 92
 }
27 93
 
28 94
 
... ...
@@ -31,15 +97,68 @@ foreach($scPartie->joueurs as $j) {
31 97
 ?>
32 98
 <html>
33 99
 <head>
34
-  <title>Karuba</title>
100
+  <title><?php echo $jeuNom; ?></title>
35 101
   <link rel="stylesheet" type="text/css" href="css/jeu.css" />
36 102
   <script type= "text/javascript" src="js/jquery-3.5.0.min.js"></script>
37
-  <script type= "text/javascript" src="js/karuba.js"></script>
103
+  <script type= "text/javascript" src="js/jeu.js"></script>
104
+  <script type="text/javascript">
105
+var scInput_JoueurId = <?php echo $scMoi->id; ?>;
106
+var scInput_JeuNom = '<?php echo $jeuNom; ?>';
107
+  </script>
38 108
 </head>
39 109
 <body>
40 110
 
41 111
 
42
-<?php print_r($scJoueurs); ?>
112
+<div class="zone-autres">
113
+  <?php foreach($scJoueurs as $j) { ?>
114
+  <div class="zone-autres-plateau">
115
+    <?php affichePlateauJoueur($j); ?>
116
+  </div>
117
+  <?php } ?>
118
+</div>
119
+
120
+
121
+<div class="zone-moi">
122
+  <div class="zone-moi-infos">
123
+    <table>
124
+      <tr>
125
+        <td id="zoneInfosTuile">
126
+          <div id="zoneInfosTuile_tuile"></div>
127
+          <div id="zoneInfosTuile_jeter" class="zone-moi-infos-tuile-jeter">Jeter ?</div>
128
+        </td>
129
+      </tr>
130
+      <tr>
131
+        <td id="zoneInfosReste">Reste : -</td>
132
+      </tr>
133
+      <tr>
134
+        <td>Tr&eacute;sors suivants :</td>
135
+      </tr>
136
+      <?php for($i = 1 ; $i <= 4 ; $i++) { ?>
137
+      <tr>
138
+        <td><img src="src/temple<?php echo $i; ?>.png" /><div class="zone-moi-infos-temple<?php echo $i; ?>" id="zoneInfosTemple<?php echo $i; ?>"></div></td>
139
+      </tr>
140
+      <?php } ?>
141
+    </table>
142
+  </div>
143
+
144
+  <div class="zone-moi-plateau">
145
+    <?php affichePlateauJoueur($scMoi); ?>
146
+  </div>
147
+</div>
148
+
149
+
150
+
151
+<div class="bas-btn">
152
+  <div class="bas-btn-terminer jeu-btn" id="basBoutons">Terminer la partie</div>
153
+</div>
154
+
155
+
156
+<div class="finpartie" id="finPartie">
157
+  <div class="finpartie-titre">Fin de partie</div>
158
+  <div class="finpartie-infos" id="finPartieInfos"></div>
159
+  <div class="finpartie-btn jeu-btn" id="finPartieBtn">Nouvelle partie !</div>
160
+</div>
161
+
43 162
 
44 163
 </body>
45 164
 </html>
... ...
@@ -1,6 +1,37 @@
1 1
 (function($) {
2
+$(document).ready(function() {
2 3
 
4
+  var scJoueurId = scInput_JoueurId;
3 5
 
4 6
 
7
+  function refreshScreen(data) {
8
+    if(data['statut'] == 0) {
9
+      window.location.href = 'index.php?j=' + scJoueurId;
10
+    }
5 11
 
12
+
13
+  }
14
+
15
+  function refresh() {
16
+    $.get('backend/jeu.php?j=' + scJoueurId)
17
+      .done(function(data, text, jqxhr) {
18
+        refreshScreen(  JSON.parse(jqxhr.responseText) );
19
+      })
20
+      .fail(function(jqxhr){
21
+//        alert(jqxhr.responseText);
22
+      })
23
+      .always(function(){
24
+        refreshTimer = setTimeout(refresh, 1000);
25
+      });
26
+  }
27
+
28
+  refresh();
29
+  var refreshTimer;
30
+
31
+
32
+
33
+
34
+
35
+
36
+});
6 37
 })(jQuery);