Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     Logger::Fine("Login server is online");
 }
Exemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     if (is_dir("crumbs") === false) {
         mkdir("crumbs", 0777);
     }
     $downloadAndDecode = function ($url) {
         $filename = basename($url, ".json");
         if (file_exists("crumbs/{$filename}.json")) {
             $jsonData = file_get_contents("crumbs/{$filename}.json");
         } else {
             $jsonData = file_get_contents($url);
             file_put_contents("crumbs/{$filename}.json", $jsonData);
         }
         $dataArray = json_decode($jsonData, true);
         return $dataArray;
     };
     $rooms = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/rooms.json");
     foreach ($rooms as $room => $details) {
         $this->rooms[$room] = new Room($room, sizeof($this->rooms) + 1, $details['path'] == '' ? true : false);
     }
     $stamps = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/stamps.json");
     foreach ($stamps as $stampCat) {
         if ($stampCat['parent_group_id'] == 8) {
             foreach ($stampCat['stamps'] as $stamp) {
                 foreach ($rooms as $room) {
                     if (str_replace("Games : ", "", $stampCat['display']) == $room['display_name']) {
                         $roomId = $room['room_id'];
                     }
                 }
                 $this->gameStamps[$roomId][] = $stamp['stamp_id'];
             }
         }
     }
     unset($rooms);
     unset($stamps);
     $agentRooms = array(210, 212, 323, 803);
     $rockhoppersShip = array(422, 423);
     $ninjaRooms = array(320, 321, 324, 326);
     $hotelRooms = range(430, 434);
     $noSpawn = array_merge($agentRooms, $rockhoppersShip, $ninjaRooms, $hotelRooms);
     $this->spawnRooms = array_keys(array_filter($this->rooms, function ($room) use($noSpawn) {
         if (!in_array($room->externalId, $noSpawn) && $room->externalId <= 810) {
             return true;
         }
     }));
     $items = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/paper_items.json");
     foreach ($items as $itemIndex => $item) {
         $itemId = $item["paper_item_id"];
         $this->items[$itemId] = $item["cost"];
         if ($item["type"] == 8) {
             array_push($this->pins, $itemId);
         }
         if (isset($item['is_epf'])) {
             $this->epfItems[$item["paper_item_id"]] = $item["cost"];
         }
         unset($items[$itemIndex]);
     }
     $locations = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/igloo_locations.json");
     foreach ($locations as $locationIndex => $location) {
         $locationId = $location["igloo_location_id"];
         $this->locations[$locationId] = $location["cost"];
         unset($locations[$locationIndex]);
     }
     $furnitureList = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/furniture_items.json");
     foreach ($furnitureList as $furnitureIndex => $furniture) {
         $furnitureId = $furniture["furniture_item_id"];
         $this->furniture[$furnitureId] = $furniture["cost"];
         unset($furnitureList[$furnitureIndex]);
     }
     $floors = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/igloo_floors.json");
     foreach ($floors as $floorIndex => $floor) {
         $floorId = $floor["igloo_floor_id"];
         $this->floors[$floorId] = $floor["cost"];
         unset($floors[$floorIndex]);
     }
     $igloos = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/igloos.json");
     foreach ($igloos as $iglooId => $igloo) {
         $this->igloos[$iglooId] = $igloo["cost"];
         unset($igloos[$iglooId]);
     }
     $careItems = $downloadAndDecode("http://media1.clubpenguin.com/play/en/web_service/game_configs/puffle_items.json");
     foreach ($careItems as $careId => $careItem) {
         $itemId = $careItem["puffle_item_id"];
         $this->careItems[$itemId] = array($careItem["cost"], $careItem["quantity"]);
         unset($careItems[$careId]);
     }
     $tableIds = range(200, 207);
     $emptyTable = array();
     $this->tablePopulationById = array_fill_keys($tableIds, $emptyTable);
     $this->playersByTableId = array_fill_keys($tableIds, $emptyTable);
     $this->gamesByTableId = array_fill_keys($tableIds, null);
     Logger::Fine("World server is online");
 }