Esempio n. 1
0
 public function Get_Item_Information($itemtypeid)
 {
     $itemtypeid = urldecode($itemtypeid);
     if (!is_numeric($itemtypeid)) {
         return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
     }
     if (strlen($itemtypeid) > 8) {
         return Response::json(array('status' => 'error', 'error' => 'This is not a proper ItemTypeID.'));
     }
     //check the cache
     if (Cache::has($this->class_name . "_" . $itemtypeid)) {
         //pull from cache
         $itemtypeid_info = Cache::get($this->class_name . "_" . $itemtypeid);
         return json_encode($itemtypeid_info);
     }
     $basic_info = hWebIcon::where(function ($query) use($itemtypeid) {
         $query->where('itemTypeId', '=', $itemtypeid);
         $query->where('version', '=', $this->version);
     })->first(array('asset_path', 'abilitymodule_id', 'backpack_id', 'basic_id', 'blueprint_id', 'chassis_id', 'consumable_id', 'craftingcomponent_id', 'craftingstation_id', 'craftingsubcomponent_id', 'framemodule_id', 'palettemodule_id', 'powerup_id', 'resourceitem_id', 'scopemodule_id', 'weapon_id', 'weaponmodule_id'));
     if (empty($basic_info)) {
         return Response::json(array('status' => 'error', 'error' => 'ItemTypeID not found in db.'));
     }
     //break up the types
     $detailed_info = array();
     $constraint_info = array();
     $weapon_info = array();
     if ($basic_info['abilitymodule_id'] != "") {
         $detailed_info = AbilityModule::where('id', '=', $basic_info['abilitymodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
     }
     if ($basic_info['basic_id'] != "") {
         $detailed_info = Basic::where('id', '=', $basic_info['basic_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['blueprint_id'] != "") {
         //Note -> blueprint_id = recipe_id
     }
     if ($basic_info['chassis_id'] != "") {
         //Note -> links to hattributes
         $detailed_info = Chassis::where('id', '=', $basic_info['chassis_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'progression_item_id', 'progression_resource_id'));
         $chassis_info = hAttributes::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->get(array('description', 'display_name', 'value', 'stat_id'));
     }
     if ($basic_info['consumable_id'] != "") {
         $detailed_info = Consumable::where('id', '=', $basic_info['consumable_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'powerLevel', 'name', 'rarity'));
     }
     if ($basic_info['craftingcomponent_id'] != "") {
         $detailed_info = CraftingComponent::where('id', '=', $basic_info['craftingcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['craftingsubcomponent_id'] != "") {
         $detailed_info = CraftingSubcomponent::where('id', '=', $basic_info['craftingsubcomponent_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['framemodule_id'] != "") {
         $detailed_info = FrameModule::where('id', '=', $basic_info['framemodule_id'])->first(array('type', 'abilityId', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'powerLevel', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
     }
     if ($basic_info['palletmodule_id'] != "") {
         $detailed_info = PaletteModule::where('id', '=', $basic_info['palettemodule_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['powerup_id'] != "") {
         $detailed_info = Powerup::where('id', '=', $basic_info['powerup_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity'));
     }
     if ($basic_info['resourceitem_id'] != "") {
         $detailed_info = ResourceItem::where('id', '=', $basic_info['resourceitem_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'resource_color'));
     }
     if ($basic_info['weapon_id'] != "") {
         //weapons have hstats also!
         $detailed_info = Weapon::where('id', '=', $basic_info['weapon_id'])->first(array('type', 'craftingTypeId', 'subTypeId', 'description', 'level', 'name', 'rarity', 'durability'));
         $constraint_info = hConstraint::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('cpu', 'mass', 'power'));
         $weapon_info = hStat::where(function ($query) use($itemtypeid) {
             $query->where('itemTypeId', '=', $itemtypeid);
             $query->where('version', '=', $this->version);
         })->first(array('ammoPerBurst', 'clipSize', 'damagePerRound', 'damagePerSecond', 'healthPerRound', 'maxAmmo', 'range', 'reloadTime', 'roundsPerBurst', 'roundsPerMinute', 'splashRadius', 'spread'));
     }
     if (empty($detailed_info)) {
         return Response::json(array('status' => 'error', 'error' => 'error getting detailed information for this itemtypeid.'));
     }
     $detailed_info = $detailed_info->toArray();
     $detailed_info['asset_path'] = $basic_info['asset_path'];
     //add contstraint details
     if (!empty($constraint_info)) {
         $constraint_info = $constraint_info->toArray();
         $detailed_info['cpu'] = $constraint_info['cpu'];
         $detailed_info['mass'] = $constraint_info['mass'];
         $detailed_info['power'] = $constraint_info['power'];
     }
     if (!empty($weapon_info)) {
         $weapon_info = $weapon_info->toArray();
         foreach ($weapon_info as $key => $data) {
             $detailed_info[$key] = $data;
         }
     }
     if (!empty($chassis_info)) {
         $chassis_info = $chassis_info->toArray();
         foreach ($chassis_info as $key => $data) {
             $detailed_info[$key] = $data;
         }
     }
     //cache
     //Cache::forever($this->class_name . "_" . $itemtypeid,$detailed_info);
     $detailed_info['status'] = 'success';
     return json_encode($detailed_info);
 }
Esempio n. 2
0
 public function get_player_profile_chassis($name, $chassis_id)
 {
     //quality control (get it?)
     function quality_control($quality)
     {
         switch ($quality) {
             case 0:
                 return "common";
                 break;
             case 1000:
                 return "legendary";
                 break;
             case $quality >= 901:
                 return "epic";
                 break;
             case $quality >= 701:
                 return "rare";
                 break;
             case $quality >= 401:
                 return "uncommon";
                 break;
             default:
                 return "common";
                 break;
         }
     }
     //searching by name, null name = no buenos
     if ($name == NULL) {
         return Response::error('404');
     } else {
         $input_name = urldecode($name);
     }
     //Look up the player, latest to account for deletes with the same name
     $player = Player::where('name', '=', $input_name)->order_by('created_at', 'DESC')->first();
     //no player found, why not search?
     if (!$player) {
         return Response::error('404');
     }
     //Pull this chassis_id loadout from cache
     $cache_key_loadouts = $player->db_id . "_loadouts";
     $loadout = Cache::Get($cache_key_loadouts . '_' . $chassis_id);
     $cache_set_check = Cache::Get($cache_key_loadouts . "_" . $chassis_id . "_md5");
     if ($cache_set_check == md5(serialize($loadout))) {
         //load this chassis entirely from cache
         $player_item_abilities = Cache::Get($cache_key_loadouts . "_" . $chassis_id . "_abilities");
         $player_item_gear = Cache::Get($cache_key_loadouts . "_" . $chassis_id . "_gear");
         $player_item_weapons = Cache::Get($cache_key_loadouts . "_" . $chassis_id . "_weapons");
     } else {
         //List of "secret" gear we don't want displayed
         $processor_framemods = array(75780, 75782, 75784, 75786, 75915, 75916, 75917, 75918, 75878, 75691, 76013, 76014, 76015, 76016, 76017);
         $player_gear_sdb_id = array();
         //Add all of our gear and abilities to the list
         for ($i = 0; $i < count($loadout->Gear); $i++) {
             if (isset($loadout->Gear[$i]->info->item_sdb_id)) {
                 $player_gear_sdb_id[$i] = $loadout->Gear[$i]->info->item_sdb_id;
             }
         }
         //Now add weapons to that
         for ($i = 0; $i < count($loadout->Weapons); $i++) {
             if (isset($loadout->Weapons[$i]->info->item_sdb_id)) {
                 $player_gear_sdb_id[] = $loadout->Weapons[$i]->info->item_sdb_id;
             }
         }
         $player_gear = array();
         if (!empty($player_gear_sdb_id)) {
             $player_gear = hWebIcon::where(function ($query) use($player_gear_sdb_id) {
                 $query->where_in('itemTypeId', $player_gear_sdb_id);
                 $query->where('version', '=', Base_Controller::getVersionDate());
             })->get();
             //reindex the get result
             $player_gear_base_item = array();
             foreach ($player_gear_sdb_id as $id) {
                 foreach ($player_gear as $item) {
                     if ($item->itemtypeid == $id) {
                         $player_gear_base_item[] = $item;
                     }
                 }
             }
             //remove player_gear variable;
             $player_gear = null;
         } else {
             $player_gear_base_item = null;
         }
         $gear_counter = 0;
         $ability_counter = 0;
         $weapon_counter = 0;
         $player_item_abilities = array();
         $player_item_gear = array();
         $player_item_weapons = array();
         for ($i = 0; $i < count($player_gear_base_item); $i++) {
             $player_gear_icons[$i] = $player_gear_base_item[$i]->asset_path;
             //the gear is either going to be an ability, frame mod or weapon
             if (isset($player_gear_base_item[$i]->backpack_id)) {
                 //do nothing we don't display backpacks
             }
             if (isset($player_gear_base_item[$i]->abilitymodule_id)) {
                 //we has an ability
                 $temp_ability_id = $player_gear_base_item[$i]->attributes['itemtypeid'];
                 $player_equipped_ability_info = AbilityModule::where(function ($query) use($temp_ability_id) {
                     $query->where('itemTypeId', '=', $temp_ability_id);
                     $query->where('version', '=', Base_Controller::getVersionDate());
                 })->first();
                 $ability_base_info_reqs = hConstraint::where(function ($query) use($temp_ability_id) {
                     $query->where('itemTypeId', '=', $temp_ability_id);
                     $query->where('version', '=', Base_Controller::getVersionDate());
                 })->first();
                 //Add check to see if slot index is 5 or higher
                 $player_item_abilities[$ability_counter]['asset_path'] = $player_gear_base_item[$i]->asset_path;
                 $player_item_abilities[$ability_counter]['name'] = $player_equipped_ability_info->attributes['name'];
                 $player_item_abilities[$ability_counter]['desc'] = $player_equipped_ability_info->attributes['description'];
                 //Add check to see if durability is over 1,000
                 if (isset($loadout->Gear[$i]->info->durability)) {
                     $player_item_abilities[$ability_counter]['durability'] = $loadout->Gear[$i]->info->durability;
                 } else {
                     $player_item_abilities[$ability_counter]['durability'] = null;
                 }
                 //Add check to see if quality is over 1,000
                 $player_item_abilities[$ability_counter]['quality'] = $loadout->Gear[$i]->info->quality;
                 $player_item_abilities[$ability_counter]['quality_color'] = quality_control($loadout->Gear[$i]->info->quality);
                 if (isset($loadout->Gear[$i]->info->attribute_modifiers)) {
                     $player_item_abilities[$ability_counter]['attribute_modifiers'] = $loadout->Gear[$i]->info->attribute_modifiers;
                 } else {
                     $player_item_abilities[$ability_counter]['attribute_modifiers'] = null;
                 }
                 //Add check to see if allocated power is over 100
                 $player_item_abilities[$ability_counter]['allocated_power'] = $loadout->Gear[$i]->allocated_power;
                 $player_item_abilities[$ability_counter]['base_constraint_info'] = $ability_base_info_reqs->attributes;
                 $ability_counter++;
             }
             if (isset($player_gear_base_item[$i]->framemodule_id) && !in_array($player_gear_base_item[$i]->attributes['itemtypeid'], $processor_framemods)) {
                 //we has frame mod
                 if ($gear_counter < 9) {
                     $temp_framemod_id = $player_gear_base_item[$i]->attributes['itemtypeid'];
                     $player_equipped_gear_info = FrameModule::where(function ($query) use($temp_framemod_id) {
                         $query->where('itemTypeId', '=', $temp_framemod_id);
                         $query->where('version', '=', Base_Controller::getVersionDate());
                     })->first();
                     $gear_base_info_reqs = hConstraint::where(function ($query) use($temp_framemod_id) {
                         $query->where('itemTypeId', '=', $temp_framemod_id);
                         $query->where('version', '=', Base_Controller::getVersionDate());
                     })->first();
                     $player_item_gear[$gear_counter]['asset_path'] = $player_gear_base_item[$i]->asset_path;
                     $player_item_gear[$gear_counter]['name'] = $player_equipped_gear_info->attributes['name'];
                     $player_item_gear[$gear_counter]['desc'] = $player_equipped_gear_info->attributes['description'];
                     //assume zero if null.
                     if (isset($loadout->Gear[$i]->info->quality)) {
                         $player_item_gear[$gear_counter]['quality'] = $loadout->Gear[$i]->info->quality;
                     } else {
                         $player_item_gear[$gear_counter]['quality'] = 0;
                     }
                     $player_item_gear[$gear_counter]['quality_color'] = quality_control($loadout->Gear[$i]->info->quality);
                     if (isset($loadout->Gear[$i]->info->durability)) {
                         $player_item_gear[$gear_counter]['durability'] = $loadout->Gear[$i]->info->durability;
                     } else {
                         $player_item_gear[$gear_counter]['durability'] = null;
                     }
                     if (isset($loadout->Gear[$i]->info->attribute_modifiers)) {
                         $player_item_gear[$gear_counter]['attribute_modifiers'] = $loadout->Gear[$i]->info->attribute_modifiers;
                     } else {
                         $player_item_gear[$gear_counter]['attribute_modifiers'] = null;
                     }
                     $player_item_gear[$gear_counter]['base_constraint_info'] = $gear_base_info_reqs->attributes;
                     $gear_counter++;
                 } else {
                     Log::warn("Player ({$player->db_id}) has more than eight frame items in loadouts: " . $player_gear_base_item[$i]);
                 }
             }
             if (isset($player_gear_base_item[$i]->weapon_id)) {
                 //we has weapon
                 if ($weapon_counter < 2) {
                     $temp_weapon_id = $player_gear_base_item[$i]->attributes['itemtypeid'];
                     $player_equipped_weapon_info = Weapon::where(function ($query) use($temp_weapon_id) {
                         $query->where('itemTypeId', '=', $temp_weapon_id);
                         $query->where('version', '=', Base_Controller::getVersionDate());
                     })->first();
                     $weapon_base_info = hStat::where(function ($query) use($temp_weapon_id) {
                         $query->where('itemTypeId', '=', $temp_weapon_id);
                         $query->where('version', '=', Base_Controller::getVersionDate());
                     })->first();
                     $weapon_base_info_reqs = hConstraint::where(function ($query) use($temp_weapon_id) {
                         $query->where('itemTypeId', '=', $temp_weapon_id);
                         $query->where('version', '=', Base_Controller::getVersionDate());
                     })->first();
                     $player_item_weapons[$weapon_counter]['asset_path'] = $player_gear_base_item[$i]->asset_path;
                     $player_item_weapons[$weapon_counter]['name'] = $player_equipped_weapon_info->attributes['name'];
                     $player_item_weapons[$weapon_counter]['desc'] = $player_equipped_weapon_info->attributes['description'];
                     if (isset($loadout->Weapons[$weapon_counter]->info->durability)) {
                         $player_item_weapons[$weapon_counter]['durability'] = $loadout->Weapons[$weapon_counter]->info->durability;
                     } else {
                         $player_item_weapons[$weapon_counter]['durability'] = null;
                     }
                     $player_item_weapons[$weapon_counter]['quality'] = $loadout->Weapons[$weapon_counter]->info->quality;
                     $player_item_weapons[$weapon_counter]['quality_color'] = quality_control($loadout->Weapons[$weapon_counter]->info->quality);
                     if (isset($loadout->Weapons[$weapon_counter]->info->attribute_modifiers)) {
                         $player_item_weapons[$weapon_counter]['attribute_modifiers'] = $loadout->Weapons[$weapon_counter]->info->attribute_modifiers;
                     } else {
                         $player_item_weapons[$weapon_counter]['attribute_modifiers'] = null;
                     }
                     $player_item_weapons[$weapon_counter]['base_info'] = $weapon_base_info->attributes;
                     $player_item_weapons[$weapon_counter]['base_constraint_info'] = $weapon_base_info_reqs->attributes;
                     $player_item_weapons[$weapon_counter]['allocated_power'] = $loadout->Weapons[$weapon_counter]->allocated_power;
                     $weapon_counter++;
                 } else {
                     Log::warn("Player ({$player->db_id}) has more than two weapons in loadouts: " . $player_gear_base_item[$i]);
                 }
             }
         }
         //cache the loadout md5
         Cache::forever($cache_key_loadouts . "_" . $chassis_id . "_md5", md5(serialize($loadout)));
         //cache the rest of the loadout to seperate files for easy loading
         Cache::forever($cache_key_loadouts . "_" . $chassis_id . "_abilities", $player_item_abilities);
         Cache::forever($cache_key_loadouts . "_" . $chassis_id . "_gear", $player_item_gear);
         Cache::forever($cache_key_loadouts . "_" . $chassis_id . "_weapons", $player_item_weapons);
     }
     return View::make('player.player_profile_chassis')->with(compact('player_item_abilities'))->with(compact('player_item_gear'))->with(compact('player_item_weapons'));
 }