- 기존의 랜덤 코드는 deprecated 처리 - 서버 시작 시 랜덤하게 정해진 hiddenSeed를 활용 - 랜덤 생성 단위 - 월 실행 - 사령턴 실행 결과 - 커맨드 실행 결과 - 작위 보상 - 부대장 생성 - 유니크 획득 시도 - 설문 조사 - 장수 생성 - NPC국 생성, NPC 생성, NPC의 토너먼트 베팅 - 전투 - 도시 점령 - 자율 행동 선택 - 랜덤 턴 변경 - 거래장, 토너먼트 등 구 랜덤 코드를 이용하는 잔여 코드 있음
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(\Sammo\RandUtil $rng):bool{
|
|
if(!$this->hasFullConditionMet()){
|
|
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
|
}
|
|
|
|
$db = DB::db();
|
|
|
|
$general = $this->generalObj;
|
|
$date = $general->getTurnTime($general::TURNTIME_HM);
|
|
|
|
[$pick, $multiplier] = $rng->choiceUsingWeightPair([
|
|
[['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 = $rng->choiceUsingWeight([
|
|
'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(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
|
$general->applyDB($db);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
} |