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?>: 내정보
+
=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
=WebUtil::printJS('js/common.js')?>
@@ -112,21 +55,6 @@ if($gameStor->turntime <= $gameStor->opentime){
=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
=WebUtil::printCSS('../d_shared/common.css')?>
=WebUtil::printCSS('css/common.css')?>
-
@@ -140,13 +68,12 @@ $('#die_immediately').click(function(){
-
autorun_user['limit_minutes']??false)): ?>
휴 가 신 청
-
+
- 가오픈 기간 내 장수 삭제
+ 가오픈 기간 내 장수 삭제 (=substr($targetTime, 0, 19)?> 부터)
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
|