국방,임관권유문을 KVStorage로 분리

This commit is contained in:
2020-05-05 19:55:59 +09:00
parent 9a6b5d8e66
commit 562c69307e
10 changed files with 75 additions and 36 deletions
+16 -3
View File
@@ -8,7 +8,8 @@ use \sammo\{
GameConst, GameUnitConst,
LastTurn,
Command,
Json
Json,
KVStorage
};
@@ -217,8 +218,18 @@ class che_임관 extends Command\GeneralCommand{
$joinedNations = $generalObj->getAuxVar('joinedNations')??[];
$nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation');
$nationList = $db->query('SELECT nation,`name`,color,scout,gennum FROM nation');
shuffle($nationList);
$nationList = Util::convertArrayToDict($nationList, 'nation');
$nationStor = KVStorage::getStorage($db, 'nation_env');
//NOTE: join 안할것임
$scoutMsgs = $nationStor->getValues(array_map(function($nationID){
return "nation_scout_msg_{$nationID}";
}, array_keys($nationList)));
foreach($scoutMsgs as $nationIDPack=>$scoutMsg){
$nationID = Util::toInt(Util::array_last(explode('_', $nationIDPack)));
$nationList[$nationID]['scoutmsg'] = $scoutMsg;
}
foreach($nationList as &$nation){
if($env['year'] < $env['startyear']+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){
@@ -234,6 +245,8 @@ class che_임관 extends Command\GeneralCommand{
if(in_array($nation['nation'], $joinedNations)){
$nation['availableJoin'] = false;
}
}
unset($nation);
ob_start();
@@ -246,7 +259,7 @@ class che_임관 extends Command\GeneralCommand{
<?php foreach($nationList as $nation): ?>
<option
value='<?=$nation['nation']?>'
style='color:<?=$nation['color']?><?=$nation['availableJoin']?'':'background-color:red;'?>'
style='<?=$nation['availableJoin']?'':'background-color:red;'?>'
>【<?=$nation['name']?> 】</option>
<?php endforeach; ?>
<input type=button id="commonSubmit" value="<?=$this->getName()?>">
+5 -2
View File
@@ -3,6 +3,7 @@ namespace sammo\Scenario;
use \sammo\DB;
use \sammo\GameConst;
use \sammo\Util;
use \sammo\KVStorage;
use function \sammo\getNationChiefLevel;
class Nation{
@@ -82,6 +83,7 @@ class Nation{
}
$db = DB::db();
$nationStor = KVStorage::getStorage($db, 'nation_env');
$otherNations = $db->queryFirstColumn('SELECT nation FROM nation');
$db->insert('nation', [
@@ -98,7 +100,6 @@ class Nation{
'war'=>0,
'strategic_cmd_limit'=>24,
'surlimit'=>72,
'scoutmsg'=>$this->infoText,
'tech'=>$this->tech,
'level'=>$this->nationLevel,
'type'=>$type,
@@ -109,7 +110,9 @@ class Nation{
'nation'=>$this->id
], 'city IN %li', $cities);
}
$scoutKey = "nation_scout_msg_{$this->id}";
$nationStor->{$scoutKey} = $this->infoText;
$diplomacy = [];