물자조달 턴 추가 기타 커맨드 버그 수정

This commit is contained in:
2018-10-16 00:53:19 +09:00
parent 928e8a200b
commit 90736b52be
13 changed files with 195 additions and 90 deletions
-12
View File
@@ -186,18 +186,6 @@ function setLeadershipBonus(&$general, $nationLevel){
return $lbonus;
}
function CriticalScore($score, $type) {
switch($type) {
case 0:
$ratio = Util::randF()*0.8 + 2.2; // 2.2~3.0
break;
case 1:
$ratio = Util::randF()*0.2 + 0.2; // 0.2~0.4
break;
}
return Util::round($score * $ratio);
}
function CriticalScoreEx(string $type):float {
if($type == 'success'){
return Util::randRange(2.2, 3.0);
+2 -5
View File
@@ -6,14 +6,11 @@ use \sammo\{
General,
CityConst,
ActionLogger,
LastTurn
LastTurn,
Command
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_NPC능동 extends Command\GeneralCommand{
@@ -5,18 +5,19 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
LastTurn,
Command
};
use function sammo\{
TechLimit,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore, TechLimit,
uniqueItemEx,
LastTurn
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_기술연구 extends che_상업투자{
@@ -1,9 +1,6 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\Util;
use \sammo\JosaUtil;
class che_농지개간 extends che_상업투자{
static protected $cityKey = 'agri';
static protected $statKey = 'intel';
@@ -0,0 +1,129 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst,
LastTurn,
GameUnitConst,
Command
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
};
use \sammo\Constraint\Constraint;
class che_물자조달 extends Command\GeneralCommand{
static protected $actionName = '물자조달';
protected function init(){
$general = $this->generalObj;
$this->setCity();
$this->setNation();
$this->runnableConstraints=[
['NoNeutral'],
['NoWanderingNation'],
['OccupiedCity'],
['SuppliedCity']
];
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
public function getPreReqTurn():int{
return 0;
}
public function getPostReqTurn():int{
return 0;
}
public function run():bool{
if(!$this->isRunnable()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
}
$db = DB::db();
$general = $this->generalObj;
$date = substr($general->getVar('turntime'),11,5);
[$resName, $resKey] = Util::choiceRandom([
['금', 'gold'],
['쌀', 'rice']
]);
$score = $general->getLeadership() + $general->getPower() + $general->getIntel();
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2);
$pick = Util::choiceRandomUsingWeight([
'fail'=>0.3,
'success'=>0.1,
'normal'=>0.6
]);
$score *= CriticalScoreEx($pick);
$score = Util::round($score);
$scoreText = number_format($score, 0);
$logger = $general->getLogger();
if($pick == 'fail'){
$logger->pushGeneralActionLog("조달을 <span class='ev_failed'>실패</span>하여 {$resName}을 <C>$scoreText</> 조달했습니다. <1>$date</>");
}
else if($pick == 'success'){
$logger->pushGeneralActionLog("조달을 <S>성공</>하여 {$resName}을 <C>$scoreText</> 조달했습니다. <1>$date</>");
}
else{
$logger->pushGeneralActionLog("{$resName}을 <C>$scoreText</> 조달했습니다. <1>$date</>");
}
$exp = $score * 0.7 / 3;
$ded = $score * 1.0 / 3;
$exp = $general->onPreGeneralStatUpdate($general, 'experience', $exp);
$ded = $general->onPreGeneralStatUpdate($general, 'dedication', $ded);
$incStat = Util::choiceRandomUsingWeight([
'leader2'=>$general->getLeadership(false, false, false, false),
'power2'=>$general->getPower(false, false, false, false),
'intel2'=>$general->getIntel(false, false, false, false)
]);
$general->increaseVar('experience', $exp);
$general->increaseVar('dedication', $ded);
$general->increaseVar($incStat, 1);
$db->update('nation', [
$resKey=>$db->sqleval('%b + %i', $resKey, $score)
], 'nation=%i',$general->getNationID());
$general->setResultTurn(new LastTurn(static::getName(), $this->arg));
$general->applyDB($db);
$this->checkStatChange();
}
}
+8 -11
View File
@@ -5,20 +5,17 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
GameConst, GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
use sammo\GameUnitConst;
class che_사기진작 extends Command\GeneralCommand{
+14 -12
View File
@@ -5,18 +5,20 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
GameConst,
LastTurn,
GameUnitConst,
Command
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_상업투자 extends Command\GeneralCommand{
@@ -74,20 +76,20 @@ class che_상업투자 extends Command\GeneralCommand{
$general = $this->generalObj;
if(static::$statKey == 'intel'){
$score = getGeneralIntel($general->getRaw(), true, true, true, false);
$score = $general->getIntel(true, true, true, false);
}
else if(static::$statKey == 'power'){
$score = getGeneralPower($general->getRaw(), true, true, true, false);
$score = $general->getPower(true, true, true, false);
}
else if(static::$statKey == 'leader'){
$score = getGeneralLeadership($general->getRaw(), true, true, true, false);
$score = $general->getLeadership(true, true, true, false);
}
else{
throw new \sammo\MustNotBeReachedException();
}
$score *= $trust / 100;
$score *= getDomesticExpLevelBonus($general['explevel']);
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2);
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
@@ -1,9 +1,6 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\Util;
use \sammo\JosaUtil;
class che_성벽보수 extends che_상업투자{
static protected $cityKey = 'wall';
static protected $statKey = 'power';
@@ -1,9 +1,6 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\Util;
use \sammo\JosaUtil;
class che_수비강화 extends che_상업투자{
static protected $cityKey = 'def';
static protected $statKey = 'power';
+12 -9
View File
@@ -5,17 +5,20 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
GameConst,
LastTurn,
GameUnitConst,
Command
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
@@ -72,13 +75,13 @@ class che_정착장려 extends Command\GeneralCommand{
$general = $this->generalObj;
if(static::$statKey == 'leader'){
$score = getGeneralLeadership($general->getRaw(), true, true, true, false);
$score = $general->getLeadership(true, true, true, false);
}
else{
throw new \sammo\MustNotBeReachedException();
}
$score *= getDomesticExpLevelBonus($general['explevel']);
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2);
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
+12 -10
View File
@@ -5,18 +5,20 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
GameConst,
LastTurn,
GameUnitConst,
Command
};
use function \sammo\{
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
CriticalRatioDomestic,
CriticalScoreEx,
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
class che_주민선정 extends Command\GeneralCommand{
@@ -72,13 +74,13 @@ class che_주민선정 extends Command\GeneralCommand{
$general = $this->generalObj;
if(static::$statKey == 'leader'){
$score = getGeneralLeadership($general->getRaw(), true, true, true, false);
$score = $general->getLeadership(true, true, true, false);
}
else{
throw new \sammo\MustNotBeReachedException();
}
$score *= getDomesticExpLevelBonus($general['explevel']);
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
$score *= Util::randRange(0.8, 1.2);
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
$score = Util::valutFit($score, 1);
@@ -1,9 +1,6 @@
<?php
namespace sammo\GeneralCommand;
use \sammo\Util;
use \sammo\JosaUtil;
class che_치안강화 extends che_상업투자{
static protected $cityKey = 'secu';
static protected $statKey = 'power';
+9 -11
View File
@@ -5,20 +5,18 @@ use \sammo\{
DB, Util, JosaUtil,
General,
ActionLogger,
GameConst,
getGeneralLeadership,getGeneralPower,getGeneralIntel,
getDomesticExpLevelBonus,
CriticalRatioDomestic, CriticalScore,
uniqueItemEx,
LastTurn
GameConst, GameUnitConst,
LastTurn,
Command
};
use function \sammo\{
uniqueItemEx
};
use \sammo\Command;
use \sammo\Constraint\Constraint;
use function sammo\CriticalScore;
use function sammo\uniqueItemEx;
use function sammo\getGeneralLeadership;
use sammo\GameUnitConst;
class che_훈련 extends Command\GeneralCommand{