From d7989ab34dba1425f348e5585caf0973efc6a490 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 8 Mar 2020 13:26:56 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EB=A0=B9=EB=B6=80=20=EB=B0=80?= =?UTF-8?q?=EA=B8=B0=20=EB=8B=B9=EA=B8=B0=EA=B8=B0=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EA=B8=B0=EC=A1=B4=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_chiefcenter.php | 4 +-- hwe/func_command.php | 2 +- hwe/j_chief_turn.php | 39 ++++++++++++++++++++ hwe/{j_turn.php => j_general_turn.php} | 0 hwe/js/chiefCenter.js | 23 ++++++++++++ hwe/js/main.js | 4 +-- hwe/turn.php | 49 -------------------------- hwe/turn_pop_core.php | 17 --------- hwe/turn_push_core.php | 17 --------- 9 files changed, 67 insertions(+), 88 deletions(-) create mode 100644 hwe/j_chief_turn.php rename hwe/{j_turn.php => j_general_turn.php} (100%) delete mode 100644 hwe/turn.php delete mode 100644 hwe/turn_pop_core.php delete mode 100644 hwe/turn_push_core.php diff --git a/hwe/b_chiefcenter.php b/hwe/b_chiefcenter.php index 994d8de4..5ef4df50 100644 --- a/hwe/b_chiefcenter.php +++ b/hwe/b_chiefcenter.php @@ -67,8 +67,8 @@ var maxChiefTurn = ; ?>
update('nation_turn', [ 'turn_idx'=>$db->sqleval('turn_idx + %i', $turnCnt) - ], 'nation_id=%i AND level=%i', $nationID, $level); + ], 'nation_id=%i AND level=%i ORDER BY turn_idx DESC', $nationID, $level); $db->update('nation_turn', [ 'turn_idx'=>$db->sqleval('turn_idx - %i', GameConst::$maxChiefTurn), 'action'=>'휴식', diff --git a/hwe/j_chief_turn.php b/hwe/j_chief_turn.php new file mode 100644 index 00000000..2224d385 --- /dev/null +++ b/hwe/j_chief_turn.php @@ -0,0 +1,39 @@ +setReadOnly(); +$userID = Session::getUserID(); + +$turnAmount = Util::getReq('amount', 'int'); + +$db = DB::db(); +$me = $db->queryFirstRow('SELECT no,nation,level FROM general WHERE owner=%i', $userID); + +if($me['nation'] == 0){ + Json::die([ + 'result'=>false, + 'reason'=>'국가에 소속되어 있지 않습니다.', + ]); +} + +if($me['level'] < 5){ + Json::die([ + 'result'=>false, + 'reason'=>'수뇌가 아닙니다.', + ]); +} + +if($turnAmount > 0){ + pushNationCommand($me['nation'], $me['level']); +} +else{ + pullNationCommand($me['nation'], $me['level']); +} + +Json::die([ + 'result'=>true, + 'reason'=>'success', +]); \ No newline at end of file diff --git a/hwe/j_turn.php b/hwe/j_general_turn.php similarity index 100% rename from hwe/j_turn.php rename to hwe/j_general_turn.php diff --git a/hwe/js/chiefCenter.js b/hwe/js/chiefCenter.js index 43d1a710..92931086 100644 --- a/hwe/js/chiefCenter.js +++ b/hwe/js/chiefCenter.js @@ -117,6 +117,21 @@ function reserveTurn(turnList, command){ }, errUnknown); } +function pushTurn(turnCnt){ + $.post({ + url:'j_chief_turn.php', + dataType:'json', + data:{ + amount:turnCnt + } + }).then(function(data){ + if(!data.result){ + alert(data.reason); + } + reloadTable(); + }, errUnknown); +} + jQuery(function($){ chiefTableObj= genChiefTableObj(); @@ -138,5 +153,13 @@ $('#setCommand').click(function(){ } return false; }); + +$('#turnPush').click(function(){ + pushTurn(1); +}); + +$('#turnPull').click(function(){ + pushTurn(-1); +}); }) \ No newline at end of file diff --git a/hwe/js/main.js b/hwe/js/main.js index e5956340..1a3e5155 100644 --- a/hwe/js/main.js +++ b/hwe/js/main.js @@ -75,7 +75,7 @@ function myclock() { function pushTurn(pushAmount){ $.post({ - url:'j_turn.php', + url:'j_general_turn.php', dataType:'json', data:{ amount:pushAmount @@ -90,7 +90,7 @@ function pushTurn(pushAmount){ function repeatTurn(repeatAmount){ $.post({ - url:'j_turn.php', + url:'j_general_turn.php', dataType:'json', data:{ amount:repeatAmount, diff --git a/hwe/turn.php b/hwe/turn.php deleted file mode 100644 index bbb34b47..00000000 --- a/hwe/turn.php +++ /dev/null @@ -1,49 +0,0 @@ - 12){ - $sel = 1; -} - -$session = Session::requireGameLogin()->setReadOnly(); -$userID = Session::getUserID(); - -$db = DB::db(); -$generalID = $session->generalID; -$gameStor = KVStorage::getStorage($db, 'game_env'); - -increaseRefresh("턴반복", 1); - -$myActionCnt = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', $userID); - -$con = checkLimit($myActionCnt); -if($con >= 2) { - header('location:commandlist.php', true, 303); - exit(); - } - -switch($type) { -case 0://반복 - $valueMap = []; - foreach(range($sel, GameConst::$maxTurn - 1) as $idx){ - $src = $idx % $sel; - $valueMap['turn'.$idx] = $db->sqleval('%b', 'turn'.$src); - } - $db->update('general', $valueMap, 'owner=%i', $userID); - break; -case 1://미루기 - pushGeneralCommand($generalID, $sel); - break; -case 2://당기기 - pullGeneralCommand($generalID, $sel); - break; -} - -header('location:commandlist.php', true, 303); diff --git a/hwe/turn_pop_core.php b/hwe/turn_pop_core.php deleted file mode 100644 index 82d9442f..00000000 --- a/hwe/turn_pop_core.php +++ /dev/null @@ -1,17 +0,0 @@ -setReadOnly(); -$userID = Session::getUserID(); - -$db = DB::db(); -$me = $db->queryFirstRow('SELECT no,nation,level FROM general WHERE owner=%i', $userID); - -if($me['level'] >= 5 && $me['nation'] > 0){ - pullNationCommand($me['nation'], $me['level']); -} - -header('location:b_chiefcenter.php', true, 303); diff --git a/hwe/turn_push_core.php b/hwe/turn_push_core.php deleted file mode 100644 index b7294405..00000000 --- a/hwe/turn_push_core.php +++ /dev/null @@ -1,17 +0,0 @@ -setReadOnly(); -$userID = Session::getUserID(); - -$db = DB::db(); -$me = $db->queryFirstRow('SELECT no,nation,level FROM general WHERE owner=%i', $userID); - -if($me['level'] >= 5 && $me['nation'] > 0){ - pushNationCommand($me['nation'], $me['level']); -} - -header('location:b_chiefcenter.php', true, 303);