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);