From b22987f21b590c6f02ac5d1b4f3829ba50fdec75 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 17 May 2022 23:28:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A7=84=ED=96=89=20=EC=A4=91=20$rng=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EA=B4=80=EB=A0=A8=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 4 +++- hwe/sammo/TurnExecutionHelper.php | 2 +- hwe/sammo/WarUnit.php | 4 +--- hwe/sammo/WarUnitCity.php | 3 +-- hwe/sammo/WarUnitGeneral.php | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index b697723e..66774df1 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1247,7 +1247,7 @@ function updateOnline() $gameStor->online_nation = join(', ', $onlineNation); } -function addAge() +function addAge(RandUtil $rng) { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -1268,6 +1268,7 @@ function addAge() foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,aux from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) { $generalID = $general['no']; $special = SpecialityHelper::pickSpecialDomestic( + $rng, $general, (Json::decode($general['aux'])['prev_types_special']) ?? [] ); @@ -1295,6 +1296,7 @@ function addAge() $updateVars['aux'] = Json::encode($generalAux); } else { $special2 = SpecialityHelper::pickSpecialWar( + $rng, $general, ($generalAux['prev_types_special2']) ?? [] ); diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php index 112783a3..0e28718a 100644 --- a/hwe/sammo/TurnExecutionHelper.php +++ b/hwe/sammo/TurnExecutionHelper.php @@ -447,7 +447,7 @@ class TurnExecutionHelper updateQuaterly(); disaster($monthlyRng); tradeRate($monthlyRng); - addAge(); + addAge($monthlyRng); // 새해 알림 $logger->pushGlobalActionLog("{$gameStor->year}년이 되었습니다."); $logger->flush(); //TODO: globalAction류는 전역에서 관리하는것이 좋을 듯. diff --git a/hwe/sammo/WarUnit.php b/hwe/sammo/WarUnit.php index 785329a0..7758b968 100644 --- a/hwe/sammo/WarUnit.php +++ b/hwe/sammo/WarUnit.php @@ -4,8 +4,6 @@ namespace sammo; class WarUnit { - public readonly RandUtil $rng; - protected $general; protected $rawNation; @@ -34,7 +32,7 @@ class WarUnit protected $logActivatedSkill = []; protected $isFinished = false; - private function __construct(RandUtil $rng, General $general) + private function __construct(public readonly RandUtil $rng, General $general) { $this->rng = $rng; $this->general = $general; diff --git a/hwe/sammo/WarUnitCity.php b/hwe/sammo/WarUnitCity.php index 994d9b4f..a53f44da 100644 --- a/hwe/sammo/WarUnitCity.php +++ b/hwe/sammo/WarUnitCity.php @@ -8,8 +8,7 @@ class WarUnitCity extends WarUnit{ protected $cityRate; - function __construct(RandUtil $rng, $raw, $rawNation, int $year, int $month, $cityRate){ - $this->rng = $rng; + function __construct(public readonly RandUtil $rng, $raw, $rawNation, int $year, int $month, $cityRate){ $general = new DummyGeneral(false); $general->setVar('city', $raw['city']); $general->setVar('nation', $raw['nation']); diff --git a/hwe/sammo/WarUnitGeneral.php b/hwe/sammo/WarUnitGeneral.php index 43824ae0..14dfd9fa 100644 --- a/hwe/sammo/WarUnitGeneral.php +++ b/hwe/sammo/WarUnitGeneral.php @@ -10,9 +10,8 @@ class WarUnitGeneral extends WarUnit protected $killedPerson = 0; protected $deadPerson = 0; - function __construct(RandUtil $rng, General $general, array $rawNation, bool $isAttacker) + function __construct(public readonly RandUtil $rng, General $general, array $rawNation, bool $isAttacker) { - $this->rng = $rng; $this->general = $general; $this->raw = $general->getRaw(); $this->rawNation = $rawNation; //read-only