コード例 #1
0
 public function getIndex($advanced = false)
 {
     $crafting_job_ids = Config::get('site.job_ids.crafting');
     // ini_set('xdebug.var_display_max_depth', '10');
     // dd(current(ClassJob::with('name', 'en_abbr')->whereIn('id', $crafting_job_ids)->get()));
     return View::make('crafting.' . ($advanced ? 'advanced' : 'basic'))->with('error', FALSE)->with('active', 'crafting')->with('job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $crafting_job_ids)->get())->with('crafting_job_ids', $crafting_job_ids)->with('previous', Cookie::get('previous_crafting_load'));
 }
コード例 #2
0
 public static function get_abbr_list($ids = array())
 {
     $all_jobs = ClassJob::with('abbr')->whereIn('id', $ids)->get();
     $return = array();
     foreach ($all_jobs as $job) {
         $return[] = $job->abbr->term;
     }
     return $return;
 }
コード例 #3
0
 public function getIndex()
 {
     $account = Session::get('account');
     if (empty($account)) {
         return Redirect::to('/account/login');
     }
     $job_ids = Config::get('site.job_ids');
     return View::make('account.index')->with('crafting_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['crafting'])->get())->with('gathering_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['gathering'])->get())->with('melee_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['basic_melee'])->get())->with('magic_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['basic_magic'])->get());
 }
コード例 #4
0
 public function getIndex()
 {
     $job_ids = Config::get('site.job_ids.crafting');
     $job_ids[] = Config::get('site.job_ids.fishing');
     $type_to_icon = array('Field' => 'leaf', 'Courier' => 'envelope', 'Reverse Courier' => 'plane', 'Town' => 'home');
     // All Leves
     $all_leves = Leve::with(array('classjob', 'classjob.en_abbr', 'item', 'item.name', 'item.recipe', 'item.vendors'))->where('item_id', '>', 0)->orderBy('classjob_id')->orderBy('level')->orderBy('triple', 'desc')->orderBy('xp', 'desc')->orderBy('gil', 'desc')->get();
     $leves = array();
     foreach ($all_leves as $leve) {
         $leves[$leve->classjob->en_abbr->term][$leve->level][] = $leve;
     }
     $rewards = LeveReward::with('item')->orderBy('classjob_id')->orderBy('level')->orderBy('item_id')->orderBy('amount')->get();
     $leve_rewards = array();
     foreach ($rewards as $reward) {
         if ($reward->item_id) {
             $leve_rewards[$reward->classjob_id][$reward->level][$reward->item_id]['item'] = $reward->item;
             $leve_rewards[$reward->classjob_id][$reward->level][$reward->item_id]['amounts'][] = $reward->amount;
         }
     }
     return View::make('levequests.index')->with('crafting_job_list', ClassJob::with('name', 'en_name', 'en_abbr')->whereIn('id', $job_ids)->get())->with('crafting_job_ids', $job_ids)->with('leves', $leves)->with('rewards', $leve_rewards)->with('type_to_icon', $type_to_icon)->with('opening_level', 1)->with('opening_class', 'CRP');
 }
コード例 #5
0
 public function getIndex()
 {
     // All Quests
     $quest_records = QuestItem::with('classjob', 'classjob.en_abbr', 'item', 'item.name', 'item.recipe')->orderBy('classjob_id')->orderBy('level')->orderBy('item_id')->get();
     $quests = array();
     foreach ($quest_records as $quest) {
         if (!isset($quests[$quest->classjob->en_abbr->term])) {
             $quests[$quest->classjob->en_abbr->term] = array();
         }
         if (empty($quest->item->recipe)) {
             var_dump($quest);
             exit;
         }
         foreach ($quest->item->recipe as $r) {
             if ($r->classjob_id == $quest->classjob_id) {
                 $quest->recipe = $r;
             }
         }
         $quests[$quest->classjob->en_abbr->term][] = $quest;
     }
     $job_ids = array_merge(Config::get('site.job_ids.crafting'), Config::get('site.job_ids.gathering'));
     return View::make('pages.quests')->with('quests', $quests)->with('job_ids', $job_ids)->with('job_list', ClassJob::with('name', 'en_abbr')->whereIn('id', $job_ids)->get());
 }
コード例 #6
0
 public function getIndex()
 {
     $job_ids = Config::get('site.job_ids');
     return View::make('equipment.index')->with('error', FALSE)->with('active', 'equipment')->with('crafting_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['crafting'])->get())->with('gathering_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['gathering'])->get())->with('basic_melee_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['basic_melee'])->get())->with('basic_magic_job_list', ClassJob::with('name', 'en_abbr', 'en_name')->whereIn('id', $job_ids['basic_magic'])->get())->with('job_ids', $job_ids)->with('previous', Cookie::get('previous_equipment_load'));
 }
コード例 #7
0
 public static function calculate($job_id = 0, $level = 1, $range = 0, $craftable_only = TRUE, $rewardable_too = TRUE)
 {
     $cache_key = __METHOD__ . '|' . Config::get('language') . '|' . $job_id . ',' . $level . ',' . $range . ($craftable_only ? 'T' . ($rewardable_too ? 'T' : 'F') : 'F');
     // Does cache exist?  Return that instead
     if (Cache::has($cache_key)) {
         return Cache::get($cache_key);
     }
     // Get the job IDs
     $job = ClassJob::with('en_abbr')->find($job_id);
     $equipment_list = array_flip(Config::get('site.equipment_roles'));
     array_walk($equipment_list, function (&$i) {
         $i = array();
     });
     // Slot data
     $slots = Config::get('site.defined_slots');
     $slot_alias = Config::get('site.slot_alias');
     $slot_cannot_equip = Config::get('site.slot_cannot_equip');
     foreach ($slot_cannot_equip as &$sce) {
         foreach ($sce as &$ce) {
             $ce = $slots[$ce];
         }
     }
     unset($sce, $ce);
     // Make sure the slot avoids pieces with certain stats
     $stat_ids_to_avoid = Stat::get_ids(Stat::avoid($job->en_abbr->term));
     $stat_ids_to_focus = Stat::get_ids(Stat::focus($job->en_abbr->term));
     $boring_stat_ids = Stat::get_ids(Stat::boring());
     $advanced_stat_avoidance = Stat::advanced_avoidance($job->en_abbr->term);
     foreach ($advanced_stat_avoidance as &$ava) {
         // These are in a very specific order.
         // Keep that order in tact.
         list($a, $b) = explode(' w/o ', $ava);
         $ava[0] = Stat::get_ids(array($a))[0];
         $ava[1] = Stat::get_ids(array($b))[0];
     }
     unset($ava);
     // Get all items where:
     // Slot isn't zero
     // It's between the level & level - 10
     // The class can use it
     // craftable only?
     // rewardable?
     foreach ($slots as $slot_identifier => $slot_name) {
         $query = Item::with('name', 'baseparam', 'baseparam.name', 'vendors', 'recipe', 'recipe.classjob', 'recipe.classjob.name')->where('slot', $slot_identifier)->whereBetween('equip_level', array($level - 10, $level + $range))->whereHas('classjob', function ($query) use($job_id) {
             $query->where('classjob.id', $job_id);
         })->whereHas('baseparam', function ($query) use($stat_ids_to_focus) {
             $query->whereIn('baseparam.id', $stat_ids_to_focus);
         })->orderBy('items.equip_level', 'DESC')->orderBy('items.level', 'DESC')->limit(20);
         if ($craftable_only && $rewardable_too) {
             $query->where(function ($query) {
                 $query->whereHas('recipe', function ($query) {
                     $query->where('recipes.item_id', DB::raw('items.id'));
                 })->orWhere('items.achievable', '1')->orWhere('items.rewarded', '1');
             });
         } elseif ($craftable_only) {
             $query->whereHas('recipe', function ($query) {
                 $query->where('recipes.item_id', DB::raw('items.id'));
             });
         }
         $items = $query->remember(Config::get('site.cache_length'))->get();
         $slot = isset($slot_alias[$slot_identifier]) ? $slot_alias[$slot_identifier] : $slot_identifier;
         $role = $slots[$slot];
         foreach ($items as $item) {
             // Kick it to the curb because of attributes?
             // Compare the focused vs the avoids
             $focus = $avoid = 0;
             $param_count = array_fill(1, 100, 0);
             // 73 total stats, 100's pretty safe, not to mention we only really focus on the first dozen
             foreach ($item->baseparam as $param) {
                 $param_count[$param->id]++;
                 if (in_array($param->id, $stat_ids_to_avoid)) {
                     $avoid++;
                 } elseif (in_array($param->id, $stat_ids_to_focus)) {
                     $focus++;
                 }
             }
             if ($advanced_stat_avoidance) {
                 foreach ($advanced_stat_avoidance as $ava) {
                     // If the [0] stat exists, but the [1] stat doesn't, drop the piece completely
                     if ($param_count[$ava[0]] > 0 && $param_count[$ava[1]] == 0) {
                         $avoid += 10;
                     }
                 }
             }
             // Really sell that this should be avoided
             # echo '<strong>' . $item->name->term . ' [' . $item->id . ']</strong> for ' . $role . ' (' . $focus . ',' . $avoid . ')<br>';
             if ($avoid >= $focus || $focus == 0) {
                 continue;
             }
             // if ($item->name->term == 'Linen Cowl')
             // 	dd($item->name->term, $item->slot, $slot, $slot_cannot_equip, $slot_cannot_equip[$item->slot]);
             // Cannot equip attribute?
             if (isset($slot_cannot_equip[$item->slot])) {
                 $item->cannot_equip = implode(',', $slot_cannot_equip[$item->slot]);
             }
             $equipment_list[$role][] = $item;
             # echo '<strong>+ ' . $item->name->term . ' [' . $item->id . ']</strong> for ' . $role . '<br>';
         }
         unset($items);
     }
     $two_handed_weapon_ids = ItemUICategory::two_handed_weapon_ids();
     $leveled_equipment = array();
     // We now have a proper list, but now we need to widdle down further by ilvl
     foreach (range($level, $level + $range) as $l) {
         $leveled_equipment[$l] = array();
         foreach ($equipment_list as $role => $items) {
             $leveled_equipment[$l][$role] = array();
             $max_equip_level = 0;
             // Find max
             foreach ($items as $item) {
                 if ($item->equip_level <= $l && $item->equip_level > $max_equip_level) {
                     $max_equip_level = $item->equip_level;
                 }
             }
             // Drop lesser items
             // OR figure out cannot equip stuff for weapons
             foreach ($items as $key => $item) {
                 if ($item->equip_level == $max_equip_level) {
                     if (empty($item->cannot_equip) && in_array($item->itemuicategory_id, $two_handed_weapon_ids)) {
                         $item->cannot_equip = 'Off Hand';
                     }
                     //$item->cannot_equip = array_flip(Config::get('site.defined_slots'))['Off Hand'];
                     if (!isset($leveled_equipment[$l][$role][$item->level])) {
                         $leveled_equipment[$l][$role][$item->level] = array();
                     }
                     $leveled_equipment[$l][$role][$item->level][] = $item;
                 }
             }
             // Place highest ilvl first
             krsort($leveled_equipment[$l][$role]);
             // Re-key the list for good measure
             //$items = array_values($items);
             //$leveled_equipment[$l][$role] = $items;
         }
     }
     // We should mostly have a list of just single items now
     // Cache the results
     Cache::put($cache_key, $leveled_equipment, Config::get('site.cache_length'));
     return $leveled_equipment;
 }
コード例 #8
0
 public function getIndex()
 {
     $random_list = Recipes::with('item', 'item.name')->select('*', 'recipes.id AS recipe_id')->join('items AS i', 'i.id', '=', 'recipes.item_id')->join('translations AS t', 't.id', '=', 'i.name_' . Config::get('language'))->orderBy(DB::raw('RAND()'))->paginate(10);
     return View::make('recipes.index')->with('list', $random_list)->with('crafting_job_list', ClassJob::with('name', 'en_abbr')->whereIn('id', Config::get('site.job_ids.crafting'))->get())->with('job_list', ClassJob::get_name_abbr_list());
 }
コード例 #9
0
 public function getGathering($my_class = '', $supported_classes = '', $min_level = 0, $max_level = 0)
 {
     $supported_classes = explode(',', $supported_classes);
     $show_quests = in_array($my_class, $supported_classes);
     if (empty($supported_classes)) {
         exit('No supported class selected... Todo: real error');
     }
     // TODO
     $all_classes = ClassJob::get_id_abbr_list();
     foreach ($supported_classes as $k => $v) {
         if (in_array($v, array_keys($all_classes))) {
             $supported_classes[$k] = $all_classes[$v];
         } else {
             unset($supported_classes[$k]);
         }
     }
     if (empty($supported_classes)) {
         exit('No supported class recognized...');
     }
     // TODO
     $jobs = ClassJob::with('name')->whereIn('id', $supported_classes)->get();
     foreach ($jobs as $k => $v) {
         $jobs[$k] = $v->name->term;
     }
     if ($my_class != 'BTL') {
         $job = ClassJob::get_by_abbr($my_class);
     } else {
         $job = $my_class;
     }
     if (empty($job)) {
         exit('No primary class recognized...');
     }
     // TODO
     $top_query = $inner_query = $join = $where = $union = $having = '';
     $parameters = array();
     DB::statement('SET SESSION group_concat_max_len=16384');
     if (in_array($my_class, array('MIN', 'BTN'))) {
         // Add Nodes
         $top_query .= "\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tCOUNT(*)\n\t\t\t\t\t\tFROM `cluster_items` AS `ci`\n\t\t\t\t\t\tJOIN `clusters` AS `c` ON `c`.`id` = `ci`.`cluster_id`\n\t\t\t\t\t\tWHERE `c`.`classjob_id` = ? AND `ci`.`item_id` = `x`.`item_id`\n\t\t\t\t\t) AS nodes,\n\t\t\t";
         $parameters[] = $job->id;
         $having = "HAVING nodes > 0";
     } else {
         // Battling or Fishing
         $join = "LEFT JOIN `cluster_items` AS `ci` ON `ci`.`item_id` = `i`.`id` " . 'LEFT JOIN `item_ui_category` AS `iuc` ON `iuc`.`id` = `i`.`itemuicategory_id` ' . 'LEFT JOIN `translations` AS `iuct` ON `iuct`.`id` = `iuc`.`name_en`';
         // FSH where the item is "seafood"
         // BTL where the item is not "seafood"
         $where = "AND `iuct`.`term` " . ($my_class == 'BTL' ? '!' : '') . "= 'Seafood'";
         $where .= " AND `ci`.`id` IS NULL";
     }
     $parameters[] = $min_level;
     $parameters[] = $max_level;
     $parameters = array_merge($parameters, $supported_classes);
     if ($my_class != 'BTL') {
         $union = "\n\t\t\t\t\tUNION\n\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`i`.`id`, t.term AS name, `i`.level, `i`.`min_price`, qi.amount AS amount, \n\t\t\t\t\t\tqi.level AS quest_level, qi.quality AS quest_quality\n\t\t\t\t\tFROM quest_items AS qi\n\t\t\t\t\tJOIN items AS i ON i.id = qi.item_id\n\t\t\t\t\tJOIN classjob AS j ON j.id = qi.classjob_id\n\t\t\t\t\tJOIN translations AS t ON t.id = i.name_" . Config::get('language') . "\n\t\t\t\t\tWHERE j.id = ?\n\t\t\t\t\t\tAND qi.level BETWEEN ? AND ?\n\t\t\t";
         $parameters[] = $job->id;
         $parameters[] = $min_level;
         $parameters[] = $max_level;
     }
     // TODO Caching
     $results = DB::select("\n\t\t\tSELECT x.*,\n\t\t\t\t" . $top_query . "\n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM `items_npcs_shops` AS `ins`\n\t\t\t\t\tWHERE `ins`.`item_id` = `x`.`item_id`\n\t\t\t\t) AS vendors, \n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM `npcs_items` AS `ni`\n\t\t\t\t\tWHERE `ni`.`item_id` = `x`.`item_id`\n\t\t\t\t) AS beasts\n\t\t\tFROM (\n\t\t\t\tSELECT \n\t\t\t\t\t`i`.`id` AS `item_id`, t.term AS name, `i`.level, `i`.`min_price`, SUM(cj.amount) AS amount,\n\t\t\t\t\tNULL AS quest_level, NULL AS quest_quality\n\t\t\t\tFROM `careers` AS `c`\n\t\t\t\tJOIN `items` AS `i` ON `i`.`id` = `c`.`identifier`\n\t\t\t\tJOIN `career_classjob` AS `cj` ON `cj`.`career_id` = `c`.`id`\n\t\t\t\tJOIN translations AS t ON t.id = i.name_" . Config::get('language') . "\n\t\t\t\t" . $join . "\n\t\t\t\tWHERE\n\t\t\t\t\t`c`.`type` = 'item'\n\t\t\t\t\tAND `c`.`level` BETWEEN ? AND ?\n\t\t\t\t\tAND `cj`.`classjob_id` in (" . str_pad('', count($supported_classes) * 2 - 1, '?,') . ")\n\t\t\t\t\t" . $where . "\n\t\t\t\tGROUP BY `c`.`identifier`\n\n\t\t\t\t" . $union . "\n\t\t\t\t\n\t\t\t\tORDER BY `item_id` ASC\n\t\t\t) AS x\n\t\t\t" . $having, $parameters);
     if ($my_class != 'BTL') {
         $quest_results = array();
         // Rip out Quest Entries
         foreach ($results as $k => $result) {
             if ($result->quest_level != NULL) {
                 $quest_results[] = $result;
                 unset($results[$k]);
             }
         }
         // Put them back in, either merge or insert
         if ($show_quests) {
             foreach ($quest_results as $quest_item) {
                 foreach ($results as $k => $result) {
                     if ($quest_item->item_id == $result->item_id) {
                         // Merge
                         $original_amount = $result->amount;
                         $quest_amount = $quest_item->amount;
                         $results[$k] = $quest_item;
                         $results[$k]->amount = $original_amount;
                         $results[$k]->quest_amount = $quest_amount;
                         continue 2;
                     }
                 }
                 // If a match was found it would have continued
                 // This means at this point we add it in straight up
                 $quest_item->quest_amount = $quest_item->amount;
                 $results[] = $quest_item;
             }
         }
         // Fishing doesn't have an ilvl...
         if ($my_class != 'FSH') {
             $sortable_results = array();
             foreach ($results as $row) {
                 $sortable_results[$row->level][] = $row;
             }
             ksort($sortable_results);
             $results = array();
             foreach ($sortable_results as $rows) {
                 foreach ($rows as $row) {
                     $results[] = $row;
                 }
             }
             unset($sortable_results);
         }
     }
     return View::make('career.items')->with(array('items' => $results, 'show_quests' => $show_quests, 'jobs' => $jobs, 'job' => $job, 'min_level' => $min_level, 'max_level' => $max_level));
 }
コード例 #10
0
 public function getIndex()
 {
     $job_ids = Config::get('site.job_ids.crafting');
     $job_ids[] = Config::get('site.job_ids.fishing');
     return View::make('leve.index')->with('crafting_job_list', ClassJob::with('name', 'en_abbr')->whereIn('id', $job_ids)->get())->with('crafting_job_ids', $job_ids);
 }