국가 성향 converter를 TriggerNationType으로 통합
This commit is contained in:
@@ -90,9 +90,9 @@ $startYear = $gameStor->getValue('startyear');
|
||||
<span class="input-group-text">국가 성향</span>
|
||||
</div>
|
||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||
<?php foreach(getNationTypeList() as $typeID): ?>
|
||||
<?php $typeRealID = '\\sammo\\TriggerNationType\\'.$typeID ?>
|
||||
<option value="<?=$typeID?>"><?=($typeRealID)::$name?> (<?=($typeRealID)::$pros?>, <?=($typeRealID)::$cons?>)</option>
|
||||
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||
<?php $nationTypeClass = getNationTypeClass($typeID) ?>
|
||||
<option value="<?=$typeID?>"><?=$nationTypeClass::$name?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="input-group-prepend">
|
||||
@@ -162,8 +162,9 @@ $startYear = $gameStor->getValue('startyear');
|
||||
<span class="input-group-text">국가 성향</span>
|
||||
</div>
|
||||
<select class="custom-select form_nation_type" style="width:25ch;">
|
||||
<?php foreach(getNationTypeList() as $typeID => [$name,$pros,$cons]): ?>
|
||||
<option value="<?=$typeID?>"><?=$name?> (<?=$pros?>, <?=$cons?>)</option>
|
||||
<?php foreach(GameConst::$availableNationType as $typeID): ?>
|
||||
<?php $nationTypeClass = getNationTypeClass($typeID) ?>
|
||||
<option value="<?=$typeID?>"><?=$nationTypeClass::$name?> (<?=$nationTypeClass::$pros?>, <?=$nationTypeClass::$cons?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="input-group-prepend">
|
||||
|
||||
+28
-25
@@ -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 "<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) {
|
||||
if($level >= 0 && $level <= 4) { $nlevel = 0; }
|
||||
$code = $nlevel * 100 + $level;
|
||||
|
||||
+4
-13
@@ -1315,19 +1315,10 @@ function command_46($turn, $command) {
|
||||
?>
|
||||
</select>
|
||||
성향 : <select name=third size=1>
|
||||
<option value=1 style=background-color:black;color:white;><?=getNationType(1)?></option>
|
||||
<option value=2 style=background-color:black;color:white;><?=getNationType(2)?></option>
|
||||
<option value=10 style=background-color:black;color:white;><?=getNationType(10)?></option>
|
||||
<option value=3 style=background-color:black;color:white;><?=getNationType(3)?></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>
|
||||
<?php foreach(GameConst::$avilableNationType as $nationTypeID): ?>
|
||||
<?php $nationClass = getNationTypeClass($nationTypeID) ?>
|
||||
<?php endforeach; ?>
|
||||
<option value='<?=$nationTypeID?>' style=background-color:black;color:white;><?=$nationClass::$name?></option>
|
||||
</select>
|
||||
<input type=submit value=건국>
|
||||
<input type=hidden name=command value=<?=$command?>>
|
||||
|
||||
@@ -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_중립';
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user