내정 커맨드 버그 수정, 정착장려, 주민선정 추가, RemainCityTrust 추가, succ -> success

This commit is contained in:
2018-09-15 03:42:09 +09:00
parent f5bcaba352
commit b5380f183c
17 changed files with 393 additions and 57 deletions
+22 -22
View File
@@ -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[] = "<C>●</>{$admin['month']}월:{$dtype}{$atype} <span class='ev_failed'>실패</span>하여 <C>$score</> 상승했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:{$dtype}{$atype} <S>성공</>하여 <C>$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[] = "<C>●</>{$admin['month']}월:{$dtype}를 <span class='ev_failed'>실패</span>하여 <C>$score</> 상승했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:{$dtype}를 <S>성공</>하여 <C>$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[] = "<C>●</>{$admin['month']}월:선정을 <span class='ev_failed'>실패</span>하여 민심이 <C>".round($score, 1)."</> 상승했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:선정을 <S>성공</>하여 민심이 <C>".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[] = "<C>●</>{$admin['month']}월:{$dtype}를 <span class='ev_failed'>실패</span>하여 <C>$score</> 상승했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:{$dtype}를 <S>성공</>하여 <C>$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[] = "<C>●</>{$admin['month']}월:장려를 <span class='ev_failed'>실패</span>하여 주민이 <C>{$score}0</>명 증가했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:장려를 <S>성공</>하여 주민이 <C>{$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[] = "<C>●</>{$admin['month']}월:{$dtype}을 <span class='ev_failed'>실패</span>하여 <C>$score</> 강화했습니다. <1>$date</>";
} elseif($r['succ'] + $r['fail'] > $rd) {
} elseif($r['success'] + $r['fail'] > $rd) {
$score = CriticalScore($score, 0);
$log[] = "<C>●</>{$admin['month']}월:{$dtype}을 <S>성공</>하여 <C>$score</> 강화했습니다. <1>$date</>";
} else {
+14 -4
View File
@@ -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');
+12 -11
View File
@@ -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} <span class='ev_failed'>실패</span>하여 <C>$score</> 상승했습니다. <1>$date</>");
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else if($pick == 'succ'){
$score = CriticalScore($score, 1);
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$score</> 상승했습니다. <1>$date</>");
else if($pick == 'success'){
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else{
$score = Util::round($score);
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$score</> 상승했습니다. <1>$date</>");
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$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
);
+11 -10
View File
@@ -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} <span class='ev_failed'>실패</span>하여 <C>$score</> 상승했습니다. <1>$date</>");
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else if($pick == 'succ'){
$score = CriticalScore($score, 1);
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$score</> 상승했습니다. <1>$date</>");
else if($pick == 'success'){
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else{
$score = Util::round($score);
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$score</> 상승했습니다. <1>$date</>");
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
$exp = $score * 0.7;
+143
View File
@@ -0,0 +1,143 @@
<?php
namespace sammo\Command;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx
};
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_상업투자 extends BaseCommand{
static $cityKey = 'pop';
static $statKey = 'leader';
static $actionKey = '인구';
static $actionName = '정착 장려';
protected function init(){
$general = $this->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} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else if($pick == 'success'){
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else{
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$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);
}
}
+138
View File
@@ -0,0 +1,138 @@
<?php
namespace sammo\Command;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx
};
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_주민선정 extends BaseCommand{
static $cityKey = 'trust';
static $statKey = 'leader';
static $actionKey = '민심';
static $actionName = '주민 선정';
protected function init(){
$general = $this->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} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else if($pick == 'success'){
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
}
else{
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$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);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace sammo\Constraint;
use \sammo\JosaUtil;
class RemainCityTrust extends Constraint{
const REQ_VALUES = Constraint::REQ_CITY|Constraint::REQ_STRING_ARG;
protected $key;
protected $maxKey;
protected $keyNick;
public function checkInputValues(bool $throwExeception=true){
if(!parent::checkInputValues($throwExeception) && !$throwException){
return false;
}
$this->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;
}
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
}
@@ -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;
@@ -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;
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;