내특 동작 안하는 버그 수정
This commit is contained in:
@@ -1,137 +1,137 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
Command, GameConst
|
Command, GameConst
|
||||||
};
|
};
|
||||||
|
|
||||||
use function sammo\{
|
use function sammo\{
|
||||||
TechLimit,
|
TechLimit,
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_기술연구 extends che_상업투자{
|
class che_기술연구 extends che_상업투자{
|
||||||
static protected $statKey = 'intel';
|
static protected $statKey = 'intel';
|
||||||
static protected $actionKey = '기술';
|
static protected $actionKey = '기술';
|
||||||
static protected $actionName = '기술 연구';
|
static protected $actionName = '기술 연구';
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation(['tech']);
|
$this->setNation(['tech']);
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice)
|
ConstraintHelper::ReqGeneralRice($reqRice)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqGold = $reqGold;
|
$this->reqGold = $reqGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
if($trust < 80){
|
if($trust < 80){
|
||||||
$successRatio *= $trust / 80;
|
$successRatio *= $trust / 80;
|
||||||
}
|
}
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){
|
if(TechLimit($this->env['startyear'], $this->env['year'], $this->nation['tech'])){
|
||||||
$score /= 4;
|
$score /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
$genCount = Util::valueFit(
|
$genCount = Util::valueFit(
|
||||||
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
|
$db->queryFirstField('SELECT gennum FROM nation WHERE nation=%i', $general->getVar('nation')),
|
||||||
GameConst::$initialNationGenLimit
|
GameConst::$initialNationGenLimit
|
||||||
);
|
);
|
||||||
|
|
||||||
$nationUpdated = [
|
$nationUpdated = [
|
||||||
'tech' => $this->nation['tech'] + $score/$genCount
|
'tech' => $this->nation['tech'] + $score/$genCount
|
||||||
];
|
];
|
||||||
$db->update('nation', $nationUpdated, 'nation=%i', $general->getVar('nation'));
|
$db->update('nation', $nationUpdated, 'nation=%i', $general->getVar('nation'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
|
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,208 +1,208 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_상업투자 extends Command\GeneralCommand{
|
class che_상업투자 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'comm';
|
static protected $cityKey = 'comm';
|
||||||
static protected $statKey = 'intel';
|
static protected $statKey = 'intel';
|
||||||
static protected $actionKey = '상업';
|
static protected $actionKey = '상업';
|
||||||
static protected $actionName = '상업 투자';
|
static protected $actionName = '상업 투자';
|
||||||
static protected $debuffFront = 0.5;
|
static protected $debuffFront = 0.5;
|
||||||
|
|
||||||
protected $reqGold;
|
protected $reqGold;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqGold = $reqGold;
|
$this->reqGold = $reqGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'];
|
$develCost = $this->env['develcost'];
|
||||||
$reqGold = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
$reqGold = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||||
$reqRice = 0;
|
$reqRice = 0;
|
||||||
|
|
||||||
return [$reqGold, $reqRice];
|
return [$reqGold, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'intel'){
|
if(static::$statKey == 'intel'){
|
||||||
$score = $general->getIntel(true, true, true, false);
|
$score = $general->getIntel(true, true, true, false);
|
||||||
}
|
}
|
||||||
else if(static::$statKey == 'strength'){
|
else if(static::$statKey == 'strength'){
|
||||||
$score = $general->getStrength(true, true, true, false);
|
$score = $general->getStrength(true, true, true, false);
|
||||||
}
|
}
|
||||||
else if(static::$statKey == 'leadership'){
|
else if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= $trust / 100;
|
$score *= $trust / 100;
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$trust = Util::valueFit($this->city['trust'], 50);
|
$trust = Util::valueFit($this->city['trust'], 50);
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
if($trust < 80){
|
if($trust < 80){
|
||||||
$successRatio *= $trust / 80;
|
$successRatio *= $trust / 80;
|
||||||
}
|
}
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){
|
if(in_array($this->city['front'], [1, 3]) && $this->nation['capital'] != $this->city['city']){
|
||||||
$score *= static::$debuffFront;
|
$score *= static::$debuffFront;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
$this->city[static::$cityKey.'_max']
|
$this->city[static::$cityKey.'_max']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
$general->increaseVarWithLimit('gold', -$this->reqGold, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,191 +1,191 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_정착장려 extends Command\GeneralCommand{
|
class che_정착장려 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'pop';
|
static protected $cityKey = 'pop';
|
||||||
static protected $statKey = 'leadership';
|
static protected $statKey = 'leadership';
|
||||||
static protected $actionKey = '인구';
|
static protected $actionKey = '인구';
|
||||||
static protected $actionName = '정착 장려';
|
static protected $actionName = '정착 장려';
|
||||||
|
|
||||||
protected $reqRice;
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
ConstraintHelper::RemainCityCapacity(static::$cityKey, static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqRice = $reqRice;
|
$this->reqRice = $reqRice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'] * 2;
|
$develCost = $this->env['develcost'] * 2;
|
||||||
$reqGold = 0;
|
$reqGold = 0;
|
||||||
$reqRice = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
$reqRice = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||||
|
|
||||||
return [$reqGold, $reqRice];
|
return [$reqGold, $reqRice];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'leadership'){
|
if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
$score = Util::round($score);
|
$score = Util::round($score);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$score *= 10;
|
$score *= 10;
|
||||||
|
|
||||||
$scoreText = number_format($score, 0);
|
$scoreText = number_format($score, 0);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 주민이 <C>$scoreText</>명 증가했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
$this->city[static::$cityKey.'_max']
|
$this->city[static::$cityKey.'_max']
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,191 +1,191 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace sammo\Command\General;
|
namespace sammo\Command\General;
|
||||||
|
|
||||||
use \sammo\{
|
use \sammo\{
|
||||||
DB, Util, JosaUtil,
|
DB, Util, JosaUtil,
|
||||||
General,
|
General,
|
||||||
ActionLogger,
|
ActionLogger,
|
||||||
GameConst,
|
GameConst,
|
||||||
LastTurn,
|
LastTurn,
|
||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command
|
Command
|
||||||
};
|
};
|
||||||
|
|
||||||
use function \sammo\{
|
use function \sammo\{
|
||||||
getDomesticExpLevelBonus,
|
getDomesticExpLevelBonus,
|
||||||
CriticalRatioDomestic,
|
CriticalRatioDomestic,
|
||||||
CriticalScoreEx,
|
CriticalScoreEx,
|
||||||
tryUniqueItemLottery
|
tryUniqueItemLottery
|
||||||
};
|
};
|
||||||
|
|
||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
|
|
||||||
|
|
||||||
class che_주민선정 extends Command\GeneralCommand{
|
class che_주민선정 extends Command\GeneralCommand{
|
||||||
static protected $cityKey = 'trust';
|
static protected $cityKey = 'trust';
|
||||||
static protected $statKey = 'leadership';
|
static protected $statKey = 'leadership';
|
||||||
static protected $actionKey = '민심';
|
static protected $actionKey = '민심';
|
||||||
static protected $actionName = '주민 선정';
|
static protected $actionName = '주민 선정';
|
||||||
|
|
||||||
protected $reqRice;
|
protected $reqRice;
|
||||||
|
|
||||||
protected function argTest():bool{
|
protected function argTest():bool{
|
||||||
$this->arg = null;
|
$this->arg = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init(){
|
protected function init(){
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$this->setCity();
|
$this->setCity();
|
||||||
$this->setNation();
|
$this->setNation();
|
||||||
|
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$this->fullConditionConstraints=[
|
$this->fullConditionConstraints=[
|
||||||
ConstraintHelper::NotBeNeutral(),
|
ConstraintHelper::NotBeNeutral(),
|
||||||
ConstraintHelper::NotWanderingNation(),
|
ConstraintHelper::NotWanderingNation(),
|
||||||
ConstraintHelper::OccupiedCity(),
|
ConstraintHelper::OccupiedCity(),
|
||||||
ConstraintHelper::SuppliedCity(),
|
ConstraintHelper::SuppliedCity(),
|
||||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||||
ConstraintHelper::RemainCityTrust(static::$actionName)
|
ConstraintHelper::RemainCityTrust(static::$actionName)
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->reqRice = $reqRice;
|
$this->reqRice = $reqRice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommandDetailTitle():string{
|
public function getCommandDetailTitle():string{
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
$statTypeBase = [
|
$statTypeBase = [
|
||||||
'leadership'=>'통솔경험',
|
'leadership'=>'통솔경험',
|
||||||
'strength'=>'무력경험',
|
'strength'=>'무력경험',
|
||||||
'intel'=>'지력경험',
|
'intel'=>'지력경험',
|
||||||
];
|
];
|
||||||
$statType = $statTypeBase[static::$statKey];
|
$statType = $statTypeBase[static::$statKey];
|
||||||
[$reqGold, $reqRice] = $this->getCost();
|
[$reqGold, $reqRice] = $this->getCost();
|
||||||
|
|
||||||
$title = "{$name}({$statType}";
|
$title = "{$name}({$statType}";
|
||||||
if($reqGold > 0){
|
if($reqGold > 0){
|
||||||
$title .= ", 자금{$reqGold}";
|
$title .= ", 자금{$reqGold}";
|
||||||
}
|
}
|
||||||
if($reqRice > 0){
|
if($reqRice > 0){
|
||||||
$title .= ", 군량{$reqRice}";
|
$title .= ", 군량{$reqRice}";
|
||||||
}
|
}
|
||||||
$title .= ')';
|
$title .= ')';
|
||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCost():array{
|
public function getCost():array{
|
||||||
$develCost = $this->env['develcost'] * 2;
|
$develCost = $this->env['develcost'] * 2;
|
||||||
$reqGold = 0;
|
$reqGold = 0;
|
||||||
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
|
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
|
||||||
|
|
||||||
return [$reqGold, Util::round($reqRice)];
|
return [$reqGold, Util::round($reqRice)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompensationStyle():?int{
|
public function getCompensationStyle():?int{
|
||||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreReqTurn():int{
|
public function getPreReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReqTurn():int{
|
public function getPostReqTurn():int{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcBaseScore():float{
|
protected function calcBaseScore():float{
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
if(static::$statKey == 'leadership'){
|
if(static::$statKey == 'leadership'){
|
||||||
$score = $general->getLeadership(true, true, true, false);
|
$score = $general->getLeadership(true, true, true, false);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new \sammo\MustNotBeReachedException();
|
throw new \sammo\MustNotBeReachedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||||
$score *= Util::randRange(0.8, 1.2);
|
$score *= Util::randRange(0.8, 1.2);
|
||||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||||
$score = Util::valueFit($score, 1);
|
$score = Util::valueFit($score, 1);
|
||||||
|
|
||||||
return $score;
|
return $score;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run():bool{
|
public function run():bool{
|
||||||
if(!$this->hasFullConditionMet()){
|
if(!$this->hasFullConditionMet()){
|
||||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$general = $this->generalObj;
|
$general = $this->generalObj;
|
||||||
|
|
||||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||||
|
|
||||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||||
$successRatio = $general->onCalcDomestic(static::$cityKey, 'success', $successRatio);
|
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||||
$failRatio = $general->onCalcDomestic(static::$cityKey, 'fail', $failRatio);
|
$failRatio = $general->onCalcDomestic(static::$actionKey, 'fail', $failRatio);
|
||||||
|
|
||||||
$successRatio = Util::valueFit($successRatio, 0, 1);
|
$successRatio = Util::valueFit($successRatio, 0, 1);
|
||||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||||
$normalRatio = 1 - $failRatio - $successRatio;
|
$normalRatio = 1 - $failRatio - $successRatio;
|
||||||
|
|
||||||
$pick = Util::choiceRandomUsingWeight([
|
$pick = Util::choiceRandomUsingWeight([
|
||||||
'fail'=>$failRatio,
|
'fail'=>$failRatio,
|
||||||
'success'=>$successRatio,
|
'success'=>$successRatio,
|
||||||
'normal'=>$normalRatio
|
'normal'=>$normalRatio
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$logger = $general->getLogger();
|
$logger = $general->getLogger();
|
||||||
|
|
||||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||||
|
|
||||||
$score *= CriticalScoreEx($pick);
|
$score *= CriticalScoreEx($pick);
|
||||||
|
|
||||||
$exp = $score * 0.7;
|
$exp = $score * 0.7;
|
||||||
$ded = $score * 1.0;
|
$ded = $score * 1.0;
|
||||||
|
|
||||||
$score /= 10;
|
$score /= 10;
|
||||||
|
|
||||||
$scoreText = number_format($score, 1);
|
$scoreText = number_format($score, 1);
|
||||||
|
|
||||||
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
$josaUl = JosaUtil::pick(static::$actionName, '을');
|
||||||
if($pick == 'fail'){
|
if($pick == 'fail'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <span class='ev_failed'>실패</span>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else if($pick == 'success'){
|
else if($pick == 'success'){
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} <S>성공</>하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
$logger->pushGeneralActionLog(static::$actionName."{$josaUl} 하여 <C>$scoreText</> 상승했습니다. <1>$date</>");
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: 내정량 상승시 초과 가능?
|
//NOTE: 내정량 상승시 초과 가능?
|
||||||
$cityUpdated = [
|
$cityUpdated = [
|
||||||
static::$cityKey => Util::valueFit(
|
static::$cityKey => Util::valueFit(
|
||||||
$this->city[static::$cityKey] + $score,
|
$this->city[static::$cityKey] + $score,
|
||||||
0,
|
0,
|
||||||
100
|
100
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
$db->update('city', $cityUpdated, 'city=%i', $general->getVar('city'));
|
||||||
|
|
||||||
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
$general->increaseVarWithLimit('rice', -$this->reqRice, 0);
|
||||||
$general->addExperience($exp);
|
$general->addExperience($exp);
|
||||||
$general->addDedication($ded);
|
$general->addDedication($ded);
|
||||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||||
$general->checkStatChange();
|
$general->checkStatChange();
|
||||||
tryUniqueItemLottery($general);
|
tryUniqueItemLottery($general);
|
||||||
$general->applyDB($db);
|
$general->applyDB($db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user