feat: scenarioEffect 추가

- 모든 General에 iAction으로 작동
This commit is contained in:
2023-08-05 06:53:19 +00:00
parent e54a0a6668
commit 16cfa46864
5 changed files with 66 additions and 14 deletions
+35
View File
@@ -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;
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace sammo\ActionScenarioEffect;
use \sammo\iAction;
use \sammo\General;
class None implements iAction{
use \sammo\DefaultAction;
protected $id = -1;
protected $name = '-';
protected $info = '';
}
+3
View File
@@ -225,6 +225,9 @@ class GameConstBase
public static $inheritSpecificSpecialPoint = 4000;
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
/** @var ?string */
public static $scenarioEffectName = null;
public static $allItems = [
'horse' => [
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
+9 -14
View File
@@ -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);
}
+7
View File
@@ -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');