63, '저'=>64, '흉노'=>65, '남만'=>66, '산월'=>67, '오환'=>68, '왜'=>69 ]; public function __construct( $npcEachCount = -0.5, int $specAvg = 150, int $specDist = 20, int $tech = -1, int $dex = 0 ){ $this->npcEachCount = $npcEachCount; $this->specAvg = $specAvg; $this->specDist = $specDist; $this->tech = $tech; $this->dex = $dex; if($specDist < 0){ throw new \InvalidArgumentException('specDist는 음수를 지원하지 않습니다.'); } } private function moveCapital(){ $cities = array_map(function ($value) { return $value; }, static::INVADER_LIST); $db = DB::db(); foreach($db->queryFirstColumn('SELECT capital, nation from nation WHERE capital in %li', $cities) as $row){ list($oldCapital, $nation) = $row; $newCapital = $db->queryFirstRow('SELECT city from city where nation=%i and city !=%i \ order by rand() limit 1', $nation, $oldCapital); $db->update('nation', ['capital'=>$newCapital], 'nation=%i', $nation); $db->update('general', ['city'=>$newCapital], 'nation=%i and city=%i', $nation, $oldCapital); } $db->update('general', [ 'officer_level'=>1, 'officer_city'=>0 ], 'officer_city in %li', $cities); $db->update('city', [ 'nation'=>0 ], 'city in %li', $cities); } public function run($env=null){ $db = DB::db(); $npcEachCount = $this->npcEachCount; if($npcEachCount < 0){ $npcEachCount = $db->queryFirstField('SELECT count(no) from general where npc < 9') / count(self::INVADER_LIST); $npcEachCount /= -1 * $this->npcEachCount; } $specAvg = $this->specAvg; if($specAvg < 0){ $specAvg = $db->queryFirstField('SELECT avg(sum(`leadership` + `strength` + `intel`)) from general where npc < 9'); $specAvg /= -1 * $this->specAvg; } $tech = $this->tech; if($tech < 0){ $tech = $db->queryFirstField("SELECT avg(tech) from nation where `level`>0"); $tech /= -1 * $this->tech; } $dex = $this->dex; if($dex < 0){ $dex = $db->queryFirstField("SELECT avg(dex1 + dex2 + dex3 + dex4 + dex5)/5 from nation where `level`>0"); $dex /= -1 * $this->dex; } $this->moveCapital(); //TODO:국가를 만들고 //TODO:장수를 세팅하고 //TODO:외교를 설정한다. //TODO: 시나리오 구현 후 마무리. //TODO: 임관 모드가 '랜임모드'인 경우 오랑캐와 충돌하므로 해제해야함. return [__CLASS__, 'NYI']; } }