示例#1
0
 protected function giveItemToWorld($gameId, $itemId, $floatLat, $floatLong, $intQty = 1)
 {
     $clumpingRangeInMeters = 10;
     $query = "SELECT *,((ACOS(SIN({$floatLat} * PI() / 180) * SIN(latitude * PI() / 180) + \n                COS({$floatLat} * PI() / 180) * COS(latitude * PI() / 180) * \n                COS(({$floatLong} - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) * 1609.344\n                AS `distance`, location_id \n                FROM locations \n                WHERE type = 'item' AND type_id = '{$itemId}' AND game_id = '{$gameId}'\n                HAVING distance<= {$clumpingRangeInMeters}\n            ORDER BY distance ASC";
     $result = Module::query($query);
     if ($closestLocationWithinClumpingRange = @mysql_fetch_object($result)) {
         Module::query("UPDATE locations SET item_qty = item_qty + {$intQty} WHERE location_id = {$closestLocationWithinClumpingRange->location_id} AND game_id = '{$gameId}'");
     } else {
         $item = Module::queryObject("SELECT * FROM items WHERE item_id = '{$itemId}'");
         Module::query("INSERT INTO locations (game_id, name, type, type_id, icon_media_id, latitude, longitude, error, item_qty) VALUES ('{$gameId}', '{$item->name}','Item','{$itemId}', '{$item->icon_media_id}', '{$floatLat}','{$floatLong}', '100','{$intQty}')");
         QRCodes::createQRCode($gameId, "Location", mysql_insert_id(), '');
     }
 }
示例#2
0
 protected function giveItemToWorld($gameId, $intItemID, $floatLat, $floatLong, $intQty = 1)
 {
     //Find any items on the map nearby
     $clumpingRangeInMeters = 10;
     $query = "SELECT *,((ACOS(SIN({$floatLat} * PI() / 180) * SIN(latitude * PI() / 180) + \n            COS({$floatLat} * PI() / 180) * COS(latitude * PI() / 180) * \n            COS(({$floatLong} - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) * 1609.344\n            AS `distance`, location_id \n            FROM locations \n            WHERE type = 'item' AND type_id = '{$intItemID}' AND game_id = '{$gameId}'\n            HAVING distance<= {$clumpingRangeInMeters}\n        ORDER BY distance ASC";
     $result = Module::query($query);
     if ($closestLocationWithinClumpingRange = @mysql_fetch_object($result)) {
         //We have a match
         $query = "UPDATE locations\n                SET item_qty = item_qty + {$intQty}\n            WHERE location_id = {$closestLocationWithinClumpingRange->location_id} AND game_id = '{$gameId}'";
         Module::query($query);
     } else {
         $itemName = $this->getItemName($gameId, $intItemID);
         $error = 100;
         //Use 100 meters
         $icon_media_id = $this->getItemIconMediaId($gameId, $intItemID);
         //Set the map icon = the item's icon
         $query = "INSERT INTO locations (game_id, name, type, type_id, icon_media_id, latitude, longitude, error, item_qty)\n                VALUES ('{$gameId}', '{$itemName}','Item','{$intItemID}', '{$icon_media_id}', '{$floatLat}','{$floatLong}', '{$error}','{$intQty}')";
         Module::query($query);
         $newId = mysql_insert_id();
         //Create a coresponding QR Code
         QRCodes::createQRCode($gameId, "Location", $newId, '');
     }
 }
示例#3
0
 private function isValidObjectType($strObjectType)
 {
     $validTypes = QRCodes::lookupContentTypeOptionsFromSQL();
     return in_array($strObjectType, $validTypes);
 }
示例#4
0
 public function deleteLocation($gameId, $intLocationId)
 {
     //Lookup the name of the item
     $query = "DELETE FROM locations \n            WHERE game_id = {$gameId} AND location_id = '{$intLocationId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     //Delete any QR Codes that point here
     QRCodes::deleteQRCodeCodesForLink($gameId, "Location", $intLocationId);
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE);
     } else {
         return new returnData(0, FALSE);
     }
 }