From 95a0b1d77ee44ed74eef956004eabbd0bf3d613a Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 16 Jan 2019 02:47:48 +0900 Subject: [PATCH] =?UTF-8?q?permission,=20penalty=20=EB=8C=80=EC=9D=91=20?= =?UTF-8?q?=EC=A4=80=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 52 +++++++++++++++++++++++++++++++++++++++++++++ hwe/t_diplomacy.php | 28 ++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 hwe/t_diplomacy.php diff --git a/hwe/func.php b/hwe/func.php index 1fa240ab..7b371a22 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -395,6 +395,58 @@ function myNationInfo() { "; } +function checkSecretPermission($me){ + if(!key_exists($me['penalty']) || !key_exists($me['permission'])){ + trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족'); + } + $penalty = Json::decode($me['penalty'])??[]; + $permission = $me['permission']; + + if(!$me['nation']){ + return 0; + } + + if($me['level'] == 0){ + return 0; + } + + $secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']); + + if($pernalty['noSecret']??false){ + return 0; + } + + $secretMin = 0; + $secretMax = 3; + if($penalty['noTopSecret']??false){ + $secretMax = 1; + } + else if($penalty['noChief']??false){ + $secretMax = 1; + } + else if($penalty['noAmbassador']??false){ + $secretMax = 2; + } + + if($me['permission'] == 'auditor' || $me['permission'] == 'ambassador'){ + $secretMin = 3; + } + else if($me['level'] == 12){ + $secretMin = 3; + } + else if($me['level'] >= 5){ + $secretMin = 2; + } + else if($me['level'] > 1){ + $secretMin = 1; + } + else if($me['belong'] >= $secretLimit){ + $secretMin = 1; + } + + return min($secretMin, $secretMax); +} + function addCommand($typename, $value, $valid = 1, $color=0) { if($valid == 1) { switch($color) { diff --git a/hwe/t_diplomacy.php b/hwe/t_diplomacy.php new file mode 100644 index 00000000..79df189a --- /dev/null +++ b/hwe/t_diplomacy.php @@ -0,0 +1,28 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$db = DB::db(); +$gameStor = KVStorage::getStorage($db, 'game_env'); + +increaseRefresh("내무부", 1); + +$me = $db->queryFirstRow('SELECT no, nation, level, permission, con, turntime, belong, penalty FROM general WHERE owner=%i', $userID); +$nation = $db->queryFirstRow('SELECT secretlimit, msg, scoutmsg FROM nation WHERE nation = %i', $me['nation']); + +$con = checkLimit($me['con']); +if ($con >= 2) { + printLimitMsg($me['turntime']); + exit(); +} + +$permission = checkSecretPermission($me); +if ($permission == 0) { + echo "권한이 부족합니다. 수뇌부가 아니거나 사관년도가 부족합니다."; + exit(); +} \ No newline at end of file