Beispiel #1
0
    /**
     * 
     * Construit une instance de DBItem à partir
     * du nom de la classe finalement étendue.
     */
    public function __construct()
    {
        parent::__construct('jeu', queryLine('
			select *
			from jeu
			where jeu_name=\'' . strtolower(get_class($this)) . '\'
		'));
    }
Beispiel #2
0
 /**
  * 
  * Teste une connexion d'un user et renvoi son instance.
  * 
  * @param String $user username
  * @param String $pass password en clair
  * @return Joueur|integer 
  * 		Joueur qui s'est logé avec succes
  * 		-1 pour mauvais pass
  * 		-2 pour user inexistant (ou invité)
  * 
  */
 public static function testerLogins($user, $pass)
 {
     $res = queryLine('select * from joueur where joueur_pseudo=\'' . $user . '\'');
     if ($res) {
         if (intval($res['joueur_invite']) == 1) {
             return -2;
         }
         $hash = self::getHash($pass);
         if (strcmp($res['joueur_password_hash'], $hash) == 0) {
             return new Joueur($res);
         } else {
             return -1;
         }
     } else {
         return -2;
     }
 }
Beispiel #3
0
    /**
     * 
     * 
     * @param Joueur $joueur à tester si il est dans la partie or not
     * @return Slot|null
     */
    public function hasJoueur($joueur)
    {
        $data = queryLine('
			select *
			from partie
			natural join slot
			natural join joueur
			where partie_id=' . $this->getID() . '
			and joueur_id=' . $joueur->getID());
        return $data ? new Slot($data) : null;
    }
Beispiel #4
0
 public static function getItem($object, $query)
 {
     $line = queryLine($query);
     return new $object($line);
 }
Beispiel #5
0
    /**
     * 
     * Requiert getValue('partie'); ou Slot
     */
    private function initPartie()
    {
        if ($partie_id = getValue('partie', false)) {
            $partie = $partie_id;
        } else {
            if (slot()) {
                $partie = queryLine('
				select *
				from partie
				where partie_id=' . slot()->partie_id . '
			');
            } else {
                return;
            }
        }
        $this->singleton_partie = new Partie($partie);
    }