From 732528ce85d3f2e736351de28a955aa52c64bb5b Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 15 Sep 2018 03:42:09 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=B4=EC=A0=95=20=EC=BB=A4=EB=A7=A8?= =?UTF-8?q?=EB=93=9C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95,=20?= =?UTF-8?q?=EC=A0=95=EC=B0=A9=EC=9E=A5=EB=A0=A4,=20=EC=A3=BC=EB=AF=BC?= =?UTF-8?q?=EC=84=A0=EC=A0=95=20=EC=B6=94=EA=B0=80,=20RemainCityTrust=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20succ=20->=20success?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_process.old.php | 44 +++--- hwe/func_process.php | 18 ++- hwe/sammo/Command/che_기술연구.php | 23 +-- hwe/sammo/Command/che_상업투자.php | 21 +-- hwe/sammo/Command/che_정착장려.php | 143 ++++++++++++++++++ hwe/sammo/Command/che_주민선정.php | 138 +++++++++++++++++ hwe/sammo/Constraint/RemainCityTrust.php | 43 ++++++ hwe/sammo/TriggerNationType/che_도적.php | 2 +- hwe/sammo/TriggerPersonality/che_은둔.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_경작.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_귀모.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_발명.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_상재.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_수비.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_인덕.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_축성.php | 2 +- hwe/sammo/TriggerSpecialDomestic/che_통찰.php | 2 +- 17 files changed, 393 insertions(+), 57 deletions(-) create mode 100644 hwe/sammo/Command/che_정착장려.php create mode 100644 hwe/sammo/Command/che_주민선정.php create mode 100644 hwe/sammo/Constraint/RemainCityTrust.php diff --git a/hwe/func_process.old.php b/hwe/func_process.old.php index 18a95713..d732ed6f 100644 --- a/hwe/func_process.old.php +++ b/hwe/func_process.old.php @@ -121,7 +121,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use * @param array $general 장수 정보 * @param int|string $type 내정 커맨드 타입, 0|'leader' = 통솔 기반, 1|'power' = 무력 기반, 2|'intel' = 지력 기반 * - * @return array 계산된 실패, 성공 확률 ('succ' => 성공 확률, 'fail' => 실패 확률) + * @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률) */ function CriticalRatioDomestic(&$general, $type) { $leader = getGeneralLeadership($general, false, true, true, false); @@ -154,14 +154,14 @@ function CriticalRatioDomestic(&$general, $type) { $ratio = min($ratio, 1.2); $fail = pow($ratio / 1.2, 1.4) - 0.3; - $succ = pow($ratio / 1.2, 1.5) - 0.25; + $success = pow($ratio / 1.2, 1.5) - 0.25; $fail = min(max($fail, 0), 0.5); - $succ = min(max($succ, 0), 0.5); + $success = min(max($success, 0), 0.5); return array( - 'succ'=>$succ, + 'success'=>$success, 'fail'=>$fail ); } @@ -286,17 +286,17 @@ function process_1_old(&$general, $type) { $r = CriticalRatioDomestic($general, 2); // 특기보정 : 경작, 상재 - if($type == 1 && $general['special'] == 1) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } - if($type == 2 && $general['special'] == 2) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($type == 1 && $general['special'] == 1) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($type == 2 && $general['special'] == 2) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } + if($city['trust'] < 80) { $r['success'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:{$dtype}{$atype} 실패하여 $score 상승했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:{$dtype}{$atype} 성공하여 $score 상승했습니다. <1>$date"; } else { @@ -378,9 +378,9 @@ function process_3(&$general) { $rd = Util::randF(); $r = CriticalRatioDomestic($general, 2); // 특기보정 : 발명 - if($general['special'] == 3) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($general['special'] == 3) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } + if($city['trust'] < 80) { $r['success'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -388,7 +388,7 @@ function process_3(&$general) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:{$dtype}를 실패하여 $score 상승했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:{$dtype}를 성공하여 $score 상승했습니다. <1>$date"; } else { @@ -477,7 +477,7 @@ function process_4(&$general) { $rd = Util::randF(); $r = CriticalRatioDomestic($general, 0); // 특기보정 : 인덕 - if($general['special'] == 20) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($general['special'] == 20) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //버그방지 if($score < 1) $score = 1; @@ -485,7 +485,7 @@ function process_4(&$general) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:선정을 실패하여 민심이 ".round($score, 1)." 상승했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:선정을 성공하여 민심이 ".round($score, 1)." 상승했습니다. <1>$date"; } else { @@ -573,10 +573,10 @@ function process_5(&$general, $type) { $rd = Util::randF(); $r = CriticalRatioDomestic($general, 1); // 특기보정 : 수비, 축성 - if($type == 1 && $general['special'] == 11) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } - if($type == 2 && $general['special'] == 10) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($type == 1 && $general['special'] == 11) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($type == 2 && $general['special'] == 10) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } + if($city['trust'] < 80) { $r['success'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -584,7 +584,7 @@ function process_5(&$general, $type) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:{$dtype}를 실패하여 $score 상승했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:{$dtype}를 성공하여 $score 상승했습니다. <1>$date"; } else { @@ -666,7 +666,7 @@ function process_7(&$general) { $rd = Util::randF(); $r = CriticalRatioDomestic($general, 0); // 특기보정 : 인덕 - if($general['special'] == 20) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($general['special'] == 20) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //버그방지 if($score < 1) $score = 1; @@ -674,7 +674,7 @@ function process_7(&$general) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:장려를 실패하여 주민이 {$score}0명 증가했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:장려를 성공하여 주민이 {$score}0명 증가했습니다. <1>$date"; } else { @@ -762,9 +762,9 @@ function process_8(&$general) { $rd = Util::randF(); $r = CriticalRatioDomestic($general, 1); // 특기보정 : 통찰 - if($general['special'] == 12) { $r['succ'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } + if($general['special'] == 12) { $r['success'] += 0.1; $score *= 1.1; $admin['develcost'] *= 0.8; } //민심 반영 - if($city['trust'] < 80) { $r['succ'] *= $city['trust'] / 80; } + if($city['trust'] < 80) { $r['success'] *= $city['trust'] / 80; } //버그방지 if($score < 1) $score = 1; @@ -772,7 +772,7 @@ function process_8(&$general) { if($r['fail'] > $rd) { $score = CriticalScore($score, 1); $log[] = "●{$admin['month']}월:{$dtype}을 실패하여 $score 강화했습니다. <1>$date"; - } elseif($r['succ'] + $r['fail'] > $rd) { + } elseif($r['success'] + $r['fail'] > $rd) { $score = CriticalScore($score, 0); $log[] = "●{$admin['month']}월:{$dtype}을 성공하여 $score 강화했습니다. <1>$date"; } else { diff --git a/hwe/func_process.php b/hwe/func_process.php index 018f852a..2cbb41bf 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -121,7 +121,7 @@ function getGeneralIntel($general, $withInjury, $withItem, $withStatAdjust, $use * @param array $general 장수 정보 * @param int|string $type 내정 커맨드 타입, 0|'leader' = 통솔 기반, 1|'power' = 무력 기반, 2|'intel' = 지력 기반 * - * @return array 계산된 실패, 성공 확률 ('succ' => 성공 확률, 'fail' => 실패 확률) + * @return array 계산된 실패, 성공 확률 ('success' => 성공 확률, 'fail' => 실패 확률) */ function CriticalRatioDomestic(&$general, $type) { $leader = getGeneralLeadership($general, false, true, true, false); @@ -154,14 +154,14 @@ function CriticalRatioDomestic(&$general, $type) { $ratio = min($ratio, 1.2); $fail = pow($ratio / 1.2, 1.4) - 0.3; - $succ = pow($ratio / 1.2, 1.5) - 0.25; + $success = pow($ratio / 1.2, 1.5) - 0.25; $fail = min(max($fail, 0), 0.5); - $succ = min(max($succ, 0), 0.5); + $success = min(max($success, 0), 0.5); return array( - 'succ'=>$succ, + 'success'=>$success, 'fail'=>$fail ); } @@ -198,6 +198,16 @@ function CriticalScore($score, $type) { return Util::round($score * $ratio); } +function CriticalScoreEx(string $type):float { + if($type == 'success'){ + return Util::randRange(2.2, 3.0); + } + if($type == 'fail'){ + return Util::randRange(0.2, 0.4); + } + return 1; +} + function process_domestic(array $rawGeneral, int $type){ $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); diff --git a/hwe/sammo/Command/che_기술연구.php b/hwe/sammo/Command/che_기술연구.php index e134cabb..2a6f2dea 100644 --- a/hwe/sammo/Command/che_기술연구.php +++ b/hwe/sammo/Command/che_기술연구.php @@ -75,11 +75,11 @@ class che_기술연구 extends BaseCommand{ $score = Util::valueFit($this->calcBaseScore(), 1); - ['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); + ['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); if($trust < 80){ $successRatio *= $trust / 80; } - $successRatio = $general->onCalcDomestic(static::$cityKey, 'succ', $successRatio); + $successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio); $failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio); $successRatio = Util::valueFit($successRatio, 0, 1); @@ -88,7 +88,7 @@ class che_기술연구 extends BaseCommand{ $pick = Util::choiceRandomUsingWeight([ 'fail'=>$failRatio, - 'succ'=>$successRatio, + 'success'=>$successRatio, 'normal'=>$normalRatio ]); @@ -96,18 +96,19 @@ class che_기술연구 extends BaseCommand{ $date = substr($general->getVar('turntime'),11,5); + $score *= CriticalScoreEx($pick); + $score = Util::round($score); + $scoreText = number_format($score, 0); + $josaUl = JosaUtil::pick(static::$actionName, '을'); if($pick == 'fail'){ - $score = CriticalScore($score, 1); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $score 상승했습니다. <1>$date"); + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $scoreText 상승했습니다. <1>$date"); } - else if($pick == 'succ'){ - $score = CriticalScore($score, 1); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $score 상승했습니다. <1>$date"); + else if($pick == 'success'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $scoreText 상승했습니다. <1>$date"); } else{ - $score = Util::round($score); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $score 상승했습니다. <1>$date"); + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); } $exp = $score * 0.7; @@ -121,7 +122,7 @@ class che_기술연구 extends BaseCommand{ } $genCount = Util::valueFit( - $db->queryFirstField('SELECT count(*) FROM general WHERE nation=%i', $general->getVar('nation')), + $db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')), GameConst::$initialNationGenLimit ); diff --git a/hwe/sammo/Command/che_상업투자.php b/hwe/sammo/Command/che_상업투자.php index 34b2a252..73071546 100644 --- a/hwe/sammo/Command/che_상업투자.php +++ b/hwe/sammo/Command/che_상업투자.php @@ -83,11 +83,11 @@ class che_상업투자 extends BaseCommand{ $score = Util::valueFit($this->calcBaseScore(), 1); - ['succ'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); + ['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); if($trust < 80){ $successRatio *= $trust / 80; } - $successRatio = $general->onCalcDomestic(static::$cityKey, 'succ', $successRatio); + $successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio); $failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio); $successRatio = Util::valueFit($successRatio, 0, 1); @@ -96,7 +96,7 @@ class che_상업투자 extends BaseCommand{ $pick = Util::choiceRandomUsingWeight([ 'fail'=>$failRatio, - 'succ'=>$successRatio, + 'success'=>$successRatio, 'normal'=>$normalRatio ]); @@ -104,18 +104,19 @@ class che_상업투자 extends BaseCommand{ $date = substr($general->getVar('turntime'),11,5); + $score *= CriticalScoreEx($pick); + $score = Util::round($score); + $scoreText = number_format($score, 0); + $josaUl = JosaUtil::pick(static::$actionName, '을'); if($pick == 'fail'){ - $score = CriticalScore($score, 1); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $score 상승했습니다. <1>$date"); + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $scoreText 상승했습니다. <1>$date"); } - else if($pick == 'succ'){ - $score = CriticalScore($score, 1); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $score 상승했습니다. <1>$date"); + else if($pick == 'success'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $scoreText 상승했습니다. <1>$date"); } else{ - $score = Util::round($score); - $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $score 상승했습니다. <1>$date"); + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); } $exp = $score * 0.7; diff --git a/hwe/sammo/Command/che_정착장려.php b/hwe/sammo/Command/che_정착장려.php new file mode 100644 index 00000000..d5396fe3 --- /dev/null +++ b/hwe/sammo/Command/che_정착장려.php @@ -0,0 +1,143 @@ +generalObj; + + $this->setCity(); + $this->setNation(); + + $develCost = $this->env['develcost'] * 2; + $reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $reqRice); + + $this->constraints=[ + ['NoNeutral'], + ['NoWanderingNation'], + ['OccupiedCity'], + ['SuppliedCity'], + ['ReqGeneralGold', $reqRice], + ['RemainCityCapacity', [static::$cityKey, static::$actionName]] + ]; + + $this->reqRice = $reqRice; + } + + protected function calcBaseScore():float{ + $general = $this->generalObj; + + if(static::$statKey == 'intel'){ + $score = getGeneralIntel($general->getRaw(), true, true, true, false); + } + else if(static::$statKey == 'power'){ + $score = getGeneralPower($general->getRaw(), true, true, true, false); + } + else if(static::$statKey == 'leader'){ + $score = getGeneralLeadership($general->getRaw(), true, true, true, false); + } + else{ + throw new \sammo\MustNotBeReachedException(); + } + + $score *= getDomesticExpLevelBonus($general['explevel']); + $score *= Util::randRange(0.8, 1.2); + $score = $general->onCalcDomestic(static::$actionKey, 'score', $score); + + return $score; + } + + public function run():bool{ + if(!$this->isAvailable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + + $score = Util::valueFit($this->calcBaseScore(), 1); + + ['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); + $successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio); + $failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio); + + $successRatio = Util::valueFit($successRatio, 0, 1); + $failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio); + $normalRatio = 1 - $failRatio - $successRatio; + + $pick = Util::choiceRandomUsingWeight([ + 'fail'=>$failRatio, + 'success'=>$successRatio, + 'normal'=>$normalRatio + ]); + + $logger = $general->getLogger(); + + $date = substr($general->getVar('turntime'),11,5); + + $score *= CriticalScoreEx($pick); + $score = Util::round($score); + $scoreText = number_format($score, 0); + + $josaUl = JosaUtil::pick(static::$actionName, '을'); + if($pick == 'fail'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $scoreText 상승했습니다. <1>$date"); + } + else if($pick == 'success'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $scoreText 상승했습니다. <1>$date"); + } + else{ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); + } + + $exp = $score * 0.7; + $ded = $score * 1.0; + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + + //NOTE: 내정량 상승시 초과 가능? + $cityUpdated = [ + static::$cityKey => Util::valueFit( + $this->city[static::$cityKey] + $score, + 0, + $this->city[static::$cityKey.'2'] + ) + ]; + $db->update('city', $cityUpdated, 'city=%i', $general->getVar('city')); + + $general->increaseVarWithLimit('rice', -$this->reqRice, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVar(static::$statKey.'2', 1); + $general->updateVar('resturn', 'SUCCESS'); + $general->applyDB($db); + + $this->checkStatChange(); + uniqueItemEx($general->getVar('no'), $logger); + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Command/che_주민선정.php b/hwe/sammo/Command/che_주민선정.php new file mode 100644 index 00000000..fc40227e --- /dev/null +++ b/hwe/sammo/Command/che_주민선정.php @@ -0,0 +1,138 @@ +generalObj; + + $this->setCity(); + $this->setNation(); + + $develCost = $this->env['develcost'] * 2; + $reqRice = $general->onCalcDomestic(static::$actionKey, 'cost', $reqGold); + + $this->constraints=[ + ['NoNeutral'], + ['NoWanderingNation'], + ['OccupiedCity'], + ['SuppliedCity'], + ['ReqGeneralRice', $reqRice], + ['RemainCityTrust', static::$actionName] + ]; + + $this->reqRice = $reqRice; + } + + protected function calcBaseScore():float{ + $general = $this->generalObj; + + if(static::$statKey == 'leader'){ + $score = getGeneralLeadership($general->getRaw(), true, true, true, false); + } + else{ + throw new \sammo\MustNotBeReachedException(); + } + + $score /= 10; + $score *= getDomesticExpLevelBonus($general['explevel']); + $score *= Util::randRange(0.8, 1.2); + $score = $general->onCalcDomestic(static::$actionKey, 'score', $score); + $score = Util::valutFit($score, 1); + + return $score; + } + + public function run():bool{ + if(!$this->isAvailable()){ + throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도'); + } + + $db = DB::db(); + + $general = $this->generalObj; + + $score = Util::valueFit($this->calcBaseScore(), 1); + + ['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general->getRaw(), static::$statKey); + $successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio); + $failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio); + + $successRatio = Util::valueFit($successRatio, 0, 1); + $failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio); + $normalRatio = 1 - $failRatio - $successRatio; + + $pick = Util::choiceRandomUsingWeight([ + 'fail'=>$failRatio, + 'success'=>$successRatio, + 'normal'=>$normalRatio + ]); + + $logger = $general->getLogger(); + + $date = substr($general->getVar('turntime'),11,5); + + $score *= CriticalScoreEx($pick); + $scoreText = number_format($score, 1); + + $josaUl = JosaUtil::pick(static::$actionName, '을'); + if($pick == 'fail'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 실패하여 $scoreText 상승했습니다. <1>$date"); + } + else if($pick == 'success'){ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 성공하여 $scoreText 상승했습니다. <1>$date"); + } + else{ + $logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 $scoreText 상승했습니다. <1>$date"); + } + + $exp = $score * 0.7; + $ded = $score * 1.0; + + $exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp); + $ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded); + + //NOTE: 내정량 상승시 초과 가능? + $cityUpdated = [ + static::$cityKey => Util::valueFit( + $this->city[static::$cityKey] + $score, + 0, + 100 + ) + ]; + $db->update('city', $cityUpdated, 'city=%i', $general->getVar('city')); + + $general->increaseVarWithLimit('rice', -$this->reqRice, 0); + $general->increaseVar('experience', $exp); + $general->increaseVar('dedication', $ded); + $general->increaseVar(static::$statKey.'2', 1); + $general->updateVar('resturn', 'SUCCESS'); + $general->applyDB($db); + + $this->checkStatChange(); + uniqueItemEx($general->getVar('no'), $logger); + } + + +} \ No newline at end of file diff --git a/hwe/sammo/Constraint/RemainCityTrust.php b/hwe/sammo/Constraint/RemainCityTrust.php new file mode 100644 index 00000000..0ee43235 --- /dev/null +++ b/hwe/sammo/Constraint/RemainCityTrust.php @@ -0,0 +1,43 @@ +keyNick = $this->arg; + $this->key = 'trust'; + $this->maxVal = 100; + + if(!key_exists($this->key, $this->city)){ + if(!$throwExeception){return false; } + throw new \InvalidArgumentException("require {$this->key} in city"); + } + + return true; + } + + public function test():bool{ + $this->checkInputValues(); + $this->tested = true; + + if($this->city[$this->key] < $this->maxVal){ + return true; + } + + $josaUn = JosaUtil::pick($keyNick, '은'); + $this->reason = "{$keyNick}{$josaUn} 충분합니다."; + return false; + } +} \ No newline at end of file diff --git a/hwe/sammo/TriggerNationType/che_도적.php b/hwe/sammo/TriggerNationType/che_도적.php index 6191ee0c..31206760 100644 --- a/hwe/sammo/TriggerNationType/che_도적.php +++ b/hwe/sammo/TriggerNationType/che_도적.php @@ -21,7 +21,7 @@ class che_도적 implements iActionTrigger{ if($varType == 'cost') return $value * 1.2; } else if($turnType == '계략'){ - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } diff --git a/hwe/sammo/TriggerPersonality/che_은둔.php b/hwe/sammo/TriggerPersonality/che_은둔.php index b2a6eee0..c1729934 100644 --- a/hwe/sammo/TriggerPersonality/che_은둔.php +++ b/hwe/sammo/TriggerPersonality/che_은둔.php @@ -12,7 +12,7 @@ class che_은둔 implements iActionTrigger{ public function onCalcDomestic(string $turnType, string $varType, float $value):float{ if($turnType == '단련'){ - if($varType == 'succ'){ + if($varType == 'success'){ return $value + 0.1; } } diff --git a/hwe/sammo/TriggerSpecialDomestic/che_경작.php b/hwe/sammo/TriggerSpecialDomestic/che_경작.php index 523c03a6..ae9e077b 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_경작.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_경작.php @@ -21,7 +21,7 @@ class che_경작 implements iActionTrigger{ if($turnType == '농업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_귀모.php b/hwe/sammo/TriggerSpecialDomestic/che_귀모.php index aacf2656..126d198a 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_귀모.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_귀모.php @@ -21,7 +21,7 @@ class che_귀모 implements iActionTrigger{ public function onCalcDomestic(string $turnType, string $varType, float $value):float{ if($turnType == '계략'){ - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } diff --git a/hwe/sammo/TriggerSpecialDomestic/che_발명.php b/hwe/sammo/TriggerSpecialDomestic/che_발명.php index 61fe179b..1678cb3b 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_발명.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_발명.php @@ -21,7 +21,7 @@ class che_발명 implements iActionTrigger{ if($turnType == '기술'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_상재.php b/hwe/sammo/TriggerSpecialDomestic/che_상재.php index 7325d631..cfc557fa 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_상재.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_상재.php @@ -21,7 +21,7 @@ class che_상재 implements iActionTrigger{ if($turnType == '상업'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_수비.php b/hwe/sammo/TriggerSpecialDomestic/che_수비.php index f0eda7ad..9f0873b5 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_수비.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_수비.php @@ -21,7 +21,7 @@ class che_수비 implements iActionTrigger{ if($turnType == '수비'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_인덕.php b/hwe/sammo/TriggerSpecialDomestic/che_인덕.php index c0e6b76d..700fe999 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_인덕.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_인덕.php @@ -21,7 +21,7 @@ class che_통찰 implements iActionTrigger{ if($turnType == '민심' || $turnType == '인구'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_축성.php b/hwe/sammo/TriggerSpecialDomestic/che_축성.php index c91ec03c..b5f8bcfb 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_축성.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_축성.php @@ -21,7 +21,7 @@ class che_축성 implements iActionTrigger{ if($turnType == '성벽'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value; diff --git a/hwe/sammo/TriggerSpecialDomestic/che_통찰.php b/hwe/sammo/TriggerSpecialDomestic/che_통찰.php index 7d8e7211..05f662f0 100644 --- a/hwe/sammo/TriggerSpecialDomestic/che_통찰.php +++ b/hwe/sammo/TriggerSpecialDomestic/che_통찰.php @@ -21,7 +21,7 @@ class che_통찰 implements iActionTrigger{ if($turnType == '치안'){ if($varType == 'score') return $value * 1.1; if($varType == 'cost') return $value * 0.8; - if($varType == 'succ') return $value + 0.1; + if($varType == 'success') return $value + 0.1; } return $value;