diff --git a/hwe/b_dipcenter.php b/hwe/b_dipcenter.php
index 4f885ee9..d0a8507d 100644
--- a/hwe/b_dipcenter.php
+++ b/hwe/b_dipcenter.php
@@ -43,7 +43,7 @@ if ($me['officer_level'] >= 5) {
$read = "readonly";
}
-$nationStor->cacheValues(['notice', 'scout_msg']);
+$nationStor->cacheValues(['notice', 'scout_msg', 'available_war_setting_cnt']);
?>
@@ -251,8 +251,8 @@ if ($budgetricediff > 0) {
|
diff --git a/hwe/c_dipcenter.php b/hwe/c_dipcenter.php
index 192f2424..41fa6f56 100644
--- a/hwe/c_dipcenter.php
+++ b/hwe/c_dipcenter.php
@@ -1,4 +1,5 @@
queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty
//내가 수뇌부이어야함
$permission = checkSecretPermission($me);
-if($permission < 0){
+if ($permission < 0) {
header('location:b_myBossInfo.php', true, 303);
exit();
-}
-else if ($me['officer_level'] < 5 && $permission != 4) {
+} else if ($me['officer_level'] < 5 && $permission != 4) {
header('location:b_myBossInfo.php', true, 303);
exit();
}
@@ -34,44 +34,52 @@ else if ($me['officer_level'] < 5 && $permission != 4) {
$nationID = $me['nation'];
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
-if($btn == "국가방침 수정") {
+if ($btn == "국가방침 수정") {
$msg = mb_substr($msg, 0, 16384);
//$msg = StringUtil::
$nationStor->notice = WebUtil::htmlPurify($msg);
-} elseif($btn == "임관 권유문 수정") {
+} elseif ($btn == "임관 권유문 수정") {
$scoutmsg = mb_substr($scoutmsg, 0, 1000);
$nationStor->scout_msg = WebUtil::htmlPurify($scoutmsg);
-} elseif($btn == "세율") {
+} elseif ($btn == "세율") {
$rate = Util::valueFit($rate, 5, 30);
$db->update('nation', [
- 'rate'=>$rate,
+ 'rate' => $rate,
], 'nation=%i', $nationID);
-} elseif($btn == "지급률") {
+} elseif ($btn == "지급률") {
$bill = Util::valueFit($bill, 20, 200);
$db->update('nation', [
- 'bill'=>$bill
- ], 'nation=%i',$nationID);
-} elseif($btn == "기밀권한") {
+ 'bill' => $bill
+ ], 'nation=%i', $nationID);
+} elseif ($btn == "기밀권한") {
$secretlimit = Util::valueFit($secretlimit, 1, 99);
$db->update('nation', [
- 'secretlimit'=>$secretlimit
- ], 'nation=%i',$nationID);
-} elseif($btn == "임관 금지") {
+ 'secretlimit' => $secretlimit
+ ], 'nation=%i', $nationID);
+} elseif ($btn == "임관 금지") {
$db->update('nation', [
- 'scout'=>1
- ], 'nation=%i',$nationID);
-} elseif($btn == "임관 허가") {
+ 'scout' => 1
+ ], 'nation=%i', $nationID);
+} elseif ($btn == "임관 허가") {
$db->update('nation', [
- 'scout'=>0
- ], 'nation=%i',$nationID);
-} elseif($btn == "전쟁 금지") {
- $db->update('nation', [
- 'war'=>1
- ], 'nation=%i',$nationID);
-} elseif($btn == "전쟁 허가") {
- $db->update('nation', [
- 'war'=>0
- ], 'nation=%i',$nationID);
+ 'scout' => 0
+ ], 'nation=%i', $nationID);
+} elseif ($btn == "전쟁 금지") {
+ $avilableCnt = $nationStor->getValue('available_war_setting_cnt') ?? 0;
+ if ($avilableCnt > 0) {
+ $db->update('nation', [
+ 'war' => 1
+ ], 'nation=%i', $nationID);
+ $nationStor->setValue('available_war_setting_cnt', $avilableCnt - 1);
+ }
+} elseif ($btn == "전쟁 허가") {
+ $avilableCnt = $nationStor->getValue('available_war_setting_cnt') ?? 0;
+ if ($avilableCnt > 0) {
+ $db->update('nation', [
+ 'war' => 0
+ ], 'nation=%i', $nationID);
+ $nationStor->setValue('available_war_setting_cnt', $avilableCnt - 1);
+ }
}
header('location:b_dipcenter.php');
diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php
index 7f3b8df5..7525a778 100644
--- a/hwe/func_gamerule.php
+++ b/hwe/func_gamerule.php
@@ -481,6 +481,21 @@ function postUpdateMonthly()
'term' => 6,
], 'state = 1 AND term = 0');
+ $availableWarSettingCnt = KVStorage::getValuesFromInterNamespace($db, 'nation_env', 'available_war_setting_cnt');
+ foreach ($nations as $nation) {
+ $nationID = $nation['nation'];
+ if(!key_exists($nationID, $availableWarSettingCnt)){
+ $availableWarSettingCnt[$nationID] = 0;
+ }
+ }
+ foreach($availableWarSettingCnt as $nationID=>$cnt){
+ if($cnt >= GameConst::$maxAvailableWarSettingCnt){
+ continue;
+ }
+ $cnt = Util::valueFit($cnt + GameConst::$incAvailableWarSettingCnt, 0, GameConst::$maxAvailableWarSettingCnt);
+ (KVStorage::getStorage($db, $nationID, 'nation_env'))->setValue('available_war_setting_cnt', $cnt);
+ }
+
//초반이후 방랑군 자동 해체
if ($admin['year'] >= $admin['startyear'] + 2) {
checkWander();
diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php
index 25833b38..719d174c 100644
--- a/hwe/sammo/GameConstBase.php
+++ b/hwe/sammo/GameConstBase.php
@@ -202,6 +202,9 @@ class GameConstBase
[20, 4]
];
+ public static $maxAvailableWarSettingCnt = 10;
+ public static $incAvailableWarSettingCnt = 2;
+
public static $inheritBornSpecialPoint = 6000;
public static $inheritBornTurntimePoint = 3000;
public static $inheritBornCityPoint = 1000;
diff --git a/src/sammo/KVStorage.php b/src/sammo/KVStorage.php
index 80cdd20b..b6db4eff 100644
--- a/src/sammo/KVStorage.php
+++ b/src/sammo/KVStorage.php
@@ -42,7 +42,7 @@ class KVStorage{
public function __get($key) {
return $this->getValue($key);
}
-
+
public function __set($key, $value) {
$this->setValue($key, $value);
}
@@ -93,13 +93,13 @@ class KVStorage{
return $this;
}
$keys = array_map('mb_strtolower', $keys);
-
+
foreach($keys as $key){
if(key_exists($key, $this->cacheData)){
unset($this->cacheData[$key]);
}
}
-
+
return $this;
}
@@ -141,7 +141,7 @@ class KVStorage{
$this->cacheData[$key] = null;
}
}
-
+
return $this;
}
@@ -180,7 +180,7 @@ class KVStorage{
$result = [];
$notExists = [];
-
+
//TODO: DB Select에서 as를 쓸 수 있으면 좋을 듯.
foreach($keys as $key){
if(!key_exists($key, $this->cacheData)){
@@ -208,9 +208,9 @@ class KVStorage{
}
/**
- * @param string|int $key
- * @param bool $onlyCache
- * @return mixed|null
+ * @param string|int $key
+ * @param bool $onlyCache
+ * @return mixed|null
*/
public function getValue($key, bool $onlyCache=false){
if(is_string($key)){
@@ -228,11 +228,11 @@ class KVStorage{
}
/**
- *
- * @param string|int $key
- * @param mixed $value
- * @return KVStorage
- * @throws MeekroDBException
+ *
+ * @param string|int $key
+ * @param mixed $value
+ * @return KVStorage
+ * @throws MeekroDBException
*/
public function setValue($key, $value):self{
if(is_string($key)){
@@ -249,11 +249,11 @@ class KVStorage{
}
/**
- *
- * @param string|int $key
- * @param mixed $value
- * @return KVStorage
- * @throws MeekroDBException
+ *
+ * @param string|int $key
+ * @param mixed $value
+ * @return KVStorage
+ * @throws MeekroDBException
*/
public function deleteValue($key):self{
if(is_string($key)){
@@ -284,9 +284,9 @@ class KVStorage{
}
$result = [];
foreach($this->db->queryAllLists(
- 'SELECT `key`, `value` FROM %b WHERE `namespace`=%s AND `key` IN %ls',
+ 'SELECT `key`, `value` FROM %b WHERE `namespace`=%s AND `key` IN %ls',
$this->tableName,
- $this->storNamespace,
+ $this->storNamespace,
$keys
) as list($key, $value))
{
|