From 645c5cc6c11d1ae6c35073fc66a388533d0d698a Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 10 May 2020 04:29:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B8=ED=83=90=20=ED=99=95=EB=A5=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Command/General/che_인재탐색.php | 53 ++++++++++++++-------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/hwe/sammo/Command/General/che_인재탐색.php b/hwe/sammo/Command/General/che_인재탐색.php index 8ed2e2c0..2370fc39 100644 --- a/hwe/sammo/Command/General/che_인재탐색.php +++ b/hwe/sammo/Command/General/che_인재탐색.php @@ -57,9 +57,19 @@ class che_인재탐색 extends Command\GeneralCommand{ } public function getCommandDetailTitle():string{ + $db = DB::db(); + $env = $this->env; + + $maxGenCnt = $env['maxgeneral']; + $totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2'); + $totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4'); + $name = $this->getName(); [$reqGold, $reqRice] = $this->getCost(); + $foundProp = $this->calcFoundProp($maxGenCnt, $totalGenCnt, $totalNpcCnt); + $foundPropText = number_format($foundProp*100, 1); + $title = "{$name}(랜덤경험"; if($reqGold > 0){ $title .= ", 자금{$reqGold}"; @@ -67,7 +77,8 @@ class che_인재탐색 extends Command\GeneralCommand{ if($reqRice > 0){ $title .= ", 군량{$reqRice}"; } - $title .= ')'; + + $title .= ", 확률 {$foundPropText}%)"; return $title; } @@ -83,6 +94,28 @@ class che_인재탐색 extends Command\GeneralCommand{ return 0; } + public function calcFoundProp(int $maxGenCnt, int $totalGenCnt, int $totalNpcCnt):float{ + + + $currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2); + $remainSlot = $maxGenCnt - $currCnt; + if($remainSlot < 0){ + $remainSlot = 0; + } + + $foundPropMain = pow($remainSlot / $maxGenCnt, 6); + $foundPropSmall = 1 / ($totalNpcCnt / 3 + 1); + $foundPropBig = 1 / $maxGenCnt; + + if($totalNpcCnt < 50){ + $foundProp = max($foundPropMain, $foundPropSmall); + } + else{ + $foundProp = max($foundPropMain, $foundPropBig); + } + return $foundProp; + } + public function run():bool{ if(!$this->hasFullConditionMet()){ throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); @@ -97,7 +130,6 @@ class che_인재탐색 extends Command\GeneralCommand{ $nationID = $general->getNationID(); - $maxGenCnt = $env['maxgeneral']; $nationCnt = count(getAllNationStaticInfo()); $totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2'); @@ -107,24 +139,9 @@ class che_인재탐색 extends Command\GeneralCommand{ $npcCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND 3 <= npc AND npc <= 4', $nationID); $currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2); - $remainSlot = $maxGenCnt - $currCnt; - if($remainSlot < 0){ - $remainSlot = 0; - } - $avgCnt = $currCnt / $nationCnt; - $foundPropMain = pow($remainSlot / $maxGenCnt, 6); - $foundPropSmall = 1 / ($totalNpcCnt / 3 + 1); - $foundPropBig = 1 / $maxGenCnt; - - if($totalNpcCnt < 50){ - $foundProp = max($foundPropMain, $foundPropSmall); - } - else{ - $foundProp = max($foundPropMain, $foundPropBig); - } - $foundNpc = Util::randBool($foundProp); + $foundNpc = Util::randBool($this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt)); $logger = $general->getLogger();