private function handleNewShipSlotitem() { foreach ($this->new as $new) { try { $ship = Util::load("ship/{$new}.json"); } catch (FileNotFoundException $e) { $this->error("{$new} not found.."); } $sortno = $ship['sort_no']; $this->info("【{$ship['name']}】"); $record = InitEquip::where('sortno', $sortno)->first(); if ($record) { $this->info($this->getSlotItemNameById($record->slot1)); $this->info($this->getSlotItemNameById($record->slot2)); $this->info($this->getSlotItemNameById($record->slot3)); $this->info($this->getSlotItemNameById($record->slot4)); $this->info($this->getSlotItemNameById($record->slot5)); } else { $this->error("database did not has {$ship['name']} data"); } } $this->info('Done.'); }
use Illuminate\Contracts\Filesystem\FileNotFoundException; use App\Util; // Api Start2 $app->post('/start2/upload', function (Request $request) { $rules = ['password' => 'required|alpha_dash|between:5,50', 'data' => 'required|json']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return Util::errorResponse('data invalid'); } $inputs = $request->all(); if (env('ADMIN_PASSWORD', 'admin') !== $inputs['password']) { return Util::errorResponse('incorrect password'); } $start2 = json_decode($inputs['data'], true); if (Util::exists('api_start2.json')) { $data = Util::load('api_start2.json'); if (Util::compareJson($data, $start2)) { return Util::errorResponse('duplicate start2 data'); } } Util::dump('api_start2.json', $start2); $datetime = new DateTime(); $today = $datetime->format('YmdH'); Util::dump("start2/{$today}.json", $start2); Queue::push(function ($job) { Artisan::call('parse:start2'); $job->delete(); }); return Util::successResponse(); }); $app->get('/start2', function () {
} $inputs = $request->all(); $dantan = array_key_exists('dantan', $inputs) ? $inputs['dantan'] : false; foreach ($inputs['eventId'] as $eventno => $event) { MapEvent::create(['mapAreaId' => $inputs['mapAreaId'], 'mapId' => $inputs['mapId'], 'cellId' => $inputs['cellId'], 'eventId' => $event, 'eventType' => $inputs['eventType'], 'count' => $inputs['count'][$eventno], 'dantan' => $dantan]); } return response()->json(['result' => 'success']); }]); $app->get('/map/max/hp', ['middleware' => 'report-cache', function (Request $request) { $rules = ['mapAreaId' => 'required|digits_between:1,3', 'mapId' => 'required|digits_between:1,3', 'maxHp' => 'required|digits_between:1,10', 'lv' => 'required|digits_between:1,4']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(['result' => 'error', 'reason' => 'Data invalid']); } $inputs = $request->all(); MapMaxHp::create(['mapAreaId' => $inputs['mapAreaId'], 'mapId' => $inputs['mapId'], 'maxHp' => $inputs['maxHp'], 'lv' => $inputs['lv']]); return response()->json(['result' => 'success']); }]); // Report Results $app->get('/report/enemies', ['middleware' => 'cache', function () { $raw = Util::load('report/enemy.json'); return $raw; }]); $app->get('/report/new', ['middleware' => 'cache', function () { $raw = Util::load('report/new.json'); return $raw; }]); $app->get('/report/tyku', ['middleware' => 'cache', function () { $raw = Util::load('report/tyku.json'); return $raw; }]);