From 6c185ffd09c721bfc1fa70d7af4aae1e91abcfbd Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 22 Mar 2020 03:17:05 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=84=EB=9E=B5=20DetailTitle/=20isReservabl?= =?UTF-8?q?e=20=EC=99=84=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_processing.php | 4 +- hwe/func_command.php | 10 +- hwe/sammo/Command/Nation/che_수몰.php | 8 + hwe/sammo/Command/Nation/che_의병모집.php | 287 ++++++++++++++++++++++ hwe/sammo/Command/Nation/che_피장파장.php | 8 + hwe/sammo/Command/Nation/che_필사즉생.php | 8 + hwe/sammo/Command/Nation/che_허보.php | 8 + 7 files changed, 327 insertions(+), 6 deletions(-) create mode 100644 hwe/sammo/Command/Nation/che_의병모집.php diff --git a/hwe/b_processing.php b/hwe/b_processing.php index 814a6a88..e3838bb3 100644 --- a/hwe/b_processing.php +++ b/hwe/b_processing.php @@ -59,9 +59,9 @@ if($commandObj->isArgValid()){ die_redirect(); } -if(!$commandObj->isReservable()){ +/*if(!$commandObj->isReservable()){ die_redirect(); -} +}*/ $jsList = $commandObj->getJSFiles(); $cssList = $commandObj->getCSSFiles(); diff --git a/hwe/func_command.php b/hwe/func_command.php index 11afbea5..7b8013b1 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -319,14 +319,14 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command, ]; } - if(!$commandObj->isReservable()){ + /*if(!$commandObj->isReservable()){ return [ 'result'=>false, 'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testReservable(), 'test'=>'isReservable', 'target'=>'command' ]; - } + }*/ $brief = $commandObj->getBrief(); @@ -401,14 +401,16 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr ]; } - if(!$commandObj->isReservable()){ + /*if(!$commandObj->isReservable()){ return [ 'result'=>false, 'reason'=>'예약 불가능한 커맨드 :'.$commandObj->testReservable(), 'test'=>'isReservable', 'target'=>'command' ]; - } + }*/ + //TODO: Reservable은 '정말로 입력 불가'이고, '입력은 가능하지만 실행은 안될 것 같은' 군을 하나더 추가해야함 + // Runnable은 Arg를 모두 받아서 처리해야 하는 것이고, Arg를 받지 않아도 안될 것 같지만 입력 자체는 가능할 것 같은 커맨드. $brief = $commandObj->getBrief(); diff --git a/hwe/sammo/Command/Nation/che_수몰.php b/hwe/sammo/Command/Nation/che_수몰.php index 22f9385c..d7f94a03 100644 --- a/hwe/sammo/Command/Nation/che_수몰.php +++ b/hwe/sammo/Command/Nation/che_수몰.php @@ -65,6 +65,14 @@ class che_수몰 extends Command\NationCommand{ ConstraintHelper::AvailableStrategicCommand(), ]; } + + public function getCommandDetailTitle():string{ + $name = $this->getName(); + $reqTurn = $this->getPreReqTurn()+1; + $postReqTurn = $this->getPostReqTurn(); + + return "{$name}/{$reqTurn}턴(전략$postReqTurn)"; + } public function getCost():array{ return [0, 0]; diff --git a/hwe/sammo/Command/Nation/che_의병모집.php b/hwe/sammo/Command/Nation/che_의병모집.php new file mode 100644 index 00000000..552288b0 --- /dev/null +++ b/hwe/sammo/Command/Nation/che_의병모집.php @@ -0,0 +1,287 @@ +arg = null; + return true; + } + + protected function init(){ + + $general = $this->generalObj; + + $this->setNation(['gennum', 'scout']); + $env = $this->env; + $relYear = $env['year'] - $env['startyear']; + + [$reqGold, $reqRice] = $this->getCost(); + + if($relYear < 3){ + $this->runnableConstraints = [ + ConstraintHelper::AlwaysFail('현재 초반 제한중입니다.') + ]; + return; + } + + $this->runnableConstraints=[ + ConstraintHelper::BeChief(), + ConstraintHelper::NotBeNeutral(), + ConstraintHelper::OccupiedCity(), + ConstraintHelper::AvailableStrategicCommand() + ]; + } + + public function getCommandDetailTitle():string{ + $name = $this->getName(); + $reqTurn = $this->getPreReqTurn()+1; + $postReqTurn = $this->getPostReqTurn(); + + return "{$name}/{$reqTurn}턴(전략$postReqTurn)"; + } + + public function getCost():array{ + return [0, 0]; + } + + public function getPreReqTurn():int{ + return 2; + } + + public function getPostReqTurn():int{ + $genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit); + $nextTerm = Util::round(sqrt($genCount*10)*10); + + $nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm); + return $nextTerm; + } + + public function run():bool{ + if(!$this->isRunnable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + $env = $this->env; + + $general = $this->generalObj; + $date = $general->getTurnTime($general::TURNTIME_HM); + + $nationID = $general->getNationID(); + + $genCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID); + $npcCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc = 3', $nationID); + $npcOtherCount = $db->queryFirstField('SELECT count(no) FROM general WHERE nation!=%i AND npc = 3', $nationID); + + + $genCount = Util::valueFit($genCount, 1); + $npcCount = Util::valueFit($npcCount, 1); + $npcOtherCountScore = Util::round(sqrt($npcOtherCount + 1)) - 1; + + //TODO: 수식 재 설계 + $randPick = 1 / (sqrt($genCount * $npcCount * $npcCount) + $npcOtherCount); + + $logger = $general->getLogger(); + + if(!Util::randBool($randPick)){ + $logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date"); + + $incStat = Util::choiceRandomUsingWeight([ + 'leadership2'=>$general->getLeadership(false, false, false, false), + 'strength2'=>$general->getStrength(false, false, false, false), + 'intel2'=>$general->getIntel(false, false, false, false) + ]); + [$reqGold, $reqRice] = $this->getCost(); + + $exp = 100; + $ded = 70; + + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); + + $general->increaseVarWithLimit('gold', -$reqGold, 0); + $general->increaseVarWithLimit('rice', -$reqRice, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVar($incStat, 1); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); + return true; + } + //인간적으로 너무 길어서 끊었다! + + $exp = 200; + $ded = 300; + + if($env['scenario'] < 100){ + $pickTypeList = ['무'=>4, '지'=>6]; + } + else{ + $pickTypeList = ['무'=>4, '지'=>4, '무지'=>2]; + } + + $pickType = Util::choiceRandomUsingWeightPair($pickTypeList); + + $mainStat = GameConst::$defaultStatMax - Util::randRangeInt(0, 10); + $otherStat = GameConst::$defaultStatMin + Util::randRangeInt(0, 5); + $subStat = GameConst::$defaultStatTotal - $mainStat - $otherStat; + if($subStat < GameConst::$defaultStatMin){ + $subStat = $otherStat; + $otherStat = GameConst::$defaultStatMin; + $mainStat = GameConst::$defaultStatTotal - $subStat - $otherStat; + if($mainStat){ + throw new \LogicException('기본 스탯 설정값이 잘못되어 있음'); + } + } + + $avgGen = $db->queryFirstRow( + 'SELECT max(leadership+strength+intel) as stat_sum, avg(dedication) as ded,avg(experience) as exp, + avg(dex0) as dex0, avg(dex10) as dex10, avg(dex20) as dex20, avg(dex30) as dex30, avg(dex40) as dex40 + from general where nation=%i', + $nationID + ); + + if($pickType == '무'){ + $leadership = $subStat; + $strength = $mainStat; + $intel = $otherStat; + } + else if($pickType == '지'){ + $leadership = $subStat; + $strength = $otherStat; + $intel = $mainStat; + } + else{ + $leadership = $otherStat; + $strength = $subStat; + $intel = $mainStat; + } + + // 국내 최고능치 기준으로 랜덤성 스케일링 + $maxLPI = $avgGen['stat_sum']; + if($maxLPI > 210) { + $leadership *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.6, 0.9); + $strength *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.6, 0.9); + $intel *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.6, 0.9); + } elseif($maxLPI > 180) { + $leadership *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.75, 0.95); + $strength *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.75, 0.95); + $intel *= $avgGen['stat_sum'] / GameConst::$defaultStatTotal * Util::randRange(0.75, 0.95); + } else { + $leadership *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.9, 1); + $strength *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.9, 1); + $intel *= $maxLPI / GameConst::$defaultStatTotal * Util::randRange(0.9, 1); + } + $leadership = Util::round($leadership); + $strength = Util::round($strength); + $intel = Util::round($intel); + + $isOurNation = $this->nation['scout'] == 0; + + $age = $env['year'] - 20; + + $newNPC = new \sammo\Scenario\NPC( + Util::randRangeInt(1, 150), + \sammo\getRandGenName(), + null, + $isOurNation?$nationID:0, + $general->getCityID(), + $leadership, + $strength, + $intel, + $isOurNation?1:0, + $age, + $env['year'] + Util::randRangeInt(10, 50), + null, + null + ); + $newNPC->npc = 3; + $newNPC->setMoney(100, 100); + $newNPC->setExpDed($avgGen['exp'], $avgGen['ded']); + $newNPC->setSpecYear( + Util::round((80 - $age)/12) + $age, + Util::round((80 - $age)/3) + $age + ); + $newNPC->setDex( + $avgGen['dex0'], + $avgGen['dex10'], + $avgGen['dex20'], + $avgGen['dex30'], + $avgGen['dex40'] + ); + + $newNPC->build($this->env); + $npcName = $newNPC->realName; + $josaRa = JosaUtil::pick($npcName, '라'); + + if($isOurNation){ + $scoutType = '영입'; + $db->update('nation', [ + 'gennum'=>$db->sqleval('gennum + 1') + ], 'nation=%i', $nationID); + } + else{ + $scoutType = '발견'; + } + + $generalName = $general->getName(); + $josaYi = JosaUtil::pick($generalName, '이'); + + $logger->pushGeneralActionLog("$npcName{$josaRa}는 인재를 {$scoutType}하였습니다! <1>$date"); + $logger->pushGlobalActionLog("{$generalName}{$josaYi} $npcName{$josaRa}는 인재를 {$scoutType}하였습니다!"); + $logger->pushGeneralHistoryLog("$npcName{$josaRa}는 인재를 {$scoutType}"); + + $incStat = Util::choiceRandomUsingWeight([ + 'leadership2'=>$general->getLeadership(false, false, false, false), + 'strength2'=>$general->getStrength(false, false, false, false), + 'intel2'=>$general->getIntel(false, false, false, false) + ]); + [$reqGold, $reqRice] = $this->getCost(); + + $exp = 200; + $ded = 300; + + $exp = $general->onCalcStat($general, 'experience', $exp); + $ded = $general->onCalcStat($general, 'dedication', $ded); + + $general->increaseVarWithLimit('gold', -$reqGold, 0); + $general->increaseVarWithLimit('rice', -$reqRice, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVar($incStat, 3); + $general->setResultTurn(new LastTurn(static::getName(), $this->arg)); + $general->checkStatChange(); + tryUniqueItemLottery($general); + $general->applyDB($db); + return true; + + return true; + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Command/Nation/che_피장파장.php b/hwe/sammo/Command/Nation/che_피장파장.php index ec2c5ca4..671a0751 100644 --- a/hwe/sammo/Command/Nation/che_피장파장.php +++ b/hwe/sammo/Command/Nation/che_피장파장.php @@ -74,6 +74,14 @@ class che_피장파장 extends Command\NationCommand{ } + public function getCommandDetailTitle():string{ + $name = $this->getName(); + $reqTurn = $this->getPreReqTurn()+1; + $postReqTurn = $this->getPostReqTurn(); + + return "{$name}/{$reqTurn}턴(전략$postReqTurn)"; + } + public function getCost():array{ return [0, 0]; } diff --git a/hwe/sammo/Command/Nation/che_필사즉생.php b/hwe/sammo/Command/Nation/che_필사즉생.php index ff047fb2..fb979e6d 100644 --- a/hwe/sammo/Command/Nation/che_필사즉생.php +++ b/hwe/sammo/Command/Nation/che_필사즉생.php @@ -52,6 +52,14 @@ class che_필사즉생 extends Command\NationCommand{ ]; } + public function getCommandDetailTitle():string{ + $name = $this->getName(); + $reqTurn = $this->getPreReqTurn()+1; + $postReqTurn = $this->getPostReqTurn(); + + return "{$name}/{$reqTurn}턴(전략$postReqTurn)"; + } + public function getCost():array{ return [0, 0]; } diff --git a/hwe/sammo/Command/Nation/che_허보.php b/hwe/sammo/Command/Nation/che_허보.php index 498a7608..6482115f 100644 --- a/hwe/sammo/Command/Nation/che_허보.php +++ b/hwe/sammo/Command/Nation/che_허보.php @@ -68,6 +68,14 @@ class che_허보 extends Command\NationCommand{ ConstraintHelper::AvailableStrategicCommand(), ]; } + + public function getCommandDetailTitle():string{ + $name = $this->getName(); + $reqTurn = $this->getPreReqTurn()+1; + $postReqTurn = $this->getPostReqTurn(); + + return "{$name}/{$reqTurn}턴(전략$postReqTurn)"; + } public function getCost():array{ return [0, 0];