From 16cfa468641ac0297f48613ab3996472a320d557 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 5 Aug 2023 06:53:19 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20scenarioEffect=20=EC=B6=94=EA=B0=80=20-?= =?UTF-8?q?=20=EB=AA=A8=EB=93=A0=20General=EC=97=90=20iAction=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9E=91=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_converter.php | 35 +++++++++++++++++++++++++ hwe/sammo/ActionScenarioEffect/None.php | 12 +++++++++ hwe/sammo/GameConstBase.php | 3 +++ hwe/sammo/General.php | 23 +++++++--------- hwe/sammo/Scenario.php | 7 +++++ 5 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 hwe/sammo/ActionScenarioEffect/None.php diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 97d60796..23f74823 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -256,6 +256,41 @@ function buildItemClass(?string $type):BaseItem{ return $obj; } +function getScenarioEffectClass(?string $type){ + if($type === null || $type === ''){ + $type = 'None'; + } + + static $basePath = __NAMESPACE__.'\\ActionScenarioEffect\\'; + $classPath = ($basePath.$type); + + if(class_exists($classPath)){ + return $classPath; + } + + $classPath = ($basePath.'che_'.$type); + if(class_exists($classPath)){ + return $classPath; + } + + throw new \InvalidArgumentException("{$type}은 시나리오 효과 클래스가 아님"); +} + +function buildScenarioEffectClass(?string $type):iAction{ + static $cache = []; + if($type === null){ + $type = 'None'; + } + if(key_exists($type, $cache)){ + return $cache[$type]; + } + $class = getScenarioEffectClass($type); + + $obj = new $class(); + $cache[$type]= $obj; + return $obj; +} + function getGeneralSpecialDomesticClass(?string $type){ if($type === null || $type === ''){ $type = GameConst::$defaultSpecialDomestic; diff --git a/hwe/sammo/ActionScenarioEffect/None.php b/hwe/sammo/ActionScenarioEffect/None.php new file mode 100644 index 00000000..20dc5980 --- /dev/null +++ b/hwe/sammo/ActionScenarioEffect/None.php @@ -0,0 +1,12 @@ + [ 'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0, diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 0cf70ebb..8f8b90bf 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -42,6 +42,9 @@ class General extends GeneralBase implements iAction protected $itemObjs = []; /** @var ?iAction */ protected $inheritBuffObj = null; + /** @var ?iAction */ + protected $scenarioEffect = null; + /** @var ?GameUnitDetail */ protected $crewType = null; @@ -108,6 +111,10 @@ class General extends GeneralBase implements iAction if ($rawInheritBuff !== null) { $this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff); } + + if(GameConst::$scenarioEffectName){ + $this->scenarioEffect = buildScenarioEffectClass(GameConst::$scenarioEffectName); + } } function setItem(string $itemKey = 'item', ?string $itemCode) @@ -351,20 +358,7 @@ class General extends GeneralBase implements iAction $statValue = Util::clamp($statValue, 0, GameConst::$maxLevel); if ($withIActionObj) { - foreach ([ - $this->nationType, - $this->officerLevelObj, - $this->specialDomesticObj, - $this->specialWarObj, - $this->personalityObj, - $this->inheritBuffObj, - ] as $actionObj) { - if ($actionObj !== null) { - $statValue = $actionObj->onCalcStat($this, $statName, $statValue); - } - } - - foreach ($this->itemObjs as $actionObj) { + foreach ($this->getActionList() as $actionObj) { if ($actionObj !== null) { $statValue = $actionObj->onCalcStat($this, $statName, $statValue); } @@ -774,6 +768,7 @@ class General extends GeneralBase implements iAction $this->personalityObj, $this->crewType, $this->inheritBuffObj, + $this->scenarioEffect ], $this->itemObjs); } diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index 364e3ee2..d2bc9ddb 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -508,6 +508,13 @@ class Scenario{ throw new \RuntimeException('유닛 파일이 올바르게 지정되지 않음! : '.$unitSet); } + if(key_exists('scenarioEffect', $this->gameConf)){ + $className = getScenarioEffectClass($this->gameConf['scenarioEffect']); + if($className === 'None'){ + $this->gameConf['scenarioEffect'] = null; + } + } + Util::generatePHPClassFile($path.'/GameConst.php', $this->gameConf, 'GameConstBase', 'sammo'); copy("$mapPath/$mapName.php", $path.'/CityConst.php');