diff --git a/hwe/b_chiefcenter.php b/hwe/b_chiefcenter.php index effafa6e..2febd89e 100644 --- a/hwe/b_chiefcenter.php +++ b/hwe/b_chiefcenter.php @@ -6,7 +6,7 @@ include "func.php"; //로그인 검사 $session = Session::requireGameLogin()->setReadOnly(); $userID = Session::getUserID(); - +$generalObj = General::createGeneralObjFromDB($session->generalID); ?> @@ -17,6 +17,7 @@ $userID = Session::getUserID(); <?=UniqueConst::$serverName?>: 사령부 + @@ -47,8 +48,8 @@ var maxChiefTurn = ; >
- :  
>
 
 
 
 
>; >
; >
- :  
>
 
 
 
 
>turnOnCache(); + $env = $gameStor->getAll(); + +?> + +queryAllLists( - 'SELECT level, turn_idx, action, arg FROM nation_turn WHERE nation_id = %i ORDER BY level DESC, turn_idx ASC', + 'SELECT level, turn_idx, action, arg, brief FROM nation_turn WHERE nation_id = %i ORDER BY level DESC, turn_idx ASC', $me['nation'] - ) as [$level, $turn_idx, $action, $arg] + ) as [$level, $turn_idx, $action, $arg, $brief] ){ if(!key_exists($level, $nationTurnList)){ $nationTurnList[$level] = []; } - $nationTurnList[$level][$turn_idx] = [$action, Json::decode($arg)]; + $nationTurnList[$level][$turn_idx] = $brief; } $nationTurnBrief = []; -foreach($nationTurnList as $level=>$turnList){ +foreach($nationTurnList as $level=>$turnBrief){ if(!key_exists($level, $generals)){ $general = Util::array_first($generals); } @@ -80,7 +80,7 @@ foreach($nationTurnList as $level=>$turnList){ 'turnTime'=>$general->getTurnTime($general::TURNTIME_FULL), 'levelText'=>getLevelText($general->getVar('level'), $nationLevel), 'npcType'=>$general->getVar('npc'), - 'turn'=>getNationTurnBrief($general, $turnList) + 'turn'=>$turnBrief ]; } diff --git a/hwe/j_set_nation_command.php b/hwe/j_set_chief_command.php similarity index 58% rename from hwe/j_set_nation_command.php rename to hwe/j_set_chief_command.php index 56175f3e..f35efa56 100644 --- a/hwe/j_set_nation_command.php +++ b/hwe/j_set_chief_command.php @@ -11,26 +11,41 @@ $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::$availableChiefCommand))){ Json::die([ 'result'=>false, - 'reason'=>'올바른 arg 형태가 아닙니다.' + 'reason'=>'사용할 수 없는 커맨드입니다.', + 'test'=>'post' + ]); +} + +if($arg === null){ + $arg = []; +} + +if(!is_array($arg)){ + Json::die([ + 'result'=>false, + 'reason'=>'올바른 arg 형태가 아닙니다.', + 'test'=>'post' ]); } diff --git a/hwe/j_set_general_command.php b/hwe/j_set_general_command.php index d1af431f..4776028b 100644 --- a/hwe/j_set_general_command.php +++ b/hwe/j_set_general_command.php @@ -16,7 +16,7 @@ if(!is_array($turnList) || !$turnList){ Json::die([ 'result'=>false, 'reason'=>'턴이 입력되지 않았습니다.', - 'test'=>'post' + 'test'=>'post', ]); } diff --git a/hwe/js/chiefCenter.js b/hwe/js/chiefCenter.js index 35fe013a..fa2d3824 100644 --- a/hwe/js/chiefCenter.js +++ b/hwe/js/chiefCenter.js @@ -94,9 +94,43 @@ function reloadTable(){ }, errUnknown); } +function reserveTurn(turnList, command){ + console.log(turnList, command); + $.post({ + url:'j_set_chief_command.php', + dataType:'json', + data:{ + action:command, + turnList:turnList + } + }).then(function(data){ + if(!data.result){ + alert(data.reason); + } + reloadTable(); + }, errUnknown); +} jQuery(function($){ - chiefTableObj= genChiefTableObj(); - $('#reloadTable').click(reloadTable); - reloadTable(); + +chiefTableObj= genChiefTableObj(); +reloadTable(); +$('#reloadTable').click(reloadTable); +$('#setCommand').click(function(){ + var turnList = $('#chiefTurnSelector').val().map(function(v){return parseInt(v);}); + var $command = $('#chiefCommandList option:selected'); + if($command.data('reqarg')){ + $.redirect( + "b_processing.php", { + command: $command.val(), + turnList: turnList.join('_'), + is_chief: true + }, "GET"); + } + else{ + reserveTurn(turnList, $command.val()); + } + return false; +}); + }) \ No newline at end of file diff --git a/hwe/js/processing.js b/hwe/js/processing.js index 76bbbb9a..8179d352 100644 --- a/hwe/js/processing.js +++ b/hwe/js/processing.js @@ -1,6 +1,13 @@ function reserveTurn(turnList, command, arg){ + var target; + if(isChiefTurn){ + target = 'j_set_chief_command.php'; + } + else{ + target = 'j_set_general_command.php'; + } $.post({ - url:'j_set_general_command.php', + url:target, dataType:'json', data:{ action:command, @@ -35,8 +42,7 @@ window.submitAction = function(){ 'int':[ 'crewType', 'destGeneralID', 'destCityID', 'destNationID', 'amount', 'colorType', - 'month', - 'year', 'destGeneralID', 'destCityID', 'destNationID', 'amount', 'crewType', + 'year', 'month', ], 'boolean':[ 'isGold', 'buyRice', diff --git a/hwe/sammo/Command/Nation/che_몰수.php b/hwe/sammo/Command/Nation/che_몰수.php index ba8692db..e81ba97a 100644 --- a/hwe/sammo/Command/Nation/che_몰수.php +++ b/hwe/sammo/Command/Nation/che_몰수.php @@ -101,6 +101,16 @@ class che_몰수 extends Command\NationCommand{ return 0; } + public function getBrief():string{ + $isGold = $this->arg['isGold']; + $amount = $this->arg['amount']; + $amountText = number_format($amount, 0); + $resName = $isGold?'금':'쌀'; + $destGeneral = $this->destGeneralObj; + $commandName = $this->getName(); + return "【{$destGeneral->getName()}】 {$resName} $amountText {$commandName}"; + } + public function run():bool{ if(!$this->isRunnable()){ @@ -174,14 +184,9 @@ class che_몰수 extends Command\NationCommand{ { //TODO: 암행부처럼 보여야... $db = DB::db(); - $form = []; - $form[] = << -몰수한것은 국가재산으로 귀속됩니다.
- + + + - -EOT; - return join("\n",$form); + + + +
+
+getName(); + $destGeneralName = $this->destGeneralObj->getName(); + $destCityName = CityConst::byID($this->arg['destCityID'])->name; + $josaRo = JosaUtil::pick($destCityName, '로'); + return "【{$destGeneralName}】【{$destCityName}】{$josaRo} {$commandName}"; + } + public function run():bool{ if(!$this->isRunnable()){ @@ -138,18 +146,10 @@ class che_발령 extends Command\NationCommand{ public function getForm(): string { - $form = []; - $form[] = \sammo\getMapHtml(); - $db = DB::db(); - $form[] = << -아국 도시로만 발령이 가능합니다.
-목록을 선택하거나 도시를 클릭하세요.
- + + + '; - $form[] = ''; - - return join("\n",$form); +
+
+
+arg['isGold']; + $amount = $this->arg['amount']; + $amountText = number_format($amount, 0); + $resName = $isGold?'금':'쌀'; + $destGeneral = $this->destGeneralObj; + $commandName = $this->getName(); + return "【{$destGeneral->getName()}】 {$resName} $amountText {$commandName}"; + } + public function run():bool{ if(!$this->isRunnable()){ @@ -148,13 +158,9 @@ class che_포상 extends Command\NationCommand{ { //TODO: 암행부처럼 보여야... $db = DB::db(); - $form = []; - $form[] = << -EOT; $destRawGenerals = $db->query('SELECT no,name,level,npc,gold,rice FROM general WHERE nation = %i AND no != %i ORDER BY npc,binary(name)',$this->generalObj->getNationID(), $this->generalObj->getID()); + $destGeneralList = []; foreach($destRawGenerals as $destGeneral){ $nameColor = \sammo\getNameColor($destGeneral['npc']); if($nameColor){ @@ -166,9 +172,27 @@ EOT; $name = "*{$name}*"; } - $form[] = ""; + $destGeneralList[] = [ + 'no'=>$destGeneral['no'], + 'color'=>$nameColor, + 'name'=>$name, + 'gold'=>$destGeneral['gold'], + 'rice'=>$destGeneral['rice'] + ]; } - $form[] = << +국고로 장수에게 자금이나 군량을 지급합니다.
+ - -EOT; - return join("\n",$form); + + + +
+
+