4 | 5 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,61 @@ |
1 |
+Creation des bases : |
|
2 |
+ |
|
3 |
+ |
|
4 |
+ |
|
5 |
+-- Structure de la table `jeuweb_karuba_parties` |
|
6 |
+ |
|
7 |
+CREATE TABLE `jeuweb_karuba_parties` ( |
|
8 |
+ `id` int(11) NOT NULL, |
|
9 |
+ `nom` text NOT NULL, |
|
10 |
+ `pioche` text NOT NULL, |
|
11 |
+ `statut` int(11) NOT NULL DEFAULT '0', |
|
12 |
+ `tresor1` text NOT NULL, |
|
13 |
+ `tresor2` text NOT NULL, |
|
14 |
+ `tresor3` text NOT NULL, |
|
15 |
+ `tresor4` text NOT NULL, |
|
16 |
+ `wait` int(11) NOT NULL DEFAULT '0' |
|
17 |
+) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
|
18 |
+ |
|
19 |
+ALTER TABLE `jeuweb_karuba_parties` |
|
20 |
+ ADD PRIMARY KEY (`id`); |
|
21 |
+ |
|
22 |
+ALTER TABLE `jeuweb_karuba_parties` |
|
23 |
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1; |
|
24 |
+ |
|
25 |
+ |
|
26 |
+ |
|
27 |
+-- Structure de la table `jeuweb_karuba_joueurs` |
|
28 |
+ |
|
29 |
+CREATE TABLE `jeuweb_karuba_joueurs` ( |
|
30 |
+ `id` int(11) NOT NULL, |
|
31 |
+ `nom` text NOT NULL, |
|
32 |
+ `partie_id` int(11) NOT NULL, |
|
33 |
+ `plateau` text NOT NULL, |
|
34 |
+ `statut` int(11) NOT NULL DEFAULT '0', |
|
35 |
+ `tresor1` int(11) NOT NULL DEFAULT '0', |
|
36 |
+ `tresor2` int(11) NOT NULL DEFAULT '0', |
|
37 |
+ `tresor3` int(11) NOT NULL DEFAULT '0', |
|
38 |
+ `tresor4` int(11) NOT NULL DEFAULT '0', |
|
39 |
+ `pepite_diamant` int(11) NOT NULL DEFAULT '0', |
|
40 |
+ `pepite_or` int(11) NOT NULL DEFAULT '0', |
|
41 |
+ `dernier_coup` text NOT NULL, |
|
42 |
+ `position_meeple1` int(11) NOT NULL DEFAULT '0', |
|
43 |
+ `position_temple1` int(11) NOT NULL DEFAULT '0', |
|
44 |
+ `position_meeple2` int(11) NOT NULL DEFAULT '0', |
|
45 |
+ `position_temple2` int(11) NOT NULL DEFAULT '0', |
|
46 |
+ `position_meeple3` int(11) NOT NULL DEFAULT '0', |
|
47 |
+ `position_temple3` int(11) NOT NULL DEFAULT '0', |
|
48 |
+ `position_meeple4` int(11) NOT NULL DEFAULT '0', |
|
49 |
+ `position_temple4` int(11) NOT NULL DEFAULT '0' |
|
50 |
+) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
|
51 |
+ |
|
52 |
+ALTER TABLE `jeuweb_karuba_joueurs` |
|
53 |
+ ADD PRIMARY KEY (`id`); |
|
54 |
+ |
|
55 |
+ALTER TABLE `jeuweb_karuba_joueurs` |
|
56 |
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1; |
|
57 |
+ |
|
58 |
+ |
|
59 |
+ |
|
60 |
+COMMIT; |
|
61 |
+ |
... | ... |
@@ -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; |
... | ... |
@@ -25,10 +25,10 @@ class PartieInfos { |
25 | 25 |
} |
26 | 26 |
|
27 | 27 |
public function creer($nom) { |
28 |
- global $db; |
|
28 |
+ global $db, $__CONF; |
|
29 | 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']; |
|
30 |
+ $db->req("INSERT INTO ".$__CONF['dbtablepre']."parties(nom) VALUES ('".$nom."');"); |
|
31 |
+ return $db->reqFirst("SELECT id FROM ".$__CONF['dbtablepre']."parties ORDER BY id DESC LIMIT 1;")['id']; |
|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
public function nextTresor() { |
... | ... |
@@ -53,9 +53,9 @@ class PartieInfos { |
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
public function refresh() { |
56 |
- global $db; |
|
56 |
+ global $db, $__CONF; |
|
57 | 57 |
|
58 |
- $req = $db->reqFirst('SELECT * FROM parties WHERE id='.$this->id.';'); |
|
58 |
+ $req = $db->reqFirst("SELECT * FROM ".$__CONF['dbtablepre']."parties WHERE id=".$this->id.";"); |
|
59 | 59 |
|
60 | 60 |
if(!$req) { |
61 | 61 |
$this->_exist = false; |
... | ... |
@@ -73,7 +73,7 @@ class PartieInfos { |
73 | 73 |
$this->pioche = explode(',', $req['pioche']); |
74 | 74 |
|
75 | 75 |
$this->joueurs = []; |
76 |
- $req = $db->req("SELECT id FROM joueurs WHERE partie_id=".$this->id." AND statut>0;"); |
|
76 |
+ $req = $db->req("SELECT id FROM ".$__CONF['dbtablepre']."joueurs WHERE partie_id=".$this->id." AND statut>0;"); |
|
77 | 77 |
while( $req1 = $db->next($req) ) |
78 | 78 |
$this->joueurs[] = $req1['id']; |
79 | 79 |
$this->nbjoueurs = count($this->joueurs); |
... | ... |
@@ -93,7 +93,7 @@ class PartieInfos { |
93 | 93 |
} |
94 | 94 |
|
95 | 95 |
public function nouvelle() { |
96 |
- global $db; |
|
96 |
+ global $db, $__CONF; |
|
97 | 97 |
|
98 | 98 |
if(!$this->_exist) return false; |
99 | 99 |
|
... | ... |
@@ -126,10 +126,10 @@ class PartieInfos { |
126 | 126 |
if($this->nbjoueurs >= 12) $tresors = '555444333222'; |
127 | 127 |
|
128 | 128 |
|
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;"); |
|
129 |
+ $req = $db->req("UPDATE ".$__CONF['dbtablepre']."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 | 130 |
if(!$req) return false; |
131 | 131 |
|
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.";"); |
|
132 |
+ $req = $db->req("UPDATE ".$__CONF['dbtablepre']."parties SET pioche='".$piocheTxt."', statut=1, tresor1=".$tresors.", tresor2=".$tresors.", tresor3=".$tresors.", tresor4=".$tresors.", wait=0 WHERE id=".$this->id.";"); |
|
133 | 133 |
if(!$req) return false; |
134 | 134 |
|
135 | 135 |
return true; |
... | ... |
@@ -11,8 +11,8 @@ if( !$scMoi->exist() ) |
11 | 11 |
* LANCER UNE NOUVELLE PARTIE |
12 | 12 |
*/ |
13 | 13 |
if( isset($_GET['new']) ) { |
14 |
- $db->req("UPDATE parties SET statut=0 WHERE id=".$scPartie->id.";"); |
|
15 |
- $db->req("UPDATE joueurs SET statut=0 WHERE partie_id=".$scPartie->id.";"); |
|
14 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."parties SET statut=0 WHERE id=".$scPartie->id.";"); |
|
15 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET statut=0 WHERE partie_id=".$scPartie->id.";"); |
|
16 | 16 |
exit(); |
17 | 17 |
} |
18 | 18 |
|
... | ... |
@@ -24,8 +24,8 @@ if( isset($_GET['meeple']) ) { |
24 | 24 |
exit(); |
25 | 25 |
|
26 | 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.";"); |
|
27 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET position_meeple".$meepleId."=".(100 + intval($_GET['meeple']))." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
28 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
29 | 29 |
exit(); |
30 | 30 |
} |
31 | 31 |
|
... | ... |
@@ -37,8 +37,8 @@ if( isset($_GET['temple']) ) { |
37 | 37 |
exit(); |
38 | 38 |
|
39 | 39 |
$templeId = $scPartie->statut / 2; |
40 |
- $db->req("UPDATE joueurs SET position_temple".$templeId."=".intval($_GET['temple'])." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
41 |
- $db->req("UPDATE parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
40 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET position_temple".$templeId."=".intval($_GET['temple'])." WHERE partie_id=".$scPartie->id." AND statut>0;"); |
|
41 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."parties SET statut=(statut+1) WHERE id=".$scPartie->id.";"); |
|
42 | 42 |
exit(); |
43 | 43 |
} |
44 | 44 |
|
... | ... |
@@ -46,7 +46,7 @@ if( isset($_GET['temple']) ) { |
46 | 46 |
* JOUE |
47 | 47 |
*/ |
48 | 48 |
function compileDernierCoup($j, $tuile) { |
49 |
- global $db, $scPartie; |
|
49 |
+ global $db, $scPartie, $__CONF; |
|
50 | 50 |
|
51 | 51 |
$dcAction = $j->dernier_coup[0]; |
52 | 52 |
$dcVal = substr($j->dernier_coup, 1); |
... | ... |
@@ -82,7 +82,7 @@ function compileDernierCoup($j, $tuile) { |
82 | 82 |
} |
83 | 83 |
} |
84 | 84 |
|
85 |
- $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.";"); |
|
85 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."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.";"); |
|
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
function verifFinPartie($j) { |
... | ... |
@@ -100,7 +100,7 @@ function verifFinPartie($j) { |
100 | 100 |
|
101 | 101 |
|
102 | 102 |
if( isset($_GET['dc']) ) { |
103 |
- $db->req("UPDATE joueurs SET dernier_coup='".$_GET['dc']."' WHERE id=".$scMoi->id.";"); |
|
103 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."joueurs SET dernier_coup='".$_GET['dc']."' WHERE id=".$scMoi->id.";"); |
|
104 | 104 |
$scMoi->dernier_coup = $_GET['dc']; |
105 | 105 |
|
106 | 106 |
|
... | ... |
@@ -116,7 +116,6 @@ if( isset($_GET['dc']) ) { |
116 | 116 |
if($nbDejaJoue == count($scJoueurs)) { |
117 | 117 |
// Extrait la 1ere tuile de la pioche |
118 | 118 |
$tuile = array_shift( $scPartie->pioche ); |
119 |
- |
|
120 | 119 |
compileDernierCoup($scMoi, $tuile); |
121 | 120 |
foreach($scJoueurs as $j) |
122 | 121 |
compileDernierCoup($j, $tuile); |
... | ... |
@@ -136,9 +135,7 @@ if( isset($_GET['dc']) ) { |
136 | 135 |
if($fin) |
137 | 136 |
$scPartie->statut++; |
138 | 137 |
|
139 |
- |
|
140 |
- $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.";"); |
|
141 |
- |
|
138 |
+ $db->req("UPDATE ".$__CONF['dbtablepre']."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.";"); |
|
142 | 139 |
} |
143 | 140 |
|
144 | 141 |
exit(); |