From da205c09f94fbad37c2cb5961efba299598c30be Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 6 Oct 2019 22:39:13 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=BB=A4=EB=A7=A8?= =?UTF-8?q?=EB=93=9C=20=EC=9E=85=EB=A0=A5=20=EA=B0=80=EB=8A=A5=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 3 +- hwe/func_command.php | 63 +++++++++++++++------- hwe/index.php | 22 ++++++-- hwe/j_reserve_command.php | 3 -- hwe/j_set_general_command.php | 34 ++++++------ hwe/j_turn.php | 26 ++++++++- hwe/js/main.js | 63 +++++++++++++++++++--- hwe/sammo/Command/BaseCommand.php | 1 - hwe/sammo/Command/General/che_상업투자.php | 7 +++ hwe/sammo/Command/General/che_정착장려.php | 6 +++ hwe/sammo/Command/General/che_주민선정.php | 6 +++ hwe/sammo/Command/General/che_첩보.php | 2 +- hwe/sammo/GameConstBase.php | 2 +- 13 files changed, 183 insertions(+), 55 deletions(-) delete mode 100644 hwe/j_reserve_command.php diff --git a/hwe/func.php b/hwe/func.php index a3d9d3e3..b9f916b1 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -430,6 +430,7 @@ function printCommandTable(General $generalObj) { + ;color:white;width:80px;font-size:13px; value='▼미루기' onclick='refreshing(this, 2,1)'>;color:white;width:80px;font-size:13px; value='▲당기기' onclick='refreshing(this, 2,2)'> - + - +
- ;color:white;width:110px;font-size:13px; value='실 행' onclick='refreshing(this, 3,form2)'>;color:white;width:110px;font-size:13px; value='갱 신'>;color:white;width:160px;font-size:13px; value='로비로' onclick="location.replace('../')">
+ ;color:white;width:160px;font-size:13px; + > diff --git a/hwe/j_reserve_command.php b/hwe/j_reserve_command.php deleted file mode 100644 index 1e17a6cd..00000000 --- a/hwe/j_reserve_command.php +++ /dev/null @@ -1,3 +0,0 @@ -setReadOnly(); $generalID = $session->generalID; - $action = Util::getReq('action', 'string'); $arg = Json::decode(Util::getReq('arg', 'string')); -$turnList = Json::decode(Util::getReq('turnList', 'string')); +$turnList = Util::getReq('turnList', 'array_int'); if(!is_array($turnList) || !$turnList){ Json::die([ 'result'=>false, - 'reason'=>'턴이 입력되지 않았습니다.' + 'reason'=>'턴이 입력되지 않았습니다.', + 'test'=>'post' ]); } if(!$action){ Json::die([ 'result'=>false, - 'reason'=>'action이 입력되지 않았습니다.' + 'reason'=>'action이 입력되지 않았습니다.', + 'test'=>'post' ]); } -if($arg === null || !is_array($arg)){ +if(!in_array($action, Util::array_flatten(GameConst::$availableGeneralCommand))){ Json::die([ 'result'=>false, - 'reason'=>'올바른 arg 형태가 아닙니다.' + 'reason'=>'사용할 수 없는 커맨드입니다.', + 'test'=>'post' ]); } -$result = setGeneralCommand($generalID, $turnList, $action, $arg); -if(!key_exists('result', $result)){ - $result['result'] = false; +if($arg === null){ + $arg = []; } -if(!key_exists('arg_test', $result)){ - $result['arg_test'] = false; + +if(!is_array($arg)){ + Json::die([ + 'result'=>false, + 'reason'=>'올바른 arg 형태가 아닙니다.', + 'test'=>'post' + ]); } -if(!key_exists('reason', $result)){ - throw new MustNotBeReachedException('reason이 왜 없어?'); -} -Json::die($result); \ No newline at end of file + +Json::die(setGeneralCommand($generalID, $turnList, $action, $arg)); \ No newline at end of file diff --git a/hwe/j_turn.php b/hwe/j_turn.php index 4a72aa63..86c415e9 100644 --- a/hwe/j_turn.php +++ b/hwe/j_turn.php @@ -6,4 +6,28 @@ include "func.php"; -$session = Session::requireGameLogin([])->setReadOnly(); \ No newline at end of file +$session = Session::requireGameLogin([])->setReadOnly(); + +$generalID = $session->generalID; + +$turnAmount = Util::getReq('amount', 'int'); + +if($turnAmount == null){ + Json::die([ + 'result'=>false, + 'reason'=>'턴이 입력되지 않았습니다.', + ]); +} + +if(abs($turnAmount) >= GameConst::$maxTurn){ + Json::die([ + 'result'=>false, + 'reason'=>'턴 숫자가 올바르지 않습니다.', + ]); +} + +pushGeneralCommand($generalID, $turnAmount); +Json::die([ + 'result'=>true, + 'reason'=>'success', +]); \ No newline at end of file diff --git a/hwe/js/main.js b/hwe/js/main.js index c97d9544..27753056 100644 --- a/hwe/js/main.js +++ b/hwe/js/main.js @@ -1,6 +1,6 @@ jQuery(function($){ -$('#do_refresh').click(function(){ +$('#refreshPage').click(function(){ document.location.reload(); return false; }); @@ -56,18 +56,65 @@ function myclock() { return; } - /* - if(!$clock.attr('data-time-diff')){ - var base_clock = moment($clock.attr('data-server-time')); - $clock.attr('data-time-diff', base_clock.diff(now_clock)); - } - */ - var game_clock = now_clock.add(parseInt($clock.data('time-diff')), 'milliseconds'); $('#clock').val(game_clock.format('YYYY-MM-DD HH:mm:ss')); } +function pushTurn(pushAmount){ + $.post({ + url:'j_turn.php', + dataType:'json', + data:{ + amount:pushAmount + } + }).then(function(data){ + if(!data.result){ + alert(data.reason); + } + reloadCommandList(); + }, errUnknown); +} + +$('#pullTurn').click(function(){ + pushTurn(-parseInt($('#repeatAmount').val())); +}); + +$('#pushTurn').click(function(){ + pushTurn(parseInt($('#repeatAmount').val())); +}); + + +function reserveTurn(turnList, command){ + console.log(turnList, command); + $.post({ + url:'j_set_general_command.php', + dataType:'json', + data:{ + action:command, + turnList:turnList + } + }).then(function(data){ + if(!data.result){ + alert(data.reason); + } + reloadCommandList(); + }, errUnknown); +} + +$('#reserveTurn').click(function(){ + var turnList = $('#generalTurnSelector').val().map(function(v){return parseInt(v);}); + var $command = $('#generalCommandList option:selected'); + /*if($command.data('reqarg')){ + alert('TODO!'); + } + else*/{ + reserveTurn(turnList, $command.val()); + } + +}) + + setInterval(myclock, 500); reloadCommandList(); }); \ No newline at end of file diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 66bad84b..83cbdfeb 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -224,7 +224,6 @@ abstract class BaseCommand{ //0 : Neutral //-1 : Negative //null : can't calculate - //TODO: 구현 return 0; } diff --git a/hwe/sammo/Command/General/che_상업투자.php b/hwe/sammo/Command/General/che_상업투자.php index 8f7f1363..86432aca 100644 --- a/hwe/sammo/Command/General/che_상업투자.php +++ b/hwe/sammo/Command/General/che_상업투자.php @@ -84,6 +84,13 @@ class che_상업투자 extends Command\GeneralCommand{ return [$reqGold, $reqRice]; } + + + public function getCompensationStyle():?int{ + $develCost = $this->env['develcost']; + $reqGold = $this->getCost()[0]; + return $develCost <=>$reqGold; + } public function getPreReqTurn():int{ return 0; diff --git a/hwe/sammo/Command/General/che_정착장려.php b/hwe/sammo/Command/General/che_정착장려.php index 75afcf9d..abcc730a 100644 --- a/hwe/sammo/Command/General/che_정착장려.php +++ b/hwe/sammo/Command/General/che_정착장려.php @@ -62,6 +62,12 @@ class che_정착장려 extends Command\GeneralCommand{ return [$reqGold, $reqRice]; } + + public function getCompensationStyle():?int{ + $develCost = $this->env['develcost'] * 2; + $reqGold = $this->getCost()[1]; + return $develCost <=>$reqGold; + } public function getPreReqTurn():int{ return 0; diff --git a/hwe/sammo/Command/General/che_주민선정.php b/hwe/sammo/Command/General/che_주민선정.php index 03e00ab9..25dec0c5 100644 --- a/hwe/sammo/Command/General/che_주민선정.php +++ b/hwe/sammo/Command/General/che_주민선정.php @@ -62,6 +62,12 @@ class che_주민선정 extends Command\GeneralCommand{ return [$reqGold, $reqRice]; } + + public function getCompensationStyle():?int{ + $develCost = $this->env['develcost'] * 2; + $reqGold = $this->getCost()[1]; + return $develCost <=>$reqGold; + } public function getPreReqTurn():int{ return 0; diff --git a/hwe/sammo/Command/General/che_첩보.php b/hwe/sammo/Command/General/che_첩보.php index 1669bd08..dc90e0b4 100644 --- a/hwe/sammo/Command/General/che_첩보.php +++ b/hwe/sammo/Command/General/che_첩보.php @@ -63,7 +63,7 @@ class che_첩보 extends Command\GeneralCommand{ public function getCost():array{ $env = $this->env; - return [$env['develcost'], 0]; + return [$env['develcost'], $env['develcost']]; } public function getPreReqTurn():int{ diff --git a/hwe/sammo/GameConstBase.php b/hwe/sammo/GameConstBase.php index 72e74276..5a722f08 100644 --- a/hwe/sammo/GameConstBase.php +++ b/hwe/sammo/GameConstBase.php @@ -196,7 +196,7 @@ class GameConstBase ] ]; - /** @var array[string] 선택 가능한 커맨드 */ + /** @var array 선택 가능한 커맨드 */ public static $availableGeneralCommand = [ ''=>[ '휴식',