_exist = false; } public function init($id) { $this->id = $id; $this->refresh(); } public function exist() { return $this->_exist; } public function creer($nom, $partie_id) { global $db; $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);"); return $db->reqFirst("SELECT id FROM joueurs WHERE partie_id=".$partie_id." ORDER BY id DESC LIMIT 1;")['id']; } public function refresh() { global $db; $req = $db->reqFirst('SELECT * FROM joueurs WHERE id='.$this->id.';'); if(!$req) { $this->_exist = false; return; } $this->nom = $req['nom']; $this->partie_id = $req['partie_id']; $this->statut = $req['statut']; $this->diamant = $req['pepite_diamant']; $this->or = $req['pepite_or']; $this->dernier_coup = $req['dernier_coup']; for($i = 0 ; $i < 4 ; $i++) { $this->temple[$i] = $req['position_temple'.($i + 1)]; $this->meeple[$i] = $req['position_meeple'.($i + 1)]; $this->tresor[$i] = $req['tresor'.($i + 1)]; } $this->plateau = explode(',', $req['plateau']); $this->_exist = true; } public function plateauTxt() { if(!$this->_exist) return false; $plateauTxt = ''; for($i = 0 ; $i < count($req['plateau']) ; $i++) { if($i > 0) $plateauTxt .= ','; $plateauTxt .= $this->plateau[$i]; } return $plateauTxt; } } ?>