Browse code

Correction de bugs : plusieurs prises de tresors, transparence, ..

schardon authored on 26/04/2020 16:42:10
Showing 5 changed files
... ...
@@ -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
   }
... ...
@@ -144,6 +144,16 @@ table.plateau tr td img {
144 144
   position: relative;
145 145
 }
146 146
 
147
+.zone-moi-infos table tr td img {
148
+  position: absolute;
149
+  left: 0;
150
+  top: 0;
151
+}
152
+
153
+.zone-moi-infos-tuile-tuile {
154
+  cursor: pointer;
155
+}
156
+
147 157
 .zone-moi-infos-tuile-jeter {
148 158
   position: absolute;
149 159
   top: 10px;
... ...
@@ -41,7 +41,7 @@ class PartieInfos {
41 41
   public function gagneTresor($n) {
42 42
     $tresor = $this->tresor[$n][0];
43 43
     $this->tresor[$n] = substr($this->tresor[$n], 1);
44
-    if($this->tresorDejaPris[$n] > 0)
44
+    if($this->_tresorDejaPris[$n] > 0)
45 45
       $tresor = $this->_tresorDejaPris[$n];
46 46
     else
47 47
       $this->_tresorDejaPris[$n] = $tresor;
... ...
@@ -123,7 +123,7 @@ var scInput_JeuNom = '<?php echo $jeuNom; ?>';
123 123
     <table>
124 124
       <tr>
125 125
         <td id="zoneInfosTuile">
126
-          <div id="zoneInfosTuile_tuile"></div>
126
+          <div id="zoneInfosTuile_tuile" class="zone-moi-infos-tuile-tuile"></div>
127 127
           <div id="zoneInfosTuile_jeter" class="zone-moi-infos-tuile-jeter">Jeter ?</div>
128 128
         </td>
129 129
       </tr>
... ...
@@ -34,15 +34,10 @@ $(document).ready(function() {
34 34
        */
35 35
       for(var t = 0 ; t < data['joueur'][j]['plateau'].length ; t++) {
36 36
         if( ( !lastData || data['joueur'][j]['plateau'][t] != lastData['joueur'][j]['plateau'][t] ) && data['joueur'][j]['plateau'][t] != "" ) {
37
-          var caseInfo = data['joueur'][j]['plateau'][t];
38
-          var pepite = caseInfo[caseInfo.length - 1];
39
-          if(pepite == 'o' ||pepite == 'd')
40
-            caseInfo = caseInfo.substring(0, caseInfo.length - 1);
41
-          else
42
-            pepite = '';
43
-          $('#PlateauCase_User' + j + '_Case' + (t + 1)).html('<img src="src/tuile_' + caseInfo + '.png" />');
44
-          if(pepite != "")
45
-            $('#PlateauCase_User' + j + '_Case' + (t + 1)).append('<img src="src/tuile_' + pepite + '.png" />');
37
+          var caseInfo = decomposerTuile( data['joueur'][j]['plateau'][t] );
38
+          $('#PlateauCase_User' + j + '_Case' + (t + 1)).html('<img src="src/tuile_' + caseInfo[0] + '.png" />');
39
+          if(caseInfo[1] != "")
40
+            $('#PlateauCase_User' + j + '_Case' + (t + 1)).append('<img src="src/tuile_' + caseInfo[1] + '.png" />');
46 41
         }
47 42
       }
48 43
 
... ...
@@ -137,15 +132,10 @@ $(document).ready(function() {
137 132
 
138 133
       if( ( !lastData || lastData['statut'] < 9 || dejaJoue ) && data['joueur'][scJoueurId]['dernier_coup'].length == 0 ) {
139 134
         dejaJoue = false;
140
-        var pioche = data['pioche'];
141
-        var pepite = pioche[pioche.length - 1];
142
-        if(pepite == 'o' ||pepite == 'd')
143
-          pioche = pioche.substring(0, pioche.length - 1);
144
-        else
145
-          pepite = '';
146
-        $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche + '.png" />');
147
-        if(pepite != "")
148
-          $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pepite + '.png" />');
135
+        var pioche = decomposerTuile( data['pioche'] );
136
+        $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche[0] + '.png" />');
137
+        if(pioche[1] != "")
138
+          $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pioche[1] + '.png" />');
149 139
       }
150 140
 
151 141
       $('#zoneInfosReste').html( 'Reste : ' + data['nbpioche'] );
... ...
@@ -270,8 +260,11 @@ $(document).ready(function() {
270 260
         meepleSelected = 0;
271 261
         $.get('backend/jeu.php?j=' + scJoueurId + '&dc=c' + InfoID)
272 262
           .done(function(data, text, jqxhr) {
263
+            var piocheAff = decomposerTuile( lastData['pioche'] );
273 264
             $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />');
274
-            $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + lastData['pioche'] + '.png" style="opacity: 0.5" />');
265
+            $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[0] + '.png" style="opacity: 0.5" />');
266
+            if(piocheAff[1] != "")
267
+              $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[1] + '.png" style="opacity: 0.5" />');
275 268
             dejaJoue = true;
276 269
           })
277 270
           .fail(function(jqxhr){
... ...
@@ -430,5 +423,24 @@ $(document).ready(function() {
430 423
 
431 424
 
432 425
 
426
+
427
+  /*
428
+   * FONCTIONS ANNEXES
429
+   */
430
+  function decomposerTuile(id) {
431
+    var newId = id;
432
+    var pepite = newId[newId.length - 1];
433
+    if(pepite == 'o' ||pepite == 'd')
434
+      newId = newId.substring(0, newId.length - 1);
435
+    else
436
+      pepite = '';
437
+
438
+    return [newId, pepite];
439
+  }
440
+
441
+
442
+
443
+
444
+
433 445
 });
434 446
 })(jQuery);