forked from devsam/core
- null && key_exists 버그 - or assign이 integer 대상이므로 직접 연산 - false 대신 0 입력한 곳 수정 - 자체 Deprecate 처리한 함수 회피 - 초기화되지 않은 [] 확인하여 처리 - sleep은 정수만 받으므로 usleep으로 변경 - 선언하지 않고 그냥 사용하던 member 변수 선언 - boolean operation 순서 틀린 부분 수정
136 lines
4.0 KiB
PHP
136 lines
4.0 KiB
PHP
<?php
|
|
namespace sammo\Command\General;
|
|
|
|
use \sammo\{
|
|
DB, Util, JosaUtil,
|
|
General,
|
|
ActionLogger,
|
|
GameConst, GameUnitConst,
|
|
LastTurn,
|
|
Command
|
|
};
|
|
|
|
|
|
use function \sammo\tryUniqueItemLottery;
|
|
|
|
use \sammo\Constraint\Constraint;
|
|
use \sammo\Constraint\ConstraintHelper;
|
|
|
|
|
|
|
|
class che_단련 extends Command\GeneralCommand{
|
|
static protected $actionName = '단련';
|
|
|
|
protected function argTest():bool{
|
|
$this->arg = null;
|
|
return true;
|
|
}
|
|
|
|
protected function init()
|
|
{
|
|
|
|
$general = $this->generalObj;
|
|
|
|
$this->setCity();
|
|
$this->setNation();
|
|
|
|
[$reqGold, $reqRice] = $this->getCost();
|
|
|
|
$this->fullConditionConstraints=[
|
|
ConstraintHelper::NotBeNeutral(),
|
|
ConstraintHelper::ReqGeneralCrew(),
|
|
ConstraintHelper::ReqGeneralValue('train', '훈련', '>=', GameConst::$defaultTrainLow),
|
|
ConstraintHelper::ReqGeneralValue('atmos', '사기', '>=', GameConst::$defaultAtmosLow),
|
|
ConstraintHelper::ReqGeneralGold($reqGold),
|
|
ConstraintHelper::ReqGeneralRice($reqRice),
|
|
];
|
|
|
|
}
|
|
|
|
public function getCommandDetailTitle():string{
|
|
$name = $this->getName();
|
|
[$reqGold, $reqRice] = $this->getCost();
|
|
|
|
$title = "{$name}(병종숙련";
|
|
if($reqGold > 0){
|
|
$title .= ", 자금{$reqGold}";
|
|
}
|
|
if($reqRice > 0){
|
|
$title .= ", 군량{$reqRice}";
|
|
}
|
|
$title .= ')';
|
|
return $title;
|
|
}
|
|
|
|
public function getCost():array{
|
|
$env = $this->env;
|
|
return [$env['develcost'], $env['develcost']];
|
|
}
|
|
|
|
public function getPreReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function getPostReqTurn():int{
|
|
return 0;
|
|
}
|
|
|
|
public function run():bool{
|
|
if(!$this->hasFullConditionMet()){
|
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
|
}
|
|
|
|
$db = DB::db();
|
|
|
|
$general = $this->generalObj;
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
|
|
[$pick, $multiplier] = Util::choiceRandomUsingWeightPair([
|
|
[['success', 3], 0.34],
|
|
[['normal', 2], 0.33],
|
|
[['fail', 1], 0.33]
|
|
]);
|
|
|
|
$score = Util::round($general->getVar('crew') * $general->getVar('train') * $general->getVar('atmos') / 20 / 10000);
|
|
$score *= $multiplier;
|
|
$scoreText = number_format($score, 0);
|
|
|
|
$armTypeText = GameUnitConst::allType()[$general->getCrewTypeObj()->armType];
|
|
|
|
$logger = $general->getLogger();
|
|
|
|
if($pick == 'fail'){
|
|
$logger->pushGeneralActionLog("단련이 <span class='ev_failed'>지지부진</span>하여 {$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
|
}
|
|
else if($pick == 'success'){
|
|
$logger->pushGeneralActionLog("단련이 <S>일취월장</>하여 {$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
|
}
|
|
else{
|
|
$logger->pushGeneralActionLog("{$armTypeText} 숙련도가 <C>{$scoreText}</> 향상되었습니다. <1>$date</>");
|
|
}
|
|
|
|
$exp = $general->getVar('crew') / 400;
|
|
|
|
$general->addDex($general->getCrewTypeObj(), $score, false);
|
|
|
|
$incStat = Util::choiceRandomUsingWeight([
|
|
'leadership_exp'=>$general->getLeadership(false, false, false, false),
|
|
'strength_exp'=>$general->getStrength(false, false, false, false),
|
|
'intel_exp'=>$general->getIntel(false, false, false, false)
|
|
]);
|
|
[$reqGold, $reqRice] = $this->getCost();
|
|
|
|
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
|
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
|
$general->addExperience($exp);
|
|
$general->increaseVar($incStat, 1);
|
|
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
|
$general->checkStatChange();
|
|
tryUniqueItemLottery($general);
|
|
$general->applyDB($db);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |