forked from devsam/core
국방,임관권유문을 KVStorage로 분리
This commit is contained in:
+1
-1
@@ -86,7 +86,7 @@ $sel2[$type2] = "selected";
|
||||
<select name=nation size=1 style=color:white;background-color:black>";
|
||||
<option value=0>재야</option>";
|
||||
<?php
|
||||
$query = "select nation,name,color,scout,scoutmsg,gennum from nation order by power";
|
||||
$query = "select nation,name,color,scout,gennum from nation order by power";
|
||||
$result = MYDB_query($query, $connect) or Error("aaa_processing.php " . MYDB_error($connect), "");
|
||||
$count = MYDB_num_rows($result);
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
|
||||
+8
-4
@@ -9,14 +9,14 @@ $userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
|
||||
increaseRefresh("내무부", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no, nation, officer_level, con, turntime, belong, permission, penalty FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$nationID = $me['nation'];
|
||||
$nation = $db->queryFirstRow('SELECT nation,level,name,color,type,gold,rice,bill,rate,scout,war,secretlimit,msg,scoutmsg,capital FROM nation WHERE nation = %i', $nationID);
|
||||
$nation = $db->queryFirstRow('SELECT nation,level,name,color,type,gold,rice,bill,rate,scout,war,secretlimit,capital FROM nation WHERE nation = %i', $nationID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
@@ -42,6 +42,10 @@ if ($me['officer_level'] >= 5) {
|
||||
$read = "readonly";
|
||||
}
|
||||
|
||||
$noticeKey = "nation_notice_{$nationID}";
|
||||
$scoutKey = "nation_scout_msg_{$nationID}";
|
||||
$nationStor->cacheValues([$noticeKey, $scoutKey]);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -52,8 +56,8 @@ if ($me['officer_level'] >= 5) {
|
||||
<title><?=UniqueConst::$serverName?>: 내무부</title>
|
||||
<script>
|
||||
var editable = <?=(($me['officer_level']>=5||$permission==4)?'true':'false')?>;
|
||||
var nationMsg = <?=Json::encode($nation['msg']??'')?>;
|
||||
var scoutmsg = <?=Json::encode($nation['scoutmsg']??'')?>;
|
||||
var nationMsg = <?=Json::encode($nationStor->{$noticeKey}??'')?>;
|
||||
var scoutmsg = <?=Json::encode($nationStor->{$scoutKey}??'')?>;
|
||||
</script>
|
||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||
|
||||
+14
-13
@@ -31,48 +31,49 @@ else if ($me['officer_level'] < 5 && $permission != 4) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
$nationID = $me['nation'];
|
||||
$noticeKey = "nation_notice_{$nationID}";
|
||||
$scoutKey = "nation_scout_msg_{$nationID}";
|
||||
|
||||
if($btn == "국가방침 수정") {
|
||||
$msg = mb_substr($msg, 0, 16384);
|
||||
//$msg = StringUtil::
|
||||
$db->update('nation', [
|
||||
'msg'=>WebUtil::htmlPurify($msg)
|
||||
], 'nation=%i',$me['nation']);
|
||||
$nationStor->{$noticeKey} = WebUtil::htmlPurify($msg);
|
||||
} elseif($btn == "임관 권유문 수정") {
|
||||
$scoutmsg = mb_substr($scoutmsg, 0, 1000);
|
||||
$db->update('nation', [
|
||||
'scoutmsg'=>WebUtil::htmlPurify($scoutmsg)
|
||||
], 'nation=%i',$me['nation']);
|
||||
$nationStor->{$scoutKey} = WebUtil::htmlPurify($scoutmsg);
|
||||
} elseif($btn == "세율") {
|
||||
$rate = Util::valueFit($rate, 5, 30);
|
||||
$db->update('nation', [
|
||||
'rate'=>$rate,
|
||||
], 'nation=%i', $me['nation']);
|
||||
], 'nation=%i', $nationID);
|
||||
} elseif($btn == "지급률") {
|
||||
$bill = Util::valueFit($bill, 20, 200);
|
||||
$db->update('nation', [
|
||||
'bill'=>$bill
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
} elseif($btn == "기밀권한") {
|
||||
$secretlimit = Util::valueFit($secretlimit, 1, 99);
|
||||
$db->update('nation', [
|
||||
'secretlimit'=>$secretlimit
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
} elseif($btn == "임관 금지") {
|
||||
$db->update('nation', [
|
||||
'scout'=>1
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
} elseif($btn == "임관 허가") {
|
||||
$db->update('nation', [
|
||||
'scout'=>0
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
} elseif($btn == "전쟁 금지") {
|
||||
$db->update('nation', [
|
||||
'war'=>1
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
} elseif($btn == "전쟁 허가") {
|
||||
$db->update('nation', [
|
||||
'war'=>0
|
||||
], 'nation=%i',$me['nation']);
|
||||
], 'nation=%i',$nationID);
|
||||
}
|
||||
|
||||
header('location:b_dipcenter.php');
|
||||
|
||||
+6
-7
@@ -193,7 +193,7 @@ function myNationInfo()
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,color,power,msg,gold,rice,bill,rate,scout,war,strategic_cmd_limit,surlimit,tech,level,type from nation where nation='{$me['nation']}'";
|
||||
$query = "select nation,name,color,power,gold,rice,bill,rate,scout,war,strategic_cmd_limit,surlimit,tech,level,type from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
@@ -898,12 +898,11 @@ function onlinegen()
|
||||
function nationMsg(General $general)
|
||||
{
|
||||
$db = DB::db();
|
||||
$msg = $db->queryFirstField(
|
||||
'SELECT msg FROM nation WHERE nation = %i',
|
||||
$general->getNationID()
|
||||
);
|
||||
|
||||
return $msg ?: '';
|
||||
$nationStor = KVStorage::getStorage($db, 'nation_env');
|
||||
$nationID = $general->getNationID();
|
||||
$noticeKey = "nation_notice_{$nationID}";
|
||||
|
||||
return $nationStor->{$noticeKey}??'';
|
||||
}
|
||||
|
||||
function banner()
|
||||
|
||||
+12
-1
@@ -76,7 +76,18 @@ if ($gencount >= $admin['maxgeneral']) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg FROM nation ORDER BY rand()');
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout 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;
|
||||
}
|
||||
|
||||
echo getInvitationList($nationList);
|
||||
?>
|
||||
|
||||
@@ -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()?>">
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
+12
-1
@@ -18,7 +18,18 @@ if(!$npcmode) {
|
||||
|
||||
$gencount = $db->queryFirstField('SELECT count(`no`) FROM general WHERE npc<2');
|
||||
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg FROM nation ORDER BY rand()');
|
||||
$nationList = $db->query('SELECT nation,`name`,color,scout 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;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
@@ -117,7 +117,6 @@ CREATE TABLE `nation` (
|
||||
`name` VARCHAR(64) NOT NULL COLLATE 'utf8mb4_bin',
|
||||
`color` CHAR(10) NOT NULL,
|
||||
`onlinegen` TEXT NULL DEFAULT '',
|
||||
`msg` TEXT NULL DEFAULT '',
|
||||
`capital` INT(1) NULL DEFAULT '0',
|
||||
`capset` INT(6) NULL DEFAULT '0',
|
||||
`gennum` INT(3) NULL DEFAULT '1',
|
||||
@@ -132,13 +131,11 @@ CREATE TABLE `nation` (
|
||||
`war` INT(1) NULL DEFAULT '0',
|
||||
`strategic_cmd_limit` INT(4) NULL DEFAULT '36',
|
||||
`surlimit` INT(4) NULL DEFAULT '72',
|
||||
`scoutmsg` TEXT NULL DEFAULT '',
|
||||
`tech` float NULL DEFAULT '0',
|
||||
`power` INT(8) NULL DEFAULT '0',
|
||||
`spy` TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(`spy`)),
|
||||
`level` INT(1) NULL DEFAULT '0',
|
||||
`type` VARCHAR(20) NOT NULL DEFAULT 'che_중립',
|
||||
`rule` TEXT NULL DEFAULT '',
|
||||
`aux` LONGTEXT NOT NULL DEFAULT '{}' CHECK (json_valid(`aux`)),
|
||||
PRIMARY KEY (`nation`)
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<td style="width:130px;text-align:center;"
|
||||
><?=$nation['name']?></td>
|
||||
<td><div style="width:870px;max-width:870px;max-height:200px;overflow:hidden;"
|
||||
><?=$nation['scoutmsg']?:'-'?></div></td>
|
||||
><?=$nation['scoutmsg']??'-'?></div></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user