국가 성향 converter를 TriggerNationType으로 통합
This commit is contained in:
@@ -90,9 +90,9 @@ $startYear = $gameStor->getValue('startyear');
|
|||||||
<span class="input-group-text">국가 성향</span>
|
<span class="input-group-text">국가 성향</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||||
<?php foreach(getNationTypeList() as $typeID): ?>
|
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||||
<?php $typeRealID = '\\sammo\\TriggerNationType\\'.$typeID ?>
|
<?php $nationTypeClass = getNationTypeClass($typeID) ?>
|
||||||
<option value="<?=$typeID?>"><?=($typeRealID)::$name?> (<?=($typeRealID)::$pros?>, <?=($typeRealID)::$cons?>)</option>
|
<option value="<?=$typeID?>"><?=$nationTypeClass::$name?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
@@ -162,8 +162,9 @@ $startYear = $gameStor->getValue('startyear');
|
|||||||
<span class="input-group-text">국가 성향</span>
|
<span class="input-group-text">국가 성향</span>
|
||||||
</div>
|
</div>
|
||||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||||
<?php foreach(getNationTypeList() as $typeID => [$name,$pros,$cons]): ?>
|
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||||
<option value="<?=$typeID?>"><?=$name?> (<?=$pros?>, <?=$cons?>)</option>
|
<?php $nationTypeClass = getNationTypeClass($typeID) ?>
|
||||||
|
<option value="<?=$typeID?>"><?=$nationTypeClass::$name?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
|
|||||||
+28
-25
@@ -6,18 +6,9 @@ namespace sammo;
|
|||||||
* Value Converter
|
* Value Converter
|
||||||
*
|
*
|
||||||
* Side effect 없이 값의 변환만을 수행하는 함수들의 모음.
|
* 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(){
|
function getCharacterList(){
|
||||||
$infoText = [
|
$infoText = [
|
||||||
9=>['안전', '사기 -5, 징·모병 비용 -20%'],
|
9=>['안전', '사기 -5, 징·모병 비용 -20%'],
|
||||||
@@ -223,16 +214,9 @@ function getSpecialInfo(?int $type):?string{
|
|||||||
return $infoText[$type][1]??null;
|
return $infoText[$type][1]??null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNationType(?int $type) {
|
function getNationType(?string $type) {
|
||||||
if($type === null){
|
$nationClass = getNationTypeClass($type);
|
||||||
return '-';
|
$text = $nationClass::$name;
|
||||||
}
|
|
||||||
static $cache = [];
|
|
||||||
if(\key_exists($type, $cache)){
|
|
||||||
return $cache[$type];
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = getNationTypeList()[$type][0]??'-';
|
|
||||||
$text = join(' ', StringUtil::splitString($text));
|
$text = join(' ', StringUtil::splitString($text));
|
||||||
$cache[$type] = $text;
|
$cache[$type] = $text;
|
||||||
|
|
||||||
@@ -255,14 +239,33 @@ function getConnect($con) {
|
|||||||
return $conname;
|
return $conname;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNationType2(?int $type) {
|
function getNationType2(?string $type) {
|
||||||
if($type === null){
|
$nationClass = getNationTypeClass($type);
|
||||||
return '-';
|
|
||||||
}
|
[$name, $pros, $cons] = [$nationClass::$name, $nationClass::$pros, $nationClass::$cons];
|
||||||
[$name, $pros, $cons] = getNationTypeList()[$type]??['-', '', ''];
|
|
||||||
return "<font color=cyan>{$pros}</font> <font color=magenta>{$cons}</font>";
|
return "<font color=cyan>{$pros}</font> <font color=magenta>{$cons}</font>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function getLevel($level, $nlevel=8) {
|
||||||
if($level >= 0 && $level <= 4) { $nlevel = 0; }
|
if($level >= 0 && $level <= 4) { $nlevel = 0; }
|
||||||
$code = $nlevel * 100 + $level;
|
$code = $nlevel * 100 + $level;
|
||||||
|
|||||||
+4
-13
@@ -1315,19 +1315,10 @@ function command_46($turn, $command) {
|
|||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
성향 : <select name=third size=1>
|
성향 : <select name=third size=1>
|
||||||
<option value=1 style=background-color:black;color:white;><?=getNationType(1)?></option>
|
<?php foreach(GameConst::$avilableNationType as $nationTypeID): ?>
|
||||||
<option value=2 style=background-color:black;color:white;><?=getNationType(2)?></option>
|
<?php $nationClass = getNationTypeClass($nationTypeID) ?>
|
||||||
<option value=10 style=background-color:black;color:white;><?=getNationType(10)?></option>
|
<?php endforeach; ?>
|
||||||
<option value=3 style=background-color:black;color:white;><?=getNationType(3)?></option>
|
<option value='<?=$nationTypeID?>' style=background-color:black;color:white;><?=$nationClass::$name?></option>
|
||||||
<option value=4 style=background-color:black;color:white;><?=getNationType(4)?></option>
|
|
||||||
<option value=5 style=background-color:black;color:white;><?=getNationType(5)?></option>
|
|
||||||
<option value=6 style=background-color:black;color:white;><?=getNationType(6)?></option>
|
|
||||||
<option value=7 style=background-color:black;color:white;><?=getNationType(7)?></option>
|
|
||||||
<option value=8 style=background-color:black;color:white;><?=getNationType(8)?></option>
|
|
||||||
<option selected value=9 style=background-color:black;color:white;><?=getNationType(9)?></option>
|
|
||||||
<option value=11 style=background-color:black;color:white;><?=getNationType(11)?></option>
|
|
||||||
<option value=12 style=background-color:black;color:white;><?=getNationType(12)?></option>
|
|
||||||
<option value=13 style=background-color:black;color:white;><?=getNationType(13)?></option>
|
|
||||||
</select>
|
</select>
|
||||||
<input type=submit value=건국>
|
<input type=submit value=건국>
|
||||||
<input type=hidden name=command value=<?=$command?>>
|
<input type=hidden name=command value=<?=$command?>>
|
||||||
|
|||||||
@@ -96,7 +96,9 @@ class GameConstBase
|
|||||||
|
|
||||||
/** @var array 선택 가능한 국가 성향 */
|
/** @var array 선택 가능한 국가 성향 */
|
||||||
public static $availableNationType = [
|
public static $availableNationType = [
|
||||||
'che_명가', 'che_음양가', 'che_종횡가', 'che_불가', 'che_도적', '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_중립';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,12 @@ class Nation{
|
|||||||
$capital = 0;
|
$capital = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strpos($this->type, '_') === FALSE){
|
||||||
$type = \sammo\NationCharCall($this->type);
|
$type = 'che_'.$this->type;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$type = $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$otherNations = $db->queryFirstColumn('SELECT nation FROM nation');
|
$otherNations = $db->queryFirstColumn('SELECT nation FROM nation');
|
||||||
|
|||||||
Reference in New Issue
Block a user