예제 #1
0
 /**
  * @param $user IMappable
  * @param $distance int
  * @return Mapzone
  */
 public function GetARandomMove(IMappable $user, $distance = 1)
 {
     $query = 'SELECT id FROM game.mapzone WHERE x>=' . ($user->getX() - $distance) . ' AND y>=' . ($user->getY() - $distance) . ' AND x<=' . ($user->getX() + $distance) . ' AND y<=' . ($user->getY() + $distance) . ' ORDER BY Rand() LIMIT 1;';
     $this->db->setQuery($query);
     $this->db->query();
     $loadObj = $this->db->loadObject();
     $mz = new Mapzone($loadObj->id);
     $mz->setDb($this->db);
     $mz->load();
     return $mz;
 }
예제 #2
0
 /**
  * @param IMappable $issuer
  * @param $x2
  * @param $y2
  * @return array
  */
 public function travel(IMappable $issuer, $x2, $y2)
 {
     // Get the issuer's current location
     $x1 = $issuer->getX();
     $y1 = $issuer->getY();
     if ($this->map->checkLegalMove($x1, $y1, $x2, $y2)) {
         $result = $this->map->mapTravel($issuer, $x2, $y2);
         return $this->getResult('Success', $result);
     } else {
         return $this->getResult('Illegal move', $x2 . ', ' . $y2 . ' is too far or is not passable');
     }
 }