From 476de90ca704d05a106a879b60dac2d15cd45e61 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 2 Sep 2018 21:37:23 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B5=AD=EA=B0=80=20=EC=84=B1=ED=96=A5=20conve?= =?UTF-8?q?rter=EB=A5=BC=20TriggerNationType=EC=9C=BC=EB=A1=9C=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/battle_simulator.php | 11 ++++---- hwe/func_converter.php | 53 ++++++++++++++++++----------------- hwe/processing.php | 17 +++-------- hwe/sammo/GameConstBase.php | 4 ++- hwe/sammo/Scenario/Nation.php | 8 ++++-- 5 files changed, 47 insertions(+), 46 deletions(-) diff --git a/hwe/battle_simulator.php b/hwe/battle_simulator.php index 4b4f130a..4b4ffc8b 100644 --- a/hwe/battle_simulator.php +++ b/hwe/battle_simulator.php @@ -90,9 +90,9 @@ $startYear = $gameStor->getValue('startyear'); 국가 성향
@@ -162,8 +162,9 @@ $startYear = $gameStor->getValue('startyear'); 국가 성향
diff --git a/hwe/func_converter.php b/hwe/func_converter.php index 80696065..06ebdc27 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -6,18 +6,9 @@ namespace sammo; * Value Converter * * Side effect 없이 값의 변환만을 수행하는 함수들의 모음. + * (단, autoload, 정적 변수 초기화는 허용) */ -function NationCharCall($call) { - static $invTable = []; - if(!$invTable){ - foreach(getNationTypeList() as $typeID => [$name, $pros, $cons]){ - $invTable[$name] = $typeID; - } - } - return $invTable[$call]??0; -} - function getCharacterList(){ $infoText = [ 9=>['안전', '사기 -5, 징·모병 비용 -20%'], @@ -223,16 +214,9 @@ function getSpecialInfo(?int $type):?string{ return $infoText[$type][1]??null; } -function getNationType(?int $type) { - if($type === null){ - return '-'; - } - static $cache = []; - if(\key_exists($type, $cache)){ - return $cache[$type]; - } - - $text = getNationTypeList()[$type][0]??'-'; +function getNationType(?string $type) { + $nationClass = getNationTypeClass($type); + $text = $nationClass::$name; $text = join(' ', StringUtil::splitString($text)); $cache[$type] = $text; @@ -255,14 +239,33 @@ function getConnect($con) { return $conname; } -function getNationType2(?int $type) { - if($type === null){ - return '-'; - } - [$name, $pros, $cons] = getNationTypeList()[$type]??['-', '', '']; +function getNationType2(?string $type) { + $nationClass = getNationTypeClass($type); + + [$name, $pros, $cons] = [$nationClass::$name, $nationClass::$pros, $nationClass::$cons]; return "{$pros} {$cons}"; } +function getNationTypeClass(?string $type){ + if($type === null){ + $type = GameConst::$neutralNationType; + } + + static $path = __NAMESPACE__.'\\TriggerNationType\\'; + $nationClass = ($path.$type); + + if(class_exists($nationClass)){ + return $nationClass; + } + + $nationClass = ($path.'che_'.$type); + if(class_exists($nationClass)){ + return $nationClass; + } + + new \InvalidArgumentException("{$type}은 올바른 국가 타입 클래스가 아님"); +} + function getLevel($level, $nlevel=8) { if($level >= 0 && $level <= 4) { $nlevel = 0; } $code = $nlevel * 100 + $level; diff --git a/hwe/processing.php b/hwe/processing.php index 3deddf26..a2ecfa2f 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -1315,19 +1315,10 @@ function command_46($turn, $command) { ?> 성향 : > diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 270cbe46..87a343c5 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -96,7 +96,9 @@ class GameConstBase /** @var array 선택 가능한 국가 성향 */ public static $availableNationType = [ - 'che_명가', 'che_음양가', 'che_종횡가', 'che_불가', 'che_도적', 'che_오두미도', 'che_태평도', 'che_도가', + 'che_도적', 'che_명가', 'che_음양가', 'che_종횡가', 'che_불가', 'che_오두미도', 'che_태평도', 'che_도가', 'che_묵가', 'che_덕가', 'che_병가', 'che_유가', 'che_법가' ]; + + public static $neutralNationType = 'che_중립'; } diff --git a/hwe/sammo/Scenario/Nation.php b/hwe/sammo/Scenario/Nation.php index cbcc0f5a..6b683e60 100644 --- a/hwe/sammo/Scenario/Nation.php +++ b/hwe/sammo/Scenario/Nation.php @@ -71,8 +71,12 @@ class Nation{ $capital = 0; } - - $type = \sammo\NationCharCall($this->type); + if(strpos($this->type, '_') === FALSE){ + $type = 'che_'.$this->type; + } + else{ + $type = $this->type; + } $db = DB::db(); $otherNations = $db->queryFirstColumn('SELECT nation FROM nation');