Browse code

Passage en MySQL

schardon authored on 01/05/2020 17:19:57
Showing 1 changed files
... ...
@@ -29,16 +29,16 @@ class JoueurInfos {
29 29
   }
30 30
 
31 31
   public function creer($nom, $partie_id) {
32
-    global $db;
32
+    global $db, $__CONF;
33 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'];
34
+    $db->req("INSERT INTO ".$__CONF['dbtablepre']."joueurs(nom, partie_id) VALUES ('".$nom."', ".$partie_id.");");
35
+    return $db->reqFirst("SELECT id FROM ".$__CONF['dbtablepre']."joueurs WHERE partie_id=".$partie_id." ORDER BY id DESC LIMIT 1;")['id'];
36 36
   }
37 37
 
38 38
   public function refresh() {
39
-    global $db;
39
+    global $db, $__CONF;
40 40
 
41
-    $req = $db->reqFirst('SELECT * FROM joueurs WHERE id='.$this->id.';');
41
+    $req = $db->reqFirst("SELECT * FROM ".$__CONF['dbtablepre']."joueurs WHERE id=".$this->id.";");
42 42
 
43 43
     if(!$req) {
44 44
       $this->_exist = false;
Browse code

Version complete a tester

schardon authored on 26/04/2020 11:25:16
Showing 1 changed files
... ...
@@ -67,7 +67,7 @@ class JoueurInfos {
67 67
     if(!$this->_exist) return false;
68 68
 
69 69
     $plateauTxt = '';
70
-    for($i = 0 ; $i < count($req['plateau']) ; $i++) {
70
+    for($i = 0 ; $i < count($this->plateau) ; $i++) {
71 71
       if($i > 0) $plateauTxt .= ',';
72 72
       $plateauTxt .= $this->plateau[$i];
73 73
     }
Browse code

Affichage static de l'ecran de jeu

schardon authored on 24/04/2020 13:42:47
Showing 1 changed files
... ...
@@ -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']);
Browse code

Gestion du choix de la partie et du joueur

schardon authored on 22/04/2020 21:35:22
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,71 @@
1
+<?php
2
+
3
+class JoueurInfos {
4
+  public $id;
5
+  public $nom;
6
+  public $partie_id;
7
+  public $plateau;
8
+  public $statut;
9
+  public $tresor;
10
+  public $diamant;
11
+  public $or;
12
+  public $meeple;
13
+  public $temple;
14
+  public $dernier_coup;
15
+
16
+  private $_exist;
17
+
18
+  public function __construct() {
19
+    $this->_exist = false;
20
+  }
21
+
22
+  public function init($id) {
23
+    $this->id = $id;
24
+    $this->refresh();
25
+  }
26
+
27
+  public function exist() {
28
+    return $this->_exist;
29
+  }
30
+
31
+  public function refresh() {
32
+    global $db;
33
+
34
+    $req = $db->reqFirst('SELECT * FROM joueurs WHERE id='.$this->id.';');
35
+
36
+    if(!$req) {
37
+      $this->_exist = false;
38
+      return;
39
+    }
40
+
41
+    $this->nom = $req['nom'];
42
+    $this->partie_id = $req['partie_id'];
43
+    $this->statut = $req['statut'];
44
+    $this->diamant = $req['pepite_diamant'];
45
+    $this->or = $req['pepite_or'];
46
+    $this->dernier_coup = $req['dernier_coup'];
47
+
48
+    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];
52
+    }
53
+
54
+    $this->plateau = explode(',', $req['plateau']);
55
+
56
+    $this->_exist = true;
57
+  }
58
+
59
+  public function plateauTxt() {
60
+    if(!$this->_exist) return false;
61
+
62
+    $plateauTxt = '';
63
+    for($i = 0 ; $i < count($req['plateau']) ; $i++) {
64
+      if($i > 0) $plateauTxt .= ',';
65
+      $plateauTxt .= $this->plateau[$i];
66
+    }
67
+    return $plateauTxt;
68
+  }
69
+}
70
+
71
+?>