내정 커맨드 버그 수정, 정착장려, 주민선정 추가, 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
+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;