feat: scenarioEffect 추가
- 모든 General에 iAction으로 작동
This commit is contained in:
@@ -256,6 +256,41 @@ function buildItemClass(?string $type):BaseItem{
|
|||||||
return $obj;
|
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){
|
function getGeneralSpecialDomesticClass(?string $type){
|
||||||
if($type === null || $type === ''){
|
if($type === null || $type === ''){
|
||||||
$type = GameConst::$defaultSpecialDomestic;
|
$type = GameConst::$defaultSpecialDomestic;
|
||||||
|
|||||||
@@ -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 = '';
|
||||||
|
}
|
||||||
@@ -225,6 +225,9 @@ class GameConstBase
|
|||||||
public static $inheritSpecificSpecialPoint = 4000;
|
public static $inheritSpecificSpecialPoint = 4000;
|
||||||
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
|
public static $inheritResetAttrPointBase = [1000, 1000, 2000, 3000];//필요하면 늘려서 쓰기
|
||||||
|
|
||||||
|
/** @var ?string */
|
||||||
|
public static $scenarioEffectName = null;
|
||||||
|
|
||||||
public static $allItems = [
|
public static $allItems = [
|
||||||
'horse' => [
|
'horse' => [
|
||||||
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
|
'che_명마_01_노기' => 0, 'che_명마_02_조랑' => 0, 'che_명마_03_노새' => 0,
|
||||||
|
|||||||
+9
-14
@@ -42,6 +42,9 @@ class General extends GeneralBase implements iAction
|
|||||||
protected $itemObjs = [];
|
protected $itemObjs = [];
|
||||||
/** @var ?iAction */
|
/** @var ?iAction */
|
||||||
protected $inheritBuffObj = null;
|
protected $inheritBuffObj = null;
|
||||||
|
/** @var ?iAction */
|
||||||
|
protected $scenarioEffect = null;
|
||||||
|
|
||||||
/** @var ?GameUnitDetail */
|
/** @var ?GameUnitDetail */
|
||||||
protected $crewType = null;
|
protected $crewType = null;
|
||||||
|
|
||||||
@@ -108,6 +111,10 @@ class General extends GeneralBase implements iAction
|
|||||||
if ($rawInheritBuff !== null) {
|
if ($rawInheritBuff !== null) {
|
||||||
$this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff);
|
$this->inheritBuffObj = new TriggerInheritBuff($rawInheritBuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GameConst::$scenarioEffectName){
|
||||||
|
$this->scenarioEffect = buildScenarioEffectClass(GameConst::$scenarioEffectName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setItem(string $itemKey = 'item', ?string $itemCode)
|
function setItem(string $itemKey = 'item', ?string $itemCode)
|
||||||
@@ -351,20 +358,7 @@ class General extends GeneralBase implements iAction
|
|||||||
$statValue = Util::clamp($statValue, 0, GameConst::$maxLevel);
|
$statValue = Util::clamp($statValue, 0, GameConst::$maxLevel);
|
||||||
|
|
||||||
if ($withIActionObj) {
|
if ($withIActionObj) {
|
||||||
foreach ([
|
foreach ($this->getActionList() as $actionObj) {
|
||||||
$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) {
|
|
||||||
if ($actionObj !== null) {
|
if ($actionObj !== null) {
|
||||||
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
$statValue = $actionObj->onCalcStat($this, $statName, $statValue);
|
||||||
}
|
}
|
||||||
@@ -774,6 +768,7 @@ class General extends GeneralBase implements iAction
|
|||||||
$this->personalityObj,
|
$this->personalityObj,
|
||||||
$this->crewType,
|
$this->crewType,
|
||||||
$this->inheritBuffObj,
|
$this->inheritBuffObj,
|
||||||
|
$this->scenarioEffect
|
||||||
], $this->itemObjs);
|
], $this->itemObjs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,6 +508,13 @@ class Scenario{
|
|||||||
throw new \RuntimeException('유닛 파일이 올바르게 지정되지 않음! : '.$unitSet);
|
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');
|
Util::generatePHPClassFile($path.'/GameConst.php', $this->gameConf, 'GameConstBase', 'sammo');
|
||||||
|
|
||||||
copy("$mapPath/$mapName.php", $path.'/CityConst.php');
|
copy("$mapPath/$mapName.php", $path.'/CityConst.php');
|
||||||
|
|||||||
Reference in New Issue
Block a user