feat,refac: 게임 로직 내 '랜덤'을 RandUtil을 활용하여 재설정
- 기존의 랜덤 코드는 deprecated 처리 - 서버 시작 시 랜덤하게 정해진 hiddenSeed를 활용 - 랜덤 생성 단위 - 월 실행 - 사령턴 실행 결과 - 커맨드 실행 결과 - 작위 보상 - 부대장 생성 - 유니크 획득 시도 - 설문 조사 - 장수 생성 - NPC국 생성, NPC 생성, NPC의 토너먼트 베팅 - 전투 - 도시 점령 - 자율 행동 선택 - 랜덤 턴 변경 - 거래장, 토너먼트 등 구 랜덤 코드를 이용하는 잔여 코드 있음
This commit is contained in:
@@ -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