feat,refac: 게임 로직 내 '랜덤'을 RandUtil을 활용하여 재설정
- 기존의 랜덤 코드는 deprecated 처리 - 서버 시작 시 랜덤하게 정해진 hiddenSeed를 활용 - 랜덤 생성 단위 - 월 실행 - 사령턴 실행 결과 - 커맨드 실행 결과 - 작위 보상 - 부대장 생성 - 유니크 획득 시도 - 설문 조사 - 장수 생성 - NPC국 생성, NPC 생성, NPC의 토너먼트 베팅 - 전투 - 도시 점령 - 자율 행동 선택 - 랜덤 턴 변경 - 거래장, 토너먼트 등 구 랜덤 코드를 이용하는 잔여 코드 있음
This commit is contained in:
@@ -6,7 +6,8 @@ use \sammo\{
|
||||
General, GameConst,
|
||||
ActionLogger,
|
||||
LastTurn,
|
||||
NotInheritedMethodException
|
||||
NotInheritedMethodException,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
use function \sammo\getNationStaticInfo;
|
||||
@@ -473,7 +474,7 @@ abstract class BaseCommand{
|
||||
abstract public function getPreReqTurn():int;
|
||||
abstract public function getPostReqTurn():int;
|
||||
|
||||
abstract public function run():bool;
|
||||
abstract public function run(RandUtil $rng):bool;
|
||||
|
||||
public function exportJSVars():array {
|
||||
return [];
|
||||
|
||||
@@ -75,7 +75,7 @@ class che_NPC능동 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class che_NPC능동 extends Command\GeneralCommand{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
}
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -111,7 +111,7 @@ class che_강행 extends Command\GeneralCommand
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -156,7 +156,7 @@ class che_강행 extends Command\GeneralCommand
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class che_거병 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class che_거병 extends Command\GeneralCommand{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
|
||||
use function sammo\buildNationTypeClass;
|
||||
use function sammo\genGenericUniqueRNGFromGeneral;
|
||||
use function sammo\refreshNationStaticInfo;
|
||||
use function sammo\GetNationColors;
|
||||
|
||||
@@ -126,7 +127,7 @@ class che_건국 extends Command\GeneralCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -190,7 +191,7 @@ class che_건국 extends Command\GeneralCommand
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general, '건국');
|
||||
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general), $general, '건국');
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -51,7 +51,7 @@ class che_견문 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -99,10 +99,10 @@ class che_견문 extends Command\GeneralCommand{
|
||||
$text = str_replace(':riceAmount:', '200', $text);
|
||||
}
|
||||
if($type & SightseeingMessage::Wounded){
|
||||
$general->increaseVarWithLimit('injury', Util::randRangeInt(10, 20), null, 80);
|
||||
$general->increaseVarWithLimit('injury', $rng->nextRangeInt(10, 20), null, 80);
|
||||
}
|
||||
if($type & SightseeingMessage::HeavyWounded){
|
||||
$general->increaseVarWithLimit('injury', Util::randRangeInt(20, 50), null, 80);
|
||||
$general->increaseVarWithLimit('injury', $rng->nextRangeInt(20, 50), null, 80);
|
||||
}
|
||||
|
||||
$logger = $general->getLogger();
|
||||
@@ -112,7 +112,7 @@ class che_견문 extends Command\GeneralCommand{
|
||||
$general->addExperience($exp);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class che_군량매매 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class che_군량매매 extends Command\GeneralCommand{
|
||||
$exp = 30;
|
||||
$ded = 50;
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
$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)
|
||||
@@ -178,7 +178,7 @@ class che_군량매매 extends Command\GeneralCommand{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class che_귀환 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class che_귀환 extends Command\GeneralCommand{
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
LastTurn,
|
||||
Command, GameConst
|
||||
@@ -11,7 +11,7 @@ use \sammo\{
|
||||
|
||||
use function sammo\{
|
||||
TechLimit,
|
||||
CriticalRatioDomestic,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery,
|
||||
updateMaxDomesticCritical
|
||||
@@ -38,11 +38,11 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['tech']);
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -53,7 +53,7 @@ class che_기술연구 extends che_상업투자{
|
||||
$this->reqGold = $reqGold;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
$trust = Util::valueFit($this->city['trust'], 50);
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
$score = Util::valueFit($this->calcBaseScore($rng), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
if($trust < 80){
|
||||
@@ -77,9 +77,9 @@ class che_기술연구 extends che_상업투자{
|
||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||
$normalRatio = 1 - $failRatio - $successRatio;
|
||||
|
||||
$pick = Util::choiceRandomUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
$pick = $rng->choiceUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
'normal'=>$normalRatio
|
||||
]);
|
||||
|
||||
@@ -87,14 +87,14 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score *= CriticalScoreEx($pick);
|
||||
$score *= CriticalScoreEx($rng, $pick);
|
||||
$score = Util::round($score);
|
||||
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
@@ -134,11 +134,11 @@ class che_기술연구 extends che_상업투자{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -35,9 +35,9 @@ class che_단련 extends Command\GeneralCommand{
|
||||
$this->setNation();
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
ConstraintHelper::ReqGeneralValue('train', '훈련', '>=', GameConst::$defaultTrainLow),
|
||||
ConstraintHelper::ReqGeneralValue('atmos', '사기', '>=', GameConst::$defaultAtmosLow),
|
||||
@@ -66,7 +66,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
$env = $this->env;
|
||||
return [$env['develcost'], $env['develcost']];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
[$pick, $multiplier] = Util::choiceRandomUsingWeightPair([
|
||||
[$pick, $multiplier] = $rng->choiceUsingWeightPair([
|
||||
[['success', 3], 0.34],
|
||||
[['normal', 2], 0.33],
|
||||
[['fail', 1], 0.33]
|
||||
@@ -113,7 +113,7 @@ class che_단련 extends Command\GeneralCommand{
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $score, false);
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
$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)
|
||||
@@ -126,11 +126,11 @@ class che_단련 extends Command\GeneralCommand{
|
||||
$general->increaseVar($incStat, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class che_등용 extends Command\GeneralCommand
|
||||
return "【{$destGeneralName}】{$josaUl} {$name}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -173,7 +173,7 @@ class che_등용 extends Command\GeneralCommand
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class che_등용수락 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use \sammo\GameUnitConst;
|
||||
use \sammo\LastTurn;
|
||||
use \sammo\Command;
|
||||
|
||||
use function sammo\genGenericUniqueRNGFromGeneral;
|
||||
use function \sammo\tryUniqueItemLottery;
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
@@ -110,7 +111,7 @@ class che_랜덤임관 extends Command\GeneralCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -162,7 +163,7 @@ class che_랜덤임관 extends Command\GeneralCommand
|
||||
$score = log($affinity + 1, 2); //0~
|
||||
|
||||
//쉐킷쉐킷
|
||||
$score += Util::randF();
|
||||
$score += $rng->nextFloat1();
|
||||
|
||||
$score += sqrt($testNation['gennum'] / $allGen);
|
||||
|
||||
@@ -219,7 +220,7 @@ class che_랜덤임관 extends Command\GeneralCommand
|
||||
}
|
||||
|
||||
if ($generalsCnt) {
|
||||
$destNation = Util::choiceRandomUsingWeightPair($generalsCnt);
|
||||
$destNation = $rng->choiceUsingWeightPair($generalsCnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +252,7 @@ class che_랜덤임관 extends Command\GeneralCommand
|
||||
'천하의 균형을 맞추기 위해',
|
||||
'오랜 은거를 마치고',
|
||||
];
|
||||
$randomTalk = Util::choiceRandom($talkList);
|
||||
$randomTalk = $rng->choice($talkList);
|
||||
|
||||
$logger->pushGeneralActionLog("<D>{$destNationName}</>에 랜덤 임관했습니다. <1>$date</>");
|
||||
$logger->pushGeneralHistoryLog("<D><b>{$destNationName}</b></>에 랜덤 임관");
|
||||
@@ -290,7 +291,7 @@ class che_랜덤임관 extends Command\GeneralCommand
|
||||
$general->addExperience($exp);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general, '랜덤 임관');
|
||||
tryUniqueItemLottery(genGenericUniqueRNGFromGeneral($general), $general, '랜덤 임관');
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -55,7 +55,7 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class che_모반시도 extends Command\GeneralCommand{
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
$lordGeneral->applyDB($db);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -70,14 +70,14 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
[$resName, $resKey] = Util::choiceRandom([
|
||||
[$resName, $resKey] = $rng->choice([
|
||||
['금', 'gold'],
|
||||
['쌀', 'rice']
|
||||
]);
|
||||
|
||||
$score = $general->getLeadership() + $general->getStrength() + $general->getIntel();
|
||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||
$score *= Util::randRange(0.8, 1.2);
|
||||
$score *= $rng->nextRange(0.8, 1.2);
|
||||
|
||||
$successRatio = 0.1;
|
||||
$failRatio = 0.3;
|
||||
@@ -86,12 +86,12 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
$failRatio = $general->onCalcDomestic('조달', 'fail', $failRatio);
|
||||
$normalRatio = 1 - $failRatio - $successRatio;
|
||||
|
||||
$pick = Util::choiceRandomUsingWeight([
|
||||
$pick = $rng->choiceUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
'normal'=>$normalRatio
|
||||
]);
|
||||
$score *= CriticalScoreEx($pick);
|
||||
$score *= CriticalScoreEx($rng, $pick);
|
||||
$score = $general->onCalcDomestic('조달', 'score', $score);
|
||||
|
||||
$score = Util::round($score);
|
||||
@@ -112,7 +112,7 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
$exp = $score * 0.7 / 3;
|
||||
$ded = $score * 1.0 / 3;
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
$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)
|
||||
@@ -128,7 +128,7 @@ class che_물자조달 extends Command\GeneralCommand{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class che_방랑 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class che_방랑 extends Command\GeneralCommand{
|
||||
refreshNationStaticInfo();
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -34,13 +34,13 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
];
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
@@ -62,7 +62,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$general = $this->generalObj;
|
||||
return [Util::round($general->getVar('crew')/100), 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -103,11 +103,11 @@ class che_사기진작 extends Command\GeneralCommand{
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,12 +3,13 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
Command,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
use function \sammo\getDomesticExpLevelBonus;
|
||||
@@ -41,11 +42,11 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -82,15 +83,15 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
$develCost = $this->env['develcost'];
|
||||
$reqGold = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||
$reqRice = 0;
|
||||
|
||||
|
||||
return [$reqGold, $reqRice];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getCompensationStyle():?int{
|
||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function calcBaseScore():float{
|
||||
protected function calcBaseScore(RandUtil $rng):float{
|
||||
$trust = Util::valueFit($this->city['trust'], 50);
|
||||
$general = $this->generalObj;
|
||||
|
||||
@@ -115,16 +116,16 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
else{
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
|
||||
$score *= $trust / 100;
|
||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||
$score *= Util::randRange(0.8, 1.2);
|
||||
$score *= $rng->nextRange(0.8, 1.2);
|
||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -135,7 +136,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
$trust = Util::valueFit($this->city['trust'], 50);
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
$score = Util::valueFit($this->calcBaseScore($rng), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
if($trust < 80){
|
||||
@@ -148,9 +149,9 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||
$normalRatio = 1 - $failRatio - $successRatio;
|
||||
|
||||
$pick = Util::choiceRandomUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
$pick = $rng->choiceUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
'normal'=>$normalRatio
|
||||
]);
|
||||
|
||||
@@ -158,14 +159,14 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score *= CriticalScoreEx($pick);
|
||||
$score *= CriticalScoreEx($rng, $pick);
|
||||
$score = Util::round($score);
|
||||
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
@@ -204,7 +205,7 @@ class che_상업투자 extends Command\GeneralCommand{
|
||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -9,6 +9,7 @@ use \sammo\ActionLogger;
|
||||
use \sammo\GameConst;
|
||||
use \sammo\GameUnitConst;
|
||||
use \sammo\Command;
|
||||
use sammo\RandUtil;
|
||||
|
||||
class che_선동 extends che_화계{
|
||||
static protected $actionName = '선동';
|
||||
@@ -16,7 +17,7 @@ class che_선동 extends che_화계{
|
||||
static protected $statType = 'leadership';
|
||||
static protected $injuryGeneral = true;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
protected function affectDestCity(RandUtil $rng, int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
@@ -30,15 +31,15 @@ class che_선동 extends che_화계{
|
||||
$commandName = $this->getName();
|
||||
|
||||
// 선동 최대 10
|
||||
$secuAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['secu']);
|
||||
$secuAmount = Util::valueFit($rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['secu']);
|
||||
$trustAmount = Util::valueFit(
|
||||
Util::randRange(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) / 50,
|
||||
null,
|
||||
$rng->nextRange(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) / 50,
|
||||
null,
|
||||
$destCity['trust']
|
||||
);
|
||||
$destCity['secu'] -= $secuAmount;
|
||||
$destCity['trust'] -= $trustAmount;
|
||||
|
||||
|
||||
DB::db()->update('city', [
|
||||
'state'=>32,
|
||||
'secu'=>$destCity['secu'],
|
||||
@@ -57,5 +58,5 @@ class che_선동 extends che_화계{
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class che_선양 extends Command\GeneralCommand
|
||||
return "【{$destGeneralName}】에게 {$name}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -139,7 +139,7 @@ class che_선양 extends Command\GeneralCommand
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
$destGeneral->applyDB($db);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class che_소집해제 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -82,7 +82,7 @@ class che_소집해제 extends Command\GeneralCommand{
|
||||
$general->addDedication($ded);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -144,7 +144,7 @@ class che_숙련전환 extends Command\GeneralCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -179,7 +179,7 @@ class che_숙련전환 extends Command\GeneralCommand
|
||||
$general->increaseVar('leadership_exp', 2);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -46,7 +46,7 @@ class che_요양 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class che_요양 extends Command\GeneralCommand{
|
||||
$general->addDedication($ded);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -53,7 +53,7 @@ class che_은퇴 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class che_은퇴 extends Command\GeneralCommand{
|
||||
$logger->pushGeneralActionLog("은퇴하였습니다. <1>$date</>");
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -119,7 +119,7 @@ class che_이동 extends Command\GeneralCommand
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -164,7 +164,7 @@ class che_이동 extends Command\GeneralCommand
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
return $foundProp;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -128,14 +128,14 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||
|
||||
$foundProp = $this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt);
|
||||
$foundNpc = Util::randBool($foundProp);
|
||||
$foundNpc = $rng->nextBool($foundProp);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if (!$foundNpc) {
|
||||
$logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date</>");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
$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)
|
||||
@@ -152,7 +152,7 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
$general->increaseVar($incStat, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
@@ -163,9 +163,9 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
|
||||
$scoutType = "발견";
|
||||
|
||||
$age = Util::randRangeInt(20, 25);
|
||||
$age = $rng->nextRangeInt(20, 25);
|
||||
$birthYear = $env['year'] - $age;
|
||||
$deathYear = $env['year'] + Util::randRangeInt(10, 50);
|
||||
$deathYear = $env['year'] + $rng->nextRangeInt(10, 50);
|
||||
|
||||
$avgGen = $db->queryFirstRow(
|
||||
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
||||
@@ -175,7 +175,7 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
|
||||
$pickTypeList = ['무' => 6, '지' => 6, '무지' => 3];
|
||||
|
||||
$pickedNPC = pickGeneralFromPool($db, 0, 1)[0];
|
||||
$pickedNPC = pickGeneralFromPool($db, $rng, 0, 1)[0];
|
||||
$newNPC = $pickedNPC->getGeneralBuilder();
|
||||
|
||||
$newNPC->setSpecial('None', 'None');
|
||||
@@ -200,7 +200,7 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!");
|
||||
$logger->pushGeneralHistoryLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
$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)
|
||||
@@ -218,7 +218,7 @@ class che_인재탐색 extends Command\GeneralCommand
|
||||
$general->increaseVar($incStat, 3);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class che_임관 extends Command\GeneralCommand
|
||||
return "【{$destNationName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -179,7 +179,7 @@ class che_임관 extends Command\GeneralCommand
|
||||
$general->addExperience($exp);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -141,7 +141,7 @@ class che_장비매매 extends Command\GeneralCommand
|
||||
return "【{$itemName}】{$josaUl} 구입";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -174,11 +174,11 @@ class che_장비매매 extends Command\GeneralCommand
|
||||
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 구입했습니다. <1>$date</>");
|
||||
$general->increaseVarWithLimit('gold', -$cost, 0);
|
||||
$general->setItem($itemType, $itemCode);
|
||||
$general->onArbitraryAction($general, '장비매매', '구매', ['itemCode' => $itemCode]);
|
||||
$general->onArbitraryAction($general, $rng, '장비매매', '구매', ['itemCode' => $itemCode]);
|
||||
} else {
|
||||
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 판매했습니다. <1>$date</>");
|
||||
$general->increaseVarWithLimit('gold', $cost / 2);
|
||||
$general->onArbitraryAction($general, '장비매매', '판매', ['itemCode' => $itemCode]);
|
||||
$general->onArbitraryAction($general, $rng, '장비매매', '판매', ['itemCode' => $itemCode]);
|
||||
$general->setItem($itemType, null);
|
||||
|
||||
if(!$itemObj->isBuyable()){
|
||||
@@ -195,7 +195,7 @@ class che_장비매매 extends Command\GeneralCommand
|
||||
$general->addExperience($exp);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -116,7 +116,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
return "【{$destGeneralName}】{$josaUl} 따라 임관";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class che_장수대상임관 extends Command\GeneralCommand{
|
||||
$general->addExperience($exp);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -34,9 +34,9 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
$this->setNation();
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
@@ -53,7 +53,7 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
$techCost = getTechCost($this->nation['tech']);
|
||||
return [Util::round($crew / 100 * 3 * $techCost), 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 3;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
$logger->pushGeneralActionLog("전투태세 완료! ({$term}/3) <1>$date</>");
|
||||
|
||||
$general->increaseVarWithLimit('train', 0, GameConst::$maxTrainByCommand - 5); //95보다 높으면 '깎이지는 않음'
|
||||
@@ -117,15 +117,15 @@ class che_전투태세 extends Command\GeneralCommand{
|
||||
$crew = $general->getVar('crew');
|
||||
|
||||
$general->addDex($general->getCrewTypeObj(), $crew / 100 * 3, false);
|
||||
|
||||
|
||||
$general->increaseVar('leadership_exp', 3);
|
||||
$this->setResultTurn($turnResult);
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -32,7 +32,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.'),
|
||||
];
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::ReqGeneralValue(static::$specialType, static::$specialText, '!=', 'None', '특기가 없습니다.')
|
||||
];
|
||||
@@ -54,7 +54,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 1;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
||||
return "새로운 적성을 찾는 중... ({$term}/{$termMax})";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
||||
$specialName = static::$specialText;
|
||||
|
||||
$env = $this->env;
|
||||
|
||||
|
||||
$yearMonth = Util::joinYearMonth($env['year'], $env['month']);
|
||||
$oldSpecialList = $general->getAuxVar($oldTypeKey)??[];
|
||||
$oldSpecialList[] = $general->getVar(static::$specialType);
|
||||
@@ -97,11 +97,11 @@ class che_전투특기초기화 extends Command\GeneralCommand{
|
||||
$logger->pushGeneralActionLog("새로운 {$specialName}를 가질 준비가 되었습니다. <1>$date</>");
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,12 +3,13 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
Command,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
use function \sammo\getDomesticExpLevelBonus;
|
||||
@@ -40,11 +41,11 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -81,14 +82,14 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
$develCost = $this->env['develcost'] * 2;
|
||||
$reqGold = 0;
|
||||
$reqRice = Util::round($this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost));
|
||||
|
||||
|
||||
return [$reqGold, $reqRice];
|
||||
}
|
||||
|
||||
public function getCompensationStyle():?int{
|
||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +98,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function calcBaseScore():float{
|
||||
protected function calcBaseScore(RandUtil $rng):float{
|
||||
$general = $this->generalObj;
|
||||
|
||||
if(static::$statKey == 'leadership'){
|
||||
@@ -106,15 +107,15 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
else{
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
|
||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||
$score *= Util::randRange(0.8, 1.2);
|
||||
$score *= $rng->nextRange(0.8, 1.2);
|
||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -123,7 +124,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
$score = Util::valueFit($this->calcBaseScore($rng), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||
@@ -133,9 +134,9 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||
$normalRatio = 1 - $failRatio - $successRatio;
|
||||
|
||||
$pick = Util::choiceRandomUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
$pick = $rng->choiceUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
'normal'=>$normalRatio
|
||||
]);
|
||||
|
||||
@@ -143,14 +144,14 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score *= CriticalScoreEx($pick);
|
||||
$score *= CriticalScoreEx($rng, $pick);
|
||||
$score = Util::round($score);
|
||||
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
@@ -187,7 +188,7 @@ class che_정착장려 extends Command\GeneralCommand{
|
||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,12 +3,13 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
Command,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
use function \sammo\getDomesticExpLevelBonus;
|
||||
@@ -40,11 +41,11 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
@@ -81,14 +82,14 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
$develCost = $this->env['develcost'] * 2;
|
||||
$reqGold = 0;
|
||||
$reqRice = $this->generalObj->onCalcDomestic(static::$actionKey, 'cost', $develCost);
|
||||
|
||||
|
||||
return [$reqGold, Util::round($reqRice)];
|
||||
}
|
||||
|
||||
public function getCompensationStyle():?int{
|
||||
return $this->generalObj->onCalcDomestic(static::$actionKey, 'score', 100)<=>100;
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +98,7 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function calcBaseScore():float{
|
||||
protected function calcBaseScore(RandUtil $rng):float{
|
||||
$general = $this->generalObj;
|
||||
|
||||
if(static::$statKey == 'leadership'){
|
||||
@@ -106,16 +107,16 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
else{
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
|
||||
$score *= getDomesticExpLevelBonus($general->getVar('explevel'));
|
||||
$score *= Util::randRange(0.8, 1.2);
|
||||
$score *= $rng->nextRange(0.8, 1.2);
|
||||
$score = $general->onCalcDomestic(static::$actionKey, 'score', $score);
|
||||
$score = Util::valueFit($score, 1);
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -124,7 +125,7 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$score = Util::valueFit($this->calcBaseScore(), 1);
|
||||
$score = Util::valueFit($this->calcBaseScore($rng), 1);
|
||||
|
||||
['success'=>$successRatio, 'fail'=>$failRatio] = CriticalRatioDomestic($general, static::$statKey);
|
||||
$successRatio = $general->onCalcDomestic(static::$actionKey, 'success', $successRatio);
|
||||
@@ -134,9 +135,9 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
$failRatio = Util::valueFit($failRatio, 0, 1 - $successRatio);
|
||||
$normalRatio = 1 - $failRatio - $successRatio;
|
||||
|
||||
$pick = Util::choiceRandomUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
$pick = $rng->choiceUsingWeight([
|
||||
'fail'=>$failRatio,
|
||||
'success'=>$successRatio,
|
||||
'normal'=>$normalRatio
|
||||
]);
|
||||
|
||||
@@ -144,13 +145,13 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$score *= CriticalScoreEx($pick);
|
||||
$score *= CriticalScoreEx($rng, $pick);
|
||||
|
||||
$exp = $score * 0.7;
|
||||
$ded = $score * 1.0;
|
||||
|
||||
if($pick == 'success'){
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
updateMaxDomesticCritical($general, $score);
|
||||
}
|
||||
else{
|
||||
$general->setAuxVar('max_domestic_critical', 0);
|
||||
@@ -187,11 +188,11 @@ class che_주민선정 extends Command\GeneralCommand{
|
||||
$general->increaseVar(static::$statKey.'_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -132,7 +132,7 @@ class che_증여 extends Command\GeneralCommand
|
||||
return "【{$destGeneralName}】에게 {$resText} {$this->arg['amount']}을 {$name}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -169,7 +169,7 @@ class che_증여 extends Command\GeneralCommand
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
|
||||
$general->applyDB($db);
|
||||
$destGeneral->applyDB($db);
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -34,9 +34,9 @@ class che_집합 extends Command\GeneralCommand{
|
||||
$this->setNation();
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::MustBeTroopLeader(),
|
||||
@@ -52,7 +52,7 @@ class che_집합 extends Command\GeneralCommand{
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class che_집합 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -103,11 +103,11 @@ class che_집합 extends Command\GeneralCommand{
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -162,7 +162,7 @@ class che_징병 extends Command\GeneralCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -222,7 +222,7 @@ class che_징병 extends Command\GeneralCommand
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
$general->setAuxVar('armType', $reqCrewType->armType);
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -120,7 +120,7 @@ class che_첩보 extends Command\GeneralCommand
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -202,8 +202,8 @@ class che_첩보 extends Command\GeneralCommand
|
||||
'spy'=>Json::encode($spyInfo)
|
||||
], 'nation=%i',$nationID);
|
||||
|
||||
$exp = Util::randRangeInt(1, 100);
|
||||
$ded = Util::randRangeInt(1, 70);
|
||||
$exp = $rng->nextRangeInt(1, 100);
|
||||
$ded = $rng->nextRangeInt(1, 70);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$general->increaseInheritancePoint(InheritanceKey::active_action, 0.5);//NOTE: 첩보만 예외!
|
||||
@@ -214,7 +214,7 @@ class che_첩보 extends Command\GeneralCommand
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,9 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\CityConst;
|
||||
use sammo\Enums\InheritanceKey;
|
||||
use sammo\LiteHashDRBG;
|
||||
use sammo\RandUtil;
|
||||
use sammo\UniqueConst;
|
||||
|
||||
class che_출병 extends Command\GeneralCommand
|
||||
{
|
||||
@@ -127,7 +130,7 @@ class che_출병 extends Command\GeneralCommand
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>{$josaRo} {$commandName} 실패.";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -188,7 +191,7 @@ class che_출병 extends Command\GeneralCommand
|
||||
}
|
||||
} while (false);
|
||||
|
||||
$defenderCityID = (int) Util::choiceRandom($candidateCities);
|
||||
$defenderCityID = (int) $rng->choice($candidateCities);
|
||||
$this->setDestCity($defenderCityID);
|
||||
$defenderCityName = $this->destCity['name'];
|
||||
$josaRo = JosaUtil::pick($defenderCityName, '로');
|
||||
@@ -236,9 +239,21 @@ class che_출병 extends Command\GeneralCommand
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
processWar($general, $this->nation, $this->destCity);
|
||||
|
||||
tryUniqueItemLottery($general);
|
||||
//어디로 출병하느냐에 따라 사실 결과가 다르다
|
||||
$warRngPre = new LiteHashDRBG(Util::simpleSerialize(
|
||||
UniqueConst::$hiddenSeed,
|
||||
'war',
|
||||
$logger->getYear(),
|
||||
$logger->getMonth(),
|
||||
$general->getID(),
|
||||
$defenderCityID,
|
||||
));
|
||||
$warRngSeed = bin2hex($warRngPre->nextBytes(16));
|
||||
|
||||
processWar($warRngSeed, $general, $this->nation, $this->destCity);
|
||||
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,8 @@ use \sammo\{
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
Command
|
||||
Command,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
class che_탈취 extends che_화계{
|
||||
@@ -15,7 +16,7 @@ class che_탈취 extends che_화계{
|
||||
static protected $statType = 'strength';
|
||||
static protected $injuryGeneral = false;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
protected function affectDestCity(RandUtil $rng, int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$nationID = $general->getNationID();
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
@@ -35,8 +36,8 @@ class che_탈취 extends che_화계{
|
||||
$yearCoef = sqrt(1 + ($this->env['year'] - $this->env['startyear']) / 4) / 2;
|
||||
$commRatio = $destCity['comm'] / $destCity['comm_max'];
|
||||
$agriRatio = $destCity['agri'] / $destCity['agri_max'];
|
||||
$gold = Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $commRatio / 4);
|
||||
$rice = Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $agriRatio / 4);
|
||||
$gold = $rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $commRatio / 4);
|
||||
$rice = $rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax) * $destCity['level'] * $yearCoef * (0.25 + $agriRatio / 4);
|
||||
|
||||
if($destCity['supply']){
|
||||
[$destNationGold, $destNationRice] = $db->queryFirstList('SELECT gold,rice FROM nation WHERE nation=%i', $destNationID);
|
||||
|
||||
@@ -3,10 +3,11 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
Command
|
||||
Command,
|
||||
RandUtil
|
||||
};
|
||||
|
||||
class che_파괴 extends che_화계{
|
||||
@@ -15,7 +16,7 @@ class che_파괴 extends che_화계{
|
||||
static protected $statType = 'strength';
|
||||
static protected $injuryGeneral = true;
|
||||
|
||||
protected function affectDestCity(int $injuryCount){
|
||||
protected function affectDestCity(RandUtil $rng, int $injuryCount){
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
@@ -29,8 +30,8 @@ class che_파괴 extends che_화계{
|
||||
$commandName = $this->getName();
|
||||
|
||||
// 파괴
|
||||
$defAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['def']);
|
||||
$wallAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['wall']);
|
||||
$defAmount = Util::valueFit($rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['def']);
|
||||
$wallAmount = Util::valueFit($rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['wall']);
|
||||
if($defAmount < 0){ $defAmount = 0; }
|
||||
if($wallAmount < 0){ $wallAmount = 0; }
|
||||
|
||||
@@ -56,5 +57,5 @@ class che_파괴 extends che_화계{
|
||||
ActionLogger::PLAIN
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class che_하야 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -118,7 +118,7 @@ class che_하야 extends Command\GeneralCommand{
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -57,7 +57,7 @@ class che_해산 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class che_해산 extends Command\GeneralCommand{
|
||||
$oldGeneral->setVar('makelimit', 12);
|
||||
$oldGeneral->applyDB($db);
|
||||
}
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
// 이벤트 핸들러 동작
|
||||
|
||||
@@ -107,7 +107,7 @@ class che_헌납 extends Command\GeneralCommand
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -146,7 +146,7 @@ class che_헌납 extends Command\GeneralCommand
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,7 @@ use function sammo\tryRollbackInheritUniqueItem;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\CityConst;
|
||||
use sammo\Enums\RankColumn;
|
||||
use sammo\RandUtil;
|
||||
|
||||
class che_화계 extends Command\GeneralCommand
|
||||
{
|
||||
@@ -200,7 +201,7 @@ class che_화계 extends Command\GeneralCommand
|
||||
return "{$failReason} <G><b>{$destCityName}</b></>에 {$commandName} 실패.";
|
||||
}
|
||||
|
||||
protected function affectDestCity(int $injuryCount)
|
||||
protected function affectDestCity(RandUtil $rng, int $injuryCount)
|
||||
{
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
@@ -214,8 +215,8 @@ class che_화계 extends Command\GeneralCommand
|
||||
|
||||
$commandName = $this->getName();
|
||||
|
||||
$agriAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['agri']);
|
||||
$commAmount = Util::valueFit(Util::randRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['comm']);
|
||||
$agriAmount = Util::valueFit($rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['agri']);
|
||||
$commAmount = Util::valueFit($rng->nextRangeInt(GameConst::$sabotageDamageMin, GameConst::$sabotageDamageMax), null, $destCity['comm']);
|
||||
$destCity['agri'] -= $agriAmount;
|
||||
$destCity['comm'] -= $commAmount;
|
||||
|
||||
@@ -239,7 +240,7 @@ class che_화계 extends Command\GeneralCommand
|
||||
);
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -279,12 +280,12 @@ class che_화계 extends Command\GeneralCommand
|
||||
$prob /= $dist;
|
||||
$prob = Util::valueFit($prob, 0, 0.5);
|
||||
|
||||
if (!Util::randBool($prob)) {
|
||||
if (!$rng->nextBool($prob)) {
|
||||
$josaYi = JosaUtil::pick($commandName, '이');
|
||||
$logger->pushGeneralActionLog("<G><b>{$destCityName}</b></>에 {$commandName}{$josaYi} 실패했습니다. <1>$date</>");
|
||||
|
||||
$exp = Util::randRangeInt(1, 100);
|
||||
$ded = Util::randRangeInt(1, 70);
|
||||
$exp = $rng->nextRangeInt(1, 100);
|
||||
$ded = $rng->nextRangeInt(1, 70);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
@@ -295,18 +296,18 @@ class che_화계 extends Command\GeneralCommand
|
||||
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (static::$injuryGeneral) {
|
||||
$injuryCount = \sammo\SabotageInjury($destCityGeneralList, '계략');
|
||||
$injuryCount = \sammo\SabotageInjury($rng, $destCityGeneralList, '계략');
|
||||
} else {
|
||||
$injuryCount = 0;
|
||||
}
|
||||
|
||||
$this->affectDestCity($injuryCount);
|
||||
$this->affectDestCity($rng, $injuryCount);
|
||||
|
||||
$itemObj = $general->getItem();
|
||||
if ($itemObj->tryConsumeNow($general, 'GeneralCommand', '계략')) {
|
||||
@@ -317,8 +318,8 @@ class che_화계 extends Command\GeneralCommand
|
||||
$general->deleteItem();
|
||||
}
|
||||
|
||||
$exp = Util::randRangeInt(201, 300);
|
||||
$ded = Util::randRangeInt(141, 210);
|
||||
$exp = $rng->nextRangeInt(201, 300);
|
||||
$ded = $rng->nextRangeInt(141, 210);
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
@@ -329,7 +330,7 @@ class che_화계 extends Command\GeneralCommand
|
||||
$general->increaseRankVar(RankColumn::firenum, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace sammo\Command\General;
|
||||
|
||||
use \sammo\{
|
||||
DB, Util, JosaUtil,
|
||||
General,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst, GameUnitConst,
|
||||
LastTurn,
|
||||
@@ -33,13 +33,13 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$this->setNation();
|
||||
|
||||
$this->minConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
];
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotBeNeutral(),
|
||||
ConstraintHelper::NotWanderingNation(),
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::ReqGeneralCrew(),
|
||||
@@ -66,7 +66,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 0;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -107,11 +107,11 @@ class che_훈련 extends Command\GeneralCommand{
|
||||
$general->increaseVar('leadership_exp', 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
tryUniqueItemLottery(\sammo\genGenericUniqueRNGFromGeneral($general), $general);
|
||||
$general->applyDB($db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -34,14 +34,14 @@ class 휴식 extends Command\GeneralCommand{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
$general = $this->generalObj;
|
||||
$logger = $general->getLogger();
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
$logger->pushGeneralActionLog("아무것도 실행하지 않았습니다. <1>$date</>");
|
||||
|
||||
$this->setResultTurn(new LastTurn());
|
||||
tryRollbackInheritUniqueItem($general);
|
||||
tryRollbackInheritUniqueItem($rng, $general);
|
||||
$general->applyDB(DB::db());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class che_감축 extends Command\NationCommand{
|
||||
return "수도를 {$commandName}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class che_국기변경 extends Command\NationCommand
|
||||
return "【<span style='color:{$color};'>국기</span>】를 변경";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -103,7 +103,7 @@ class che_국호변경 extends Command\NationCommand
|
||||
return "국호를 【{$newNationName}】{$josaRo} 변경";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -121,7 +121,7 @@ class che_급습 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -141,7 +141,7 @@ class che_몰수 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -168,7 +168,7 @@ class che_몰수 extends Command\NationCommand
|
||||
);
|
||||
$amountText = number_format($amount, 0);
|
||||
|
||||
if ($destGeneral->getNPCType() >= 2 && Util::randBool(GameConst::$npcSeizureMessageProb)) {
|
||||
if ($destGeneral->getNPCType() >= 2 && $rng->nextBool(GameConst::$npcSeizureMessageProb)) {
|
||||
$npcTexts = [
|
||||
'몰수를 하다니... 이것이 윗사람이 할 짓이란 말입니까...',
|
||||
'사유재산까지 몰수해가면서 이 나라가 잘 될거라 믿습니까? 정말 이해할 수가 없군요...',
|
||||
@@ -176,7 +176,7 @@ class che_몰수 extends Command\NationCommand
|
||||
'몰수해간 내 자금... 언젠가 몰래 다시 빼내올 것이다...',
|
||||
'몰수로 인한 사기 저하는 몰수로 얻은 물자보다 더 손해란걸 모른단 말인가!'
|
||||
];
|
||||
$text = Util::choiceRandom($npcTexts);
|
||||
$text = $rng->choice($npcTexts);
|
||||
$src = new MessageTarget(
|
||||
$destGeneral->getID(),
|
||||
$destGeneral->getName(),
|
||||
|
||||
@@ -155,7 +155,7 @@ class che_물자원조 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -129,7 +129,7 @@ class che_발령 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -111,7 +111,7 @@ class che_백성동원 extends Command\NationCommand
|
||||
return "【{$destCityName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -22,6 +22,7 @@ use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\Json;
|
||||
use sammo\KVStorage;
|
||||
use sammo\RandUtil;
|
||||
|
||||
class che_불가침수락 extends Command\NationCommand
|
||||
{
|
||||
@@ -165,7 +166,7 @@ class che_불가침수락 extends Command\NationCommand
|
||||
return "{$year}년 {$month}월까지 불가침 합의";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -148,7 +148,7 @@ class che_불가침제의 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -20,6 +20,7 @@ use function \sammo\getNationStaticInfo;
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
use sammo\RandUtil;
|
||||
|
||||
class che_불가침파기수락 extends Command\NationCommand
|
||||
{
|
||||
@@ -71,7 +72,7 @@ class che_불가침파기수락 extends Command\NationCommand
|
||||
|
||||
$this->permissionConstraints = [
|
||||
ConstraintHelper::AlwaysFail('예약 불가능 커맨드')
|
||||
];
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
@@ -120,7 +121,7 @@ class che_불가침파기수락 extends Command\NationCommand
|
||||
return "{$destNationName}국과 불가침 파기 합의";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -102,7 +102,7 @@ class che_불가침파기제의 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ class che_선전포고 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -116,7 +116,7 @@ class che_수몰 extends Command\NationCommand
|
||||
return "【{$destCityName}】{$josaUl} {$commandName}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -74,7 +74,7 @@ class che_의병모집 extends Command\NationCommand
|
||||
return $nextTerm;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -143,8 +143,8 @@ class che_의병모집 extends Command\NationCommand
|
||||
from general where nation=%i',
|
||||
$nationID
|
||||
);
|
||||
foreach(\sammo\pickGeneralFromPool($db, 0, $createGenCnt) as $pickedNPC){
|
||||
|
||||
foreach(\sammo\pickGeneralFromPool($db, $rng, 0, $createGenCnt) as $pickedNPC){
|
||||
|
||||
$newNPC = $pickedNPC->getGeneralBuilder();
|
||||
|
||||
$newNPC->setCityID($general->getCityID());
|
||||
@@ -152,12 +152,12 @@ class che_의병모집 extends Command\NationCommand
|
||||
|
||||
$newNPC->setSpecial('None', 'None');
|
||||
$newNPC->setLifeSpan($env['year']-20, $env['year']+10);
|
||||
$newNPC->setKillturn(Util::randRangeInt(64, 70));
|
||||
$newNPC->setKillturn($rng->nextRangeInt(64, 70));
|
||||
$newNPC->setNPCType(4);
|
||||
$newNPC->setMoney(1000, 1000);
|
||||
$newNPC->setSpecYear(19, 19);
|
||||
$newNPC->fillRemainSpecAsRandom($pickTypeList, $avgGen, $env);
|
||||
|
||||
|
||||
$newNPC->build($this->env);
|
||||
$pickedNPC->occupyGeneralName();
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class che_이호경식 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -76,7 +76,7 @@ class che_종전수락 extends Command\NationCommand
|
||||
$this->setCity();
|
||||
$this->setNation();
|
||||
|
||||
|
||||
|
||||
$nationID = $this->nation['nation'];
|
||||
|
||||
$this->permissionConstraints = [
|
||||
@@ -129,7 +129,7 @@ class che_종전수락 extends Command\NationCommand
|
||||
return "{$destNationName}국과 종전 합의";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -100,7 +100,7 @@ class che_종전제의 extends Command\NationCommand{
|
||||
}
|
||||
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ class che_증축 extends Command\NationCommand{
|
||||
return "수도를 {$commandName}";
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class che_천도 extends Command\NationCommand
|
||||
return "【{$destCityName}】{$josaRo} {$commandName}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -124,7 +124,7 @@ class che_초토화 extends Command\NationCommand{
|
||||
return Util::toInt($amount);
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class che_포상 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -159,7 +159,7 @@ class che_피장파장 extends Command\NationCommand
|
||||
}
|
||||
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
|
||||
@@ -33,7 +33,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['strategic_cmd_limit']);
|
||||
|
||||
|
||||
$this->fullConditionConstraints=[
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
@@ -43,7 +43,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
ConstraintHelper::AvailableStrategicCommand()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getCommandDetailTitle():string{
|
||||
$name = $this->getName();
|
||||
$reqTurn = $this->getPreReqTurn()+1;
|
||||
@@ -51,24 +51,24 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
|
||||
return "{$name}/{$reqTurn}턴(재사용 대기 $postReqTurn)";
|
||||
}
|
||||
|
||||
|
||||
public function getCost():array{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getPostReqTurn():int{
|
||||
$genCount = Util::valueFit($this->nation['gennum'], GameConst::$initialNationGenLimit);
|
||||
$nextTerm = Util::round(sqrt($genCount*8)*10);
|
||||
$nextTerm = Util::round(sqrt($genCount*8)*10);
|
||||
|
||||
$nextTerm = $this->generalObj->onCalcStrategic($this->getName(), 'delay', $nextTerm);
|
||||
return $nextTerm;
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
if(!$this->hasFullConditionMet()){
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
$generalID = $general->getID();
|
||||
$generalName = $general->getName();
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
|
||||
$nationID = $general->getNationID();
|
||||
$nationName = $this->nation['name'];
|
||||
|
||||
@@ -101,8 +101,8 @@ class che_필사즉생 extends Command\NationCommand{
|
||||
}
|
||||
if($targetGeneral->getVar('atmos') < 100){
|
||||
$targetGeneral->setVar('atmos', 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$targetGeneral->applyDB($db);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class che_허보 extends Command\NationCommand
|
||||
return "【{$destCityName}】에 {$commandName}";
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
public function run(\Sammo\RandUtil $rng): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
@@ -167,10 +167,10 @@ class che_허보 extends Command\NationCommand
|
||||
$targetLogger = $targetGeneral->getLogger();
|
||||
$targetLogger->pushGeneralActionLog($destBroadcastMessage, ActionLogger::PLAIN);
|
||||
|
||||
$moveCityID = Util::choiceRandom($destNationCityList);
|
||||
$moveCityID = $rng->choice($destNationCityList);
|
||||
if ($moveCityID == $destCityID) {
|
||||
//현재도시면 다시 랜덤 추첨
|
||||
$moveCityID = Util::choiceRandom($destNationCityList);
|
||||
$moveCityID = $rng->choice($destNationCityList);
|
||||
}
|
||||
|
||||
$targetGeneral->setVar('city', $moveCityID);
|
||||
|
||||
@@ -16,7 +16,7 @@ class 휴식 extends Command\NationCommand{
|
||||
protected function init(){
|
||||
//아무것도 하지 않음
|
||||
$this->fullConditionConstraints=[];
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getPreReqTurn():int{
|
||||
@@ -31,7 +31,7 @@ class 휴식 extends Command\NationCommand{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public function run():bool{
|
||||
public function run(\Sammo\RandUtil $rng):bool{
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user