feat: 내무부 변경
This commit is contained in:
@@ -64,7 +64,6 @@ return [
|
||||
'hwe/b_tournament.php',
|
||||
'hwe/b_troop.php',
|
||||
'hwe/c_auction.php',
|
||||
'hwe/c_dipcenter.php',
|
||||
'hwe/c_tournament.php',
|
||||
'hwe/c_vote.php',
|
||||
'hwe/func_auction.php',
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_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,capital FROM nation WHERE nation = %i', $nationID);
|
||||
|
||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
printLimitMsg($me['turntime']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission < 0) {
|
||||
echo '국가에 소속되어있지 않습니다.';
|
||||
die();
|
||||
} else if ($permission < 1) {
|
||||
echo "권한이 부족합니다. 수뇌부가 아니거나 사관년도가 부족합니다.";
|
||||
die();
|
||||
}
|
||||
|
||||
if ($me['officer_level'] >= 5) {
|
||||
$btn = "submit";
|
||||
$read = "";
|
||||
} else {
|
||||
$btn = "hidden";
|
||||
$read = "readonly";
|
||||
}
|
||||
|
||||
$nationStor->cacheValues(['notice', 'scout_msg', 'available_war_setting_cnt']);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<title><?= UniqueConst::$serverName ?>: 내무부</title>
|
||||
<?= WebUtil::printStaticValues([
|
||||
'editable' => ($me['officer_level'] >= 5 || $permission == 4),
|
||||
'nationMsg' => $nationStor->notice ?? '',
|
||||
'scoutMsg' => $nationStor->scout_msg ?? '',
|
||||
]) ?>
|
||||
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
|
||||
<?= WebUtil::printDist('vue', 'v_dipcenter', true) ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td>내 무 부<br><?= backButton() ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td colspan=9 align=center bgcolor=blue>외 교 관 계</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=130 align=center class=bg1>국 가 명</td>
|
||||
<td width=50 align=center class=bg1>국력</td>
|
||||
<td width=40 align=center class=bg1>장수</td>
|
||||
<td width=40 align=center class=bg1>속령</td>
|
||||
<td width=80 align=center class=bg1>상태</td>
|
||||
<td width=60 align=center class=bg1>기간</td>
|
||||
<td width=100 align=center class=bg1>종 료 시 점</td>
|
||||
</tr>
|
||||
<?php
|
||||
$admin = $gameStor->getValues(['year', 'month']);
|
||||
|
||||
$cityCntList = Util::convertPairArrayToDict($db->queryAllLists('SELECT nation, count(city) FROM city GROUP BY nation'));
|
||||
$dipStateList = Util::convertArrayToDict($db->query('SELECT you,state,term FROM diplomacy WHERE me = %i', $nationID), 'you');
|
||||
|
||||
$nationsList = getAllNationStaticInfo();
|
||||
uasort($nationsList, function (array $lhs, array $rhs) {
|
||||
return - ($lhs['power'] <=> $rhs['power']);
|
||||
});
|
||||
|
||||
foreach ($nationsList as $staticNation) :
|
||||
//속령수
|
||||
$staticNationID = $staticNation['nation'];
|
||||
$cityCnt = $cityCntList[$staticNation['nation']] ?? 0;
|
||||
|
||||
$dipStateText = '-';
|
||||
$dipTermText = '-';
|
||||
$dipEndDateText = '-';
|
||||
if ($staticNationID !== $nationID) {
|
||||
$diplomacyState = $dipStateList[$staticNationID];
|
||||
|
||||
$dipStateText = [
|
||||
0 => "<font color=red>교 전</font>",
|
||||
1 => "<font color=magenta>선포중</font>",
|
||||
2 => "통 상",
|
||||
7 => "<font color=green>불가침</font>",
|
||||
][$diplomacyState['state']];
|
||||
|
||||
if ($diplomacyState['term']) {
|
||||
$dipEndMonth = $admin['month'] + $diplomacyState['term'] - 1;
|
||||
$dipEndYear = $admin['year'] + intdiv($dipEndMonth, 12);
|
||||
$dipEndMonth = $dipEndMonth % 12 + 1;
|
||||
|
||||
$dipTermText = $diplomacyState['term'] . '개월';
|
||||
$dipEndDateText = "{$dipEndYear}年 {$dipEndMonth}月";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class='center' style='color:<?= newColor($staticNation['color']) ?>;background-color:<?= $staticNation['color'] ?>'><?= $staticNation['name'] ?></td>
|
||||
<td class='center'><?= $staticNation['power'] ?></td>
|
||||
<td class='center'><?= $staticNation['gennum'] ?></td>
|
||||
<td class='center'><?= $cityCnt ?></td>
|
||||
<td class='center'><?= $dipStateText ?></td>
|
||||
<td class='center'><?= $dipTermText ?></td>
|
||||
<td class='center'><?= $dipEndDateText ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
// 수입 연산
|
||||
$cityList = $db->query('SELECT * FROM city WHERE nation=%i', $nationID);
|
||||
$dedicationList = $db->query('SELECT dedication FROM general WHERE nation=%i AND npc!=5', $nationID);
|
||||
|
||||
$goldIncome = getGoldIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$warIncome = getWarGoldIncome($nation['type'], $cityList);
|
||||
$totalGoldIncome = $goldIncome + $warIncome;
|
||||
|
||||
$riceIncome = getRiceIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$wallIncome = getWallIncome($nation['nation'], $nation['level'], $nation['rate'], $nation['capital'], $nation['type'], $cityList);
|
||||
$totalRiceIncome = $riceIncome + $wallIncome;
|
||||
|
||||
$outcome = getOutcome($nation['bill'], $dedicationList);
|
||||
|
||||
$budgetgold = $nation['gold'] + $totalGoldIncome - $outcome;
|
||||
$budgetrice = $nation['rice'] + $totalRiceIncome - $outcome;
|
||||
$budgetgolddiff = $totalGoldIncome - $outcome;
|
||||
$budgetricediff = $totalRiceIncome - $outcome;
|
||||
|
||||
if ($budgetgolddiff > 0) {
|
||||
$budgetgolddiff = '+' . number_format($budgetgolddiff);
|
||||
} else {
|
||||
$budgetgolddiff = number_format($budgetgolddiff);
|
||||
}
|
||||
if ($budgetricediff > 0) {
|
||||
$budgetricediff = '+' . number_format($budgetricediff);
|
||||
} else {
|
||||
$budgetricediff = number_format($budgetricediff);
|
||||
}
|
||||
|
||||
?>
|
||||
<div class='tb_layout bg0' style='margin:auto;width: 1000px;' id="editorForm">
|
||||
|
||||
</div>
|
||||
<table class="tb_layout bg0" style="margin:auto;">
|
||||
<form name=form1 method=post action=c_dipcenter.php>
|
||||
|
||||
<tr>
|
||||
<td colspan=2 align=center bgcolor=green>예 산 & 정 책</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<table width=998 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td colspan=2 align=center class=bg1>자금 예산</td>
|
||||
<td colspan=2 align=center class=bg1>병량 예산</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=248 align=right class=bg1>현 재 </td>
|
||||
<td width=248 align=center><?= number_format($nation['gold']) ?></td>
|
||||
<td width=248 align=right class=bg1>현 재 </td>
|
||||
<td width=248 align=center><?= number_format($nation['rice']) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>단기수입 </td>
|
||||
<td align=center>+<?= number_format($warIncome) ?></td>
|
||||
<td align=right class=bg1>둔전수입 </td>
|
||||
<td align=center>+<?= number_format($wallIncome) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>세 금 </td>
|
||||
<td align=center>+<?= number_format($goldIncome) ?></td>
|
||||
<td align=right class=bg1>세 곡 </td>
|
||||
<td align=center>+<?= number_format($riceIncome) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>수입 / 지출 </td>
|
||||
<td align=center>+<?= number_format($totalGoldIncome) ?> / -<?= number_format($outcome) ?></td>
|
||||
<td align=right class=bg1>수입 / 지출 </td>
|
||||
<td align=center>+<?= number_format($totalRiceIncome) ?> / -<?= number_format($outcome) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>국고 예산 </td>
|
||||
<td align=center><?= number_format($budgetgold) ?> (<?= $budgetgolddiff ?>)</td>
|
||||
<td align=right class=bg1>병량 예산 </td>
|
||||
<td align=center><?= number_format($budgetrice) ?> (<?= $budgetricediff ?>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>세율 (5 ~ 30%) </td>
|
||||
<td align=center><input type=text <?= $read ?> name=rate style=text-align:right;color:white;background-color:black; size=3 maxlength=3 value=<?= $nation['rate'] ?>>% <input type=<?= $btn ?> name=btn value=세율></td>
|
||||
<td align=right class=bg1>봉급 지급률 (20 ~ 200%) </td>
|
||||
<td align=center><input type=text <?= $read ?> name=bill style=text-align:right;color:white;background-color:black; size=3 maxlength=3 value=<?= $nation['bill'] ?>>% <input type=<?= $btn ?> name=btn value=지급률></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=right class=bg1>기밀 권한 (1 ~ 99년) </td>
|
||||
<td align=center><input type=text <?= $read ?> name=secretlimit style=text-align:right;color:white;background-color:black; size=3 maxlength=3 value=<?= $nation['secretlimit'] ?>>년 <input type=<?= $btn ?> name=btn value=기밀권한></td>
|
||||
<td align=right class=bg1>전쟁 허용/금지 변경 가능</td>
|
||||
<td align=center><?= $nationStor->getValue('available_war_setting_cnt') ?>회(월 +<?= GameConst::$incAvailableWarSettingCnt ?>회, 최대<?= GameConst::$maxAvailableWarSettingCnt ?>회)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=4 align=center>
|
||||
<?php
|
||||
if ($nation['scout'] == 0) {
|
||||
echo "
|
||||
<input type=$btn name=btn value='임관 금지'>";
|
||||
} else {
|
||||
echo "
|
||||
<input type=$btn name=btn value='임관 허가'>";
|
||||
}
|
||||
|
||||
if ($nation['war'] == 0) {
|
||||
echo "
|
||||
<input type=$btn name=btn value='전쟁 금지'>";
|
||||
} else {
|
||||
echo "
|
||||
<input type=$btn name=btn value='전쟁 허가'>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td colspan=2>기밀 권한이란, 암행부를 열람할 수 있는 일반 장수의 최소 사관 년수를 의미합니다.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 height=10></td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td><?= backButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
// $btn, $msg, $scoutmsg, $rate, $bill, $secretlimit
|
||||
|
||||
$btn = Util::getPost('btn');
|
||||
//$msg = Util::getPost('msg');
|
||||
//$scoutmsg = Util::getPost('scoutMsg');
|
||||
$rate = Util::getPost('rate', 'int');
|
||||
$bill = Util::getPost('bill', 'int');
|
||||
$secretlimit = Util::getPost('secretlimit', 'int');
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
//내가 수뇌부이어야함
|
||||
$permission = checkSecretPermission($me);
|
||||
if ($permission < 0) {
|
||||
header('location:b_myBossInfo.php', true, 303);
|
||||
exit();
|
||||
} else if ($me['officer_level'] < 5 && $permission != 4) {
|
||||
header('location:b_myBossInfo.php', true, 303);
|
||||
exit();
|
||||
}
|
||||
|
||||
$nationID = $me['nation'];
|
||||
$nationStor = KVStorage::getStorage($db, $nationID, 'nation_env');
|
||||
|
||||
/*if ($btn == "국가방침 수정") {
|
||||
$msg = mb_substr($msg, 0, 16384);
|
||||
//$msg = StringUtil::
|
||||
$nationStor->notice = WebUtil::htmlPurify($msg);
|
||||
} elseif ($btn == "임관 권유문 수정") {
|
||||
$scoutmsg = mb_substr($scoutmsg, 0, 1000);
|
||||
$nationStor->scout_msg = WebUtil::htmlPurify($scoutmsg);
|
||||
} else*/if ($btn == "세율") {
|
||||
$rate = Util::valueFit($rate, 5, 30);
|
||||
$db->update('nation', [
|
||||
'rate' => $rate,
|
||||
], 'nation=%i', $nationID);
|
||||
} elseif ($btn == "지급률") {
|
||||
$bill = Util::valueFit($bill, 20, 200);
|
||||
$db->update('nation', [
|
||||
'bill' => $bill
|
||||
], 'nation=%i', $nationID);
|
||||
} elseif ($btn == "기밀권한") {
|
||||
$secretlimit = Util::valueFit($secretlimit, 1, 99);
|
||||
$db->update('nation', [
|
||||
'secretlimit' => $secretlimit
|
||||
], 'nation=%i', $nationID);
|
||||
} elseif ($btn == "임관 금지") {
|
||||
$db->update('nation', [
|
||||
'scout' => 1
|
||||
], 'nation=%i', $nationID);
|
||||
} elseif ($btn == "임관 허가") {
|
||||
$db->update('nation', [
|
||||
'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');
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetBill extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'amount',
|
||||
])
|
||||
->rule('integer', 'amount')
|
||||
->rule('min', 'amount', 20)
|
||||
->rule('max', 'amount', 200);
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$amount = $this->args['amount'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$db->update('nation', [
|
||||
'bill' => $amount
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetBlockScout extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'value',
|
||||
])
|
||||
->rule('boolean', 'value');
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$value = $this->args['value'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$db->update('nation', [
|
||||
'scout' => $value?1:0,
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetBlockWar extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'value',
|
||||
])
|
||||
->rule('boolean', 'value');
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$value = $this->args['value'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$db->update('nation', [
|
||||
'war' => $value?1:0,
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetRate extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'amount',
|
||||
])
|
||||
->rule('integer', 'amount')
|
||||
->rule('min', 'amount', 5)
|
||||
->rule('max', 'amount', 30);
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$amount = $this->args['amount'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$db->update('nation', [
|
||||
'rate' => $amount
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\API\Nation;
|
||||
|
||||
use sammo\Session;
|
||||
use DateTimeInterface;
|
||||
use sammo\DB;
|
||||
use sammo\KVStorage;
|
||||
use sammo\Validator;
|
||||
use sammo\WebUtil;
|
||||
|
||||
use function sammo\checkSecretPermission;
|
||||
|
||||
class SetSecretLimit extends \sammo\BaseAPI
|
||||
{
|
||||
public function validateArgs(): ?string
|
||||
{
|
||||
$v = new Validator($this->args);
|
||||
$v->rule('required', [
|
||||
'amount',
|
||||
])
|
||||
->rule('integer', 'amount')
|
||||
->rule('min', 'amount', 1)
|
||||
->rule('max', 'amount', 99);
|
||||
|
||||
if (!$v->validate()) {
|
||||
return $v->errorStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getRequiredSessionMode(): int
|
||||
{
|
||||
return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY;
|
||||
}
|
||||
|
||||
public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag)
|
||||
{
|
||||
$amount = $this->args['amount'];
|
||||
$userID = $session->userID;
|
||||
$db = DB::db();
|
||||
$me = $db->queryFirstRow('SELECT `no`,nation,`officer_level`,permission,penalty FROM general WHERE `owner`=%i', $userID);
|
||||
|
||||
$permission = checkSecretPermission($me, false);
|
||||
if($permission < 0){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
if ($me['officer_level'] < 5 && $permission != 4){
|
||||
return "권한이 부족합니다.";
|
||||
}
|
||||
|
||||
|
||||
$nationID = $me['nation'];
|
||||
|
||||
$db->update('nation', [
|
||||
'bill' => $amount
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
return [
|
||||
'result' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
@import "@scss/game_bg.scss";
|
||||
@import "@scss/util.scss";
|
||||
@import "@scss/editor_component.scss";
|
||||
@import "@scss/common_legacy.scss";
|
||||
|
||||
.diplomacyTitle {
|
||||
background-color: $blue;
|
||||
@@ -32,6 +33,11 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#scoutMsgForm .ProseMirror{
|
||||
max-height: 200px;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
@include media-1000px {
|
||||
#container {
|
||||
width: 1000px;
|
||||
|
||||
+5
-1
@@ -9,4 +9,8 @@
|
||||
.s-border-tb {
|
||||
border-top: gray solid 1px;
|
||||
border-bottom: gray solid 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.avoid-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
+368
-13
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<MyToast v-model="toasts" />
|
||||
<div id="container" class="pageNationStratFinan bg0">
|
||||
<TopBackBar title="내무부" />
|
||||
<div class="diplomacyTitle">외교관계</div>
|
||||
@@ -114,20 +115,206 @@
|
||||
</div>
|
||||
|
||||
<div class="financeTitle">예산&정책</div>
|
||||
<div class="row gx-0 center">
|
||||
<div class="col-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-12 bg2">자금 예산</div>
|
||||
<div class="col-4 bg1">현 재</div>
|
||||
<div class="col-8">{{ gold.toLocaleString() }}</div>
|
||||
<div class="col-4 bg1">단기수입</div>
|
||||
<div class="col-8">{{ income.gold.war.toLocaleString() }}</div>
|
||||
<div class="col-4 bg1">세 금</div>
|
||||
<div class="col-8">
|
||||
{{ Math.floor(incomeGoldCity).toLocaleString() }}
|
||||
</div>
|
||||
<div class="col-4 bg1">수입/지출</div>
|
||||
<div class="col-8">
|
||||
+{{ Math.floor(incomeGold).toLocaleString() }} /
|
||||
{{ Math.floor(-outcomeByBill).toLocaleString() }}
|
||||
</div>
|
||||
<div class="col-4 bg1">국고 예산</div>
|
||||
<div class="col-8">
|
||||
{{ Math.floor(gold + incomeGold - outcomeByBill).toLocaleString() }}
|
||||
({{ incomeGold >= outcomeByBill ? "+" : ""
|
||||
}}{{ Math.floor(incomeGold - outcomeByBill).toLocaleString() }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-12 bg2">군량 예산</div>
|
||||
<div class="col-4 bg1">현 재</div>
|
||||
<div class="col-8">{{ rice.toLocaleString() }}</div>
|
||||
<div class="col-4 bg1">둔점수입</div>
|
||||
<div class="col-8">
|
||||
{{ Math.floor(income.rice.wall).toLocaleString() }}
|
||||
</div>
|
||||
<div class="col-4 bg1">세 금</div>
|
||||
<div class="col-8">
|
||||
{{ Math.floor(incomeRiceCity).toLocaleString() }}
|
||||
</div>
|
||||
<div class="col-4 bg1">수입/지출</div>
|
||||
<div class="col-8">
|
||||
+{{ Math.floor(incomeRice).toLocaleString() }} /
|
||||
{{ Math.floor(-outcomeByBill).toLocaleString() }}
|
||||
</div>
|
||||
<div class="col-4 bg1">국고 예산</div>
|
||||
<div class="col-8">
|
||||
{{ Math.floor(rice + incomeRice - outcomeByBill).toLocaleString() }}
|
||||
({{ incomeRice >= outcomeByBill ? "+" : ""
|
||||
}}{{ Math.floor(incomeRice - outcomeByBill).toLocaleString() }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-4 bg1 d-grid">
|
||||
<div class="align-self-center">
|
||||
세율 <span class="avoid-wrap">(5 ~ 30%)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8 row gx-0">
|
||||
<div class="col-md-6 offset-md-3 align-self-center">
|
||||
<div class="input-group my-0">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control py-1 f_tnum px-0 text-end"
|
||||
v-model="policy.rate"
|
||||
min="5"
|
||||
max="30"
|
||||
/><span class="input-group-text py-1 f_tnum">%</span
|
||||
><b-button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
@click="setRate"
|
||||
v-if="editable"
|
||||
>변경</b-button
|
||||
><b-button size="sm" @click="rollbackRate" v-if="editable"
|
||||
>취소</b-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-4 bg1 d-grid">
|
||||
<div class="align-self-center">
|
||||
지급률 <span class="avoid-wrap">(20 ~ 200%)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8 row gx-0">
|
||||
<div class="col-md-6 offset-md-3 align-self-center">
|
||||
<div class="input-group my-0">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control py-1 f_tnum px-0 text-end"
|
||||
v-model="policy.bill"
|
||||
min="20"
|
||||
max="200"
|
||||
/><span class="input-group-text py-1 f_tnum">%</span
|
||||
><b-button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
@click="setBill"
|
||||
v-if="editable"
|
||||
>변경</b-button
|
||||
><b-button size="sm" @click="rollbackBill" v-if="editable"
|
||||
>취소</b-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="row gx-0">
|
||||
<div class="col-4 bg1 d-grid">
|
||||
<div class="align-self-center">
|
||||
기밀 권한 <span class="avoid-wrap">(1 ~ 99년)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8 row gx-0">
|
||||
<div class="col-md-6 offset-md-3 align-self-center">
|
||||
<div class="input-group my-0">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control py-1 f_tnum px-0 text-end"
|
||||
v-model="policy.secretLimit"
|
||||
min="1"
|
||||
max="99"
|
||||
/><span class="input-group-text py-1 f_tnum">년</span
|
||||
><b-button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
@click="setSecretLimit"
|
||||
v-if="editable"
|
||||
>변경</b-button
|
||||
><b-button
|
||||
size="sm"
|
||||
@click="rollbackSecretLimit"
|
||||
v-if="editable"
|
||||
>취소</b-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<div class="row gx-0">
|
||||
<div class="col-4 bg1 d-grid">
|
||||
<div class="align-self-center">전쟁 금지 설정</div>
|
||||
</div>
|
||||
<div class="col-8 d-grid">
|
||||
<div class="align-self-center">10회(월 +2회, 최대10회)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3 col-md-4"></div>
|
||||
<div class="col-3 col-md-2 row gx-0">
|
||||
<div class="col-9 col-md-8 text-end p-2">전쟁 금지</div>
|
||||
<div class="col-3 col-md-4 py-2">
|
||||
<b-form-checkbox
|
||||
v-model="policy.blockWar"
|
||||
@change="setBlockWar"
|
||||
switch
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3 col-md-2 row gx-0">
|
||||
<div class="col-9 col-md-8 text-end p-2">임관 금지</div>
|
||||
<div class="col-3 col-md-4 py-2">
|
||||
<b-form-checkbox
|
||||
v-model="policy.blockScout"
|
||||
@change="setBlockScout"
|
||||
switch
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>추가 설정</div>
|
||||
<BottomBar title="내무부" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import "@scss/nationStratFinan.scss";
|
||||
import TipTap from "./components/TipTap.vue";
|
||||
import { defineComponent, reactive, ref, toRefs } from "vue";
|
||||
import { computed, defineComponent, reactive, ref, toRefs } from "vue";
|
||||
import { isString } from "lodash";
|
||||
import { diplomacyState, diplomacyStateInfo, NationStaticItem } from "./defs";
|
||||
import {
|
||||
diplomacyState,
|
||||
diplomacyStateInfo,
|
||||
NationStaticItem,
|
||||
ToastType,
|
||||
} from "./defs";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import BottomBar from "@/components/BottomBar.vue";
|
||||
import { joinYearMonth } from "@/util/joinYearMonth";
|
||||
import { parseYearMonth } from "@/util/parseYearMonth";
|
||||
import MyToast from "@/components/MyToast.vue";
|
||||
|
||||
type NationItem = NationStaticItem & {
|
||||
cityCnt: number;
|
||||
@@ -158,8 +345,9 @@ declare const staticValues: {
|
||||
wall: number;
|
||||
};
|
||||
};
|
||||
outcome: number;
|
||||
|
||||
polcy: {
|
||||
policy: {
|
||||
rate: number;
|
||||
bill: number;
|
||||
secretLimit: number;
|
||||
@@ -178,9 +366,10 @@ export default defineComponent({
|
||||
TipTap,
|
||||
TopBackBar,
|
||||
BottomBar,
|
||||
MyToast,
|
||||
},
|
||||
setup() {
|
||||
staticValues;
|
||||
const toasts = ref<ToastType[]>([]);
|
||||
const self = reactive(staticValues);
|
||||
|
||||
let oldNationMsg = staticValues.nationMsg;
|
||||
@@ -203,9 +392,17 @@ export default defineComponent({
|
||||
});
|
||||
oldNationMsg = msg;
|
||||
inEditNationMsg.value = false;
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "국가 방침을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
alert(e);
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
@@ -229,9 +426,17 @@ export default defineComponent({
|
||||
});
|
||||
oldScoutMsg = msg;
|
||||
inEditScoutMsg.value = false;
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "임관 권유문을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
alert(e);
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
@@ -240,7 +445,7 @@ export default defineComponent({
|
||||
const trackTiptapFormHeight = (target: string) => {
|
||||
let form: HTMLElement | null = null;
|
||||
let outerForm: HTMLElement | null = null;
|
||||
return () => {
|
||||
function handler() {
|
||||
if (!form) {
|
||||
form = document.querySelector(`${target} .ProseMirror`);
|
||||
}
|
||||
@@ -257,10 +462,148 @@ export default defineComponent({
|
||||
if (parentHeight != clientHeight) {
|
||||
outerForm.style.height = `${clientHeight}px`;
|
||||
}
|
||||
};
|
||||
}
|
||||
window.addEventListener("orientationchange", handler, true);
|
||||
|
||||
return handler;
|
||||
};
|
||||
|
||||
const incomeGoldCity = computed(() => {
|
||||
return (self.income.gold.city * self.policy.rate) / 100;
|
||||
});
|
||||
|
||||
const incomeGold = computed(() => {
|
||||
return incomeGoldCity.value + self.income.gold.war;
|
||||
});
|
||||
|
||||
const incomeRiceCity = computed(() => {
|
||||
return (self.income.rice.city * self.policy.rate) / 100;
|
||||
});
|
||||
|
||||
const incomeRice = computed(() => {
|
||||
return incomeRiceCity.value + self.income.rice.wall;
|
||||
});
|
||||
|
||||
const outcomeByBill = computed(() => {
|
||||
return (self.outcome * self.policy.bill) / 100;
|
||||
});
|
||||
|
||||
let oldRate = staticValues.policy.rate;
|
||||
async function setRate() {
|
||||
const rate = self.policy.rate;
|
||||
try {
|
||||
await SammoAPI.Nation.SetRate({ amount: rate });
|
||||
oldRate = rate;
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "세율을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
function rollbackRate() {
|
||||
self.policy.rate = oldRate;
|
||||
}
|
||||
|
||||
let oldBill = staticValues.policy.bill;
|
||||
async function setBill() {
|
||||
const bill = self.policy.bill;
|
||||
try {
|
||||
await SammoAPI.Nation.SetBill({ amount: bill });
|
||||
oldBill = bill;
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "지급률을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
function rollbackBill() {
|
||||
self.policy.bill = oldBill;
|
||||
}
|
||||
|
||||
let oldSecretLimit = staticValues.policy.secretLimit;
|
||||
async function setSecretLimit() {
|
||||
const secretLimit = self.policy.secretLimit;
|
||||
try {
|
||||
await SammoAPI.Nation.SetSecretLimit({ amount: secretLimit });
|
||||
oldSecretLimit = secretLimit;
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "기밀 권한을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
function rollbackSecretLimit() {
|
||||
self.policy.secretLimit = oldSecretLimit;
|
||||
}
|
||||
|
||||
async function setBlockWar() {
|
||||
try {
|
||||
await SammoAPI.Nation.SetBlockWar({ value: self.policy.blockWar });
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "전쟁 금지 설정을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function setBlockScout() {
|
||||
try {
|
||||
await SammoAPI.Nation.SetBlockScout({ value: self.policy.blockScout });
|
||||
toasts.value.push({
|
||||
title: "변경",
|
||||
content: "임관 설정을 변경했습니다.",
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.value.push({
|
||||
title: "에러",
|
||||
content: e,
|
||||
type: "danger",
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
toasts,
|
||||
|
||||
...toRefs(self),
|
||||
inEditNationMsg,
|
||||
inEditScoutMsg,
|
||||
@@ -276,12 +619,24 @@ export default defineComponent({
|
||||
|
||||
trackNationMsgHeight: trackTiptapFormHeight("#noticeForm"),
|
||||
trackScoutMsgHeight: trackTiptapFormHeight("#scoutMsgForm"),
|
||||
|
||||
incomeGoldCity,
|
||||
incomeGold,
|
||||
incomeRiceCity,
|
||||
incomeRice,
|
||||
outcomeByBill,
|
||||
|
||||
setRate,
|
||||
rollbackRate,
|
||||
setBill,
|
||||
rollbackBill,
|
||||
setSecretLimit,
|
||||
rollbackSecretLimit,
|
||||
|
||||
setBlockWar,
|
||||
setBlockScout,
|
||||
};
|
||||
},
|
||||
methods: {},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import "@scss/nationStratFinan.scss";
|
||||
</style>
|
||||
</script>
|
||||
@@ -40,6 +40,11 @@ const apiRealPath = {
|
||||
Nation: {
|
||||
SetNotice: done,
|
||||
SetScoutMsg: done,
|
||||
SetBill: done,
|
||||
SetRate: done,
|
||||
SetSecretLimit: done,
|
||||
SetBlockWar: done,
|
||||
SetBlockScout: done,
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ $wallIncome = getWallIncome(
|
||||
$cityList
|
||||
);
|
||||
|
||||
$incomes = [
|
||||
$income = [
|
||||
'gold' => [
|
||||
'city' => $goldIncome,
|
||||
'war' => $warIncome,
|
||||
@@ -132,7 +132,7 @@ $outcome = getOutcome(100, $dedicationList);
|
||||
|
||||
'gold' => $nation['gold'],
|
||||
'rice' => $nation['rice'],
|
||||
'income' => $incomeList,
|
||||
'income' => $income,
|
||||
'outcome' => $outcome,
|
||||
|
||||
'policy' => [
|
||||
|
||||
Reference in New Issue
Block a user