From 82f2eecfe8754d21fdc98823e281a5c332177953 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 1 Jun 2020 02:17:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=B4=20=EC=84=A4=EC=A0=95=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8F=99=EC=9E=91=20=EB=B0=A9=EC=8B=9D=20?= =?UTF-8?q?=EC=9D=BC=EB=8B=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .phan/config.php | 4 +- hwe/b_myPage.php | 98 +++---------------- ..._immediately.php => j_die_immediately.php} | 36 ++++--- hwe/j_set_chief_command.php | 2 + hwe/j_set_general_command.php | 2 + hwe/j_set_my_setting.php | 75 ++++++++++++++ hwe/j_set_npc_control.php | 1 + hwe/j_simulate_battle.php | 2 + hwe/j_troop.php | 2 + hwe/{c_vacation.php => j_vacation.php} | 10 +- hwe/js/myPage.js | 80 +++++++++++++++ 11 files changed, 210 insertions(+), 102 deletions(-) rename hwe/{c_die_immediately.php => j_die_immediately.php} (59%) create mode 100644 hwe/j_set_my_setting.php rename hwe/{c_vacation.php => j_vacation.php} (71%) diff --git a/.phan/config.php b/.phan/config.php index c27746b0..01bed4af 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -51,10 +51,8 @@ return [ 'hwe/b_tournament.php', 'hwe/b_troop.php', 'hwe/c_auction.php', - 'hwe/c_die_immediately.php', 'hwe/c_dipcenter.php', 'hwe/c_tournament.php', - 'hwe/c_vacation.php', 'hwe/c_vote.php', 'hwe/func.php', 'hwe/func_auction.php', @@ -83,6 +81,7 @@ return [ 'hwe/j_board_comment_add.php', 'hwe/j_board_get_articles.php', 'hwe/j_chief_turn.php', + 'hwe/j_die_immediately.php', 'hwe/j_diplomacy_destroy_letter.php', 'hwe/j_diplomacy_get_letter.php', 'hwe/j_diplomacy_respond_letter.php', @@ -115,6 +114,7 @@ return [ 'hwe/j_set_general_command.php', 'hwe/j_simulate_battle.php', 'hwe/j_troop.php', + 'hwe/j_vacation.php', 'hwe/lib.php', 'hwe/process_war.php', 'hwe/select_npc.php', diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index 36d3eb86..4ee0f0b5 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -4,30 +4,9 @@ namespace sammo; include "lib.php"; include "func.php"; -$btn = Util::getPost('btn'); -$defence_train = Util::getPost('defence_train', 'int', 80); -$tnmt = Util::getPost('tnmt', 'int', 1); -//$detachNPC = Util::getPost('detachNPC', 'bool'); -$detachNPC = false; - $showDieImmediatelyBtn = false; $availableDieImmediately = false; -if ($defence_train <= 40) { - $defence_train = 40; -} - -if($defence_train <= 90){ - $defence_train = Util::round($defence_train, -1); -} -else{ - $defence_train = 999; -} - -if($tnmt < 0 || $tnmt > 1){ - $tnmt = 1; -} - //로그인 검사 $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); @@ -42,56 +21,17 @@ $me = General::createGeneralObjFromDB($generalID); $myset = $me->getVar('myset'); if ($myset > 0) { - $submit = 'submit'; + $submit = 'button'; } else { $submit = 'hidden'; } -if (($btn == "설정저장" || $detachNPC) && $myset > 0) { - if ($myset > 1) { - $submit = 'submit'; - } else { - $submit = 'hidden'; - } - - if($defence_train != $me->getVar('defence_train')){ - if($defence_train == 999){ - $me->increaseVar('myset', -1); - $me->setVar('defence_train', $defence_train); - $me->increaseVar('train', -3); - $me->increaseVar('atmos', -3); - } - else{ - $me->increaseVar('myset', -1); - $me->setVar('defence_train', $defence_train); - } - $myset -= 1; - } - - if($me->getVar('tnmt') != $tnmt){ - $me->setVar('tnmt', $tnmt); - } - - if($me->getNPCType() == 1 && $detachNPC){ - $turnterm = $gameStor->turnterm; - - if($turnterm < 10){ - $targetKillTurn = 30 / $turnterm; - } - else{ - $targetKillTurn = 60 / $turnterm; - } - $me->setVar('killturn', $targetKillTurn); - } -} -$me->applyDB($db); - +$targetTime = addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2); if($gameStor->turntime <= $gameStor->opentime){ //서버 가오픈시 할 수 있는 행동 - if($me->getNPCType() == 0){ $showDieImmediatelyBtn = true; - if(addTurn($me->getVar('lastrefresh'), $gameStor->turnterm, 2) <= TimeUtil::now()){ + if($targetTime <= TimeUtil::now()){ $availableDieImmediately = true; } } @@ -105,6 +45,9 @@ if($gameStor->turntime <= $gameStor->opentime){ <?=UniqueConst::$serverName?>: 내정보 + @@ -112,21 +55,6 @@ if($gameStor->turntime <= $gameStor->opentime){ - @@ -140,13 +68,12 @@ $('#die_immediately').click(function(){ -
토너먼트 【 - getVar('tnmt')==0?"checked":""; ?>>수동참여 - getVar('tnmt')==1?"checked":""; ?>>자동참여 + getVar('tnmt')==0?"checked":""; ?>>수동참여 + getVar('tnmt')==1?"checked":""; ?>>자동참여 】
개막직전 남는자리가 있을경우 랜덤하게 참여합니다.

- 수비 【 @@ -154,18 +81,17 @@ $('#die_immediately').click(function(){

- name=btn style=background-color:;color:white;width:160px;height:30px;font-size:13px; value=설정저장>
+ id='set_my_setting' name=btn style=background-color:;color:white;width:160px;height:30px;font-size:13px; value=설정저장>
설정저장은 이달중 회 남았습니다.

-
autorun_user['limit_minutes']??false)): ?> 휴 가 신 청
-

+

- 가오픈 기간 내 장수 삭제
+ 가오픈 기간 내 장수 삭제 ( 부터)


diff --git a/hwe/c_die_immediately.php b/hwe/j_die_immediately.php similarity index 59% rename from hwe/c_die_immediately.php rename to hwe/j_die_immediately.php index feb4f986..86063d0f 100644 --- a/hwe/c_die_immediately.php +++ b/hwe/j_die_immediately.php @@ -4,6 +4,9 @@ namespace sammo; include "lib.php"; include "func.php"; + +WebUtil::requireAJAX(); + $availableDieImmediately = false; //로그인 검사 @@ -16,25 +19,31 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); $general = $db->queryFirstRow('SELECT no,name,owner_name,npc,lastrefresh FROM general WHERE owner=%i AND npc = 0', $userID); if(!$general){ - header('location:b_myPage.php'); - die(); + Json::die([ + 'result'=>false, + 'reason'=>'장수가 없습니다.' + ]); } increaseRefresh("장수 삭제", 1); $gameStor->cacheValues(['turnterm', 'opentime', 'turntime', 'year', 'month']); -if($gameStor->turntime <= $gameStor->opentime){ - //서버 가오픈시 할 수 있는 행동 - if(addTurn($general['lastrefresh'], $gameStor->turnterm, 2) <= TimeUtil::now()){ - $availableDieImmediately = true; - } +if($gameStor->turntime > $gameStor->opentime){ + Json::die([ + 'result'=>false, + 'reason'=>'이미 서버가 시작되었습니다.' + ]); } -if(!$availableDieImmediately){ - header('location:b_myPage.php'); - die(); -} +$targetTime = addTurn($general['lastrefresh'], $gameStor->turnterm, 2); +if($targetTime > TimeUtil::now()){ + $targetTimeShort = substr($targetTime, 0, 19); + Json::die([ + 'result'=>false, + 'reason'=>"아직 삭제할 수 없습니다. {$targetTimeShort} 부터 가능합니다." + ]); +} $generalObj = General::createGeneralObjFromDB($general['no']); @@ -46,4 +55,7 @@ $josaYi = JosaUtil::pick($generalName, '이'); $generalObj->kill($db, true, "{$generalName}{$josaYi} 이 홀연히 모습을 감추었습니다"); $session->logoutGame(); -header('location:..'); \ No newline at end of file +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/j_set_chief_command.php b/hwe/j_set_chief_command.php index 10dc8981..ced76fba 100644 --- a/hwe/j_set_chief_command.php +++ b/hwe/j_set_chief_command.php @@ -8,6 +8,8 @@ WebUtil::requireAJAX(); $session = Session::requireGameLogin([])->setReadOnly(); +increaseRefresh("사령턴 입력", 0); + $generalID = $session->generalID; diff --git a/hwe/j_set_general_command.php b/hwe/j_set_general_command.php index a587184c..72e91d3b 100644 --- a/hwe/j_set_general_command.php +++ b/hwe/j_set_general_command.php @@ -8,6 +8,8 @@ WebUtil::requireAJAX(); $session = Session::requireGameLogin([])->setReadOnly(); +increaseRefresh("턴 입력", 0); + $generalID = $session->generalID; $action = Util::getPost('action', 'string'); diff --git a/hwe/j_set_my_setting.php b/hwe/j_set_my_setting.php new file mode 100644 index 00000000..0a2c77d4 --- /dev/null +++ b/hwe/j_set_my_setting.php @@ -0,0 +1,75 @@ +setReadOnly(); +$userID = Session::getUserID(); +$generalID = $session->generalID; + +increaseRefresh("내정보 수정", 0); + +$action = Util::getPost('action'); +$tnmt = Util::getPost('tnmt', 'int', 1); +$defence_train = Util::getPost('defence_train', 'int', 80); +//$detachNPC = Util::getPost('detachNPC', 'bool'); +$detachNPC = false; + +if ($defence_train <= 40) { + $defence_train = 40; +} + +if($defence_train <= 90){ + $defence_train = Util::round($defence_train, -1); +} +else{ + $defence_train = 999; +} + +if($tnmt < 0 || $tnmt > 1){ + $tnmt = 1; +} + +$db = DB::db(); +$me = General::createGeneralObjFromDB($generalID); + + +if($defence_train != $me->getVar('defence_train')){ + if($defence_train == 999){ + $me->increaseVar('myset', -1); + $me->setVar('defence_train', $defence_train); + $me->increaseVar('train', -3); + $me->increaseVar('atmos', -3); + } + else{ + $me->increaseVar('myset', -1); + $me->setVar('defence_train', $defence_train); + } + $myset -= 1; +} + +if($me->getVar('tnmt') != $tnmt){ + $me->setVar('tnmt', $tnmt); +} + +if($me->getNPCType() == 1 && $detachNPC){ + $turnterm = $gameStor->turnterm; + + if($turnterm < 10){ + $targetKillTurn = 30 / $turnterm; + } + else{ + $targetKillTurn = 60 / $turnterm; + } + $me->setVar('killturn', $targetKillTurn); +} + +$me->applyDB($db); + +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); \ No newline at end of file diff --git a/hwe/j_set_npc_control.php b/hwe/j_set_npc_control.php index 50253861..f29c8f42 100644 --- a/hwe/j_set_npc_control.php +++ b/hwe/j_set_npc_control.php @@ -10,6 +10,7 @@ $session = Session::requireGameLogin([])->setReadOnly(); $userID = Session::getUserID(); $generalID = $session->generalID; +increaseRefresh("NPC 정책 수정", 0); $type = Util::getPost('type', 'string'); $data = Util::getPost('data', 'string'); diff --git a/hwe/j_simulate_battle.php b/hwe/j_simulate_battle.php index d8860be5..1a36a687 100644 --- a/hwe/j_simulate_battle.php +++ b/hwe/j_simulate_battle.php @@ -9,6 +9,8 @@ WebUtil::requireAJAX(); $session = Session::requireLogin([])->setReadOnly(); $userID = Session::getUserID(); +increaseRefresh("시뮬레이터", 0); + $query = Util::getPost('query'); if($query === null){ Json::die([ diff --git a/hwe/j_troop.php b/hwe/j_troop.php index 02caf873..90152801 100644 --- a/hwe/j_troop.php +++ b/hwe/j_troop.php @@ -15,6 +15,8 @@ $troop = Util::getPost('troop', 'int'); $session = Session::requireGameLogin([])->setReadOnly(); $userID = $session::getUserID(); +increaseRefresh("부대명령", 0); + $db = DB::db(); $me = $db->queryFirstRow('SELECT `no`, name, nation, troop FROM general WHERE `owner`=%i', $userID); diff --git a/hwe/c_vacation.php b/hwe/j_vacation.php similarity index 71% rename from hwe/c_vacation.php rename to hwe/j_vacation.php index 8c498b0c..e90573e8 100644 --- a/hwe/c_vacation.php +++ b/hwe/j_vacation.php @@ -13,7 +13,10 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); $autorun_user = $gameStor->autorun_user; if($autorun_user['limit_minutes']??false){ //자동 턴인 경우에는 휴가 불가 - header('location:b_myPage.php', true, 303); + Json::die([ + 'result'=>false, + 'reason'=>'자동 턴인 경우에는 휴가 명령이 불가능합니다.' + ]); } $killturn = $gameStor->killturn; @@ -23,5 +26,8 @@ $db->update('general', [ ], 'owner=%i', $userID); -header('location:b_myPage.php', true, 303); +Json::die([ + 'result'=>true, + 'reason'=>'success' +]); diff --git a/hwe/js/myPage.js b/hwe/js/myPage.js index 75c6aa27..53242b91 100644 --- a/hwe/js/myPage.js +++ b/hwe/js/myPage.js @@ -82,4 +82,84 @@ jQuery(function($){ }) initCustomCSSForm(); + + + $('#die_immediately').click(function(){ + if(!confirm('정말로 삭제하시겠습니까?')){ + return false; + } + $.post({ + url:'j_die_immediately.php', + dataType:'json', + }).then(function(data){ + if(!data){ + return quickReject('실패했습니다.'); + } + if(!data.result){ + return quickReject(data.reason); + } + + location.replace('..'); + + }, errUnknown) + .fail(function(reason){ + alert(reason); + location.reload(); + }); + return false; + return false; + }); + + $('#vacation').click(function(){ + if(!confirm('휴가 기능을 신청할까요?')){ + return false; + } + $.post({ + url:'j_vacation.php', + dataType:'json', + }).then(function(data){ + if(!data){ + return quickReject('실패했습니다.'); + } + if(!data.result){ + return quickReject(data.reason); + } + + location.reload(); + + }, errUnknown) + .fail(function(reason){ + alert(reason); + location.reload(); + }); + return false; + return false; + }); + + $('#set_my_setting').click(function(){ + $.post({ + url:'j_set_my_setting.php', + dataType:'json', + data:{ + tnmt:$('.tnmt:checked').val(), + defence_train:$('#defence_train').val(), + } + }).then(function(data){ + if(!data){ + return quickReject('실패했습니다.'); + } + if(!data.result){ + return quickReject(data.reason); + } + + location.reload(); + + }, errUnknown) + .fail(function(reason){ + alert(reason); + location.reload(); + }); + return false; + return false; + }); }); \ No newline at end of file