diff --git a/hwe/func_command.php b/hwe/func_command.php index e6d4cd36..839478b7 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -74,6 +74,40 @@ function pullGeneralCommand(int $generalID, int $turnCnt=1){ ], 'general_id=%i ORDER BY turn_idx ASC', $generalID); } +function repeatGeneralCommand(int $generalId, int $turnCnt){ + if($turnCnt <= 0){ + return; + } + if($turnCnt >= GameConst::$maxTurn){ + return; + } + + $db = DB::db(); + + $reqTurn = $turnCnt; + if($turnCnt * 2 > GameConst::$maxTurn){ + $reqTurn = GameConst::$maxTurn - $turnCnt; + } + + $turnList = $db->query('SELECT turn_idx, `action`, arg, brief FROM general_turn WHERE general_id=%i AND turn_idx < %i', $generalId, $reqTurn); + foreach($turnList as $turnItem){ + $turnIdx = $turnItem['turn_idx']; + $nextTurnIdx = $turnIdx+$turnCnt; + $turnTarget = []; + while($nextTurnIdx < GameConst::$maxTurn){ + //NOTE: range(15, 24, 12) 가 PHP에선 에러다. 그러니 직접 짠다. + $turnTarget[] = $nextTurnIdx; + $nextTurnIdx += $turnCnt; + } + + $db->update('general_turn', [ + 'action'=>$turnItem['action'], + 'arg'=>$turnItem['arg'], + 'brief'=>$turnItem['brief'] + ], 'general_id=%i AND turn_idx IN %li', $generalId, $turnTarget); + } +} + function pushNationCommand(int $nationID, int $level, int $turnCnt=1){ if($nationID == 0){ return; diff --git a/hwe/j_turn.php b/hwe/j_turn.php index 86c415e9..e17443a6 100644 --- a/hwe/j_turn.php +++ b/hwe/j_turn.php @@ -11,6 +11,7 @@ $session = Session::requireGameLogin([])->setReadOnly(); $generalID = $session->generalID; $turnAmount = Util::getReq('amount', 'int'); +$isRepeat = Util::getReq('is_repeat', 'bool', false); if($turnAmount == null){ Json::die([ @@ -26,7 +27,13 @@ if(abs($turnAmount) >= GameConst::$maxTurn){ ]); } -pushGeneralCommand($generalID, $turnAmount); +if($isRepeat){ + repeatGeneralCommand($generalID, $turnAmount); +} +else{ + pushGeneralCommand($generalID, $turnAmount); +} + Json::die([ 'result'=>true, 'reason'=>'success', diff --git a/hwe/js/chiefCenter.js b/hwe/js/chiefCenter.js index fa2d3824..f5ab4cce 100644 --- a/hwe/js/chiefCenter.js +++ b/hwe/js/chiefCenter.js @@ -75,10 +75,9 @@ function reloadTable(){ var turnTimeObj = moment(chiefInfo.turnTime); var turnList = plateObj.turn; $.each(chiefInfo.turn, function(turnIdx, turnText){ - turnTimeObj = turnTimeObj.add(turnTerm, 'minute'); turnList[turnIdx].turnTime.text(turnTimeObj.format('hh:mm')); turnList[turnIdx].turnText.text(turnText); - + turnTimeObj = turnTimeObj.add(turnTerm, 'minute'); }); }); diff --git a/hwe/js/main.js b/hwe/js/main.js index 300a9e02..83a1a475 100644 --- a/hwe/js/main.js +++ b/hwe/js/main.js @@ -76,6 +76,22 @@ function pushTurn(pushAmount){ }, errUnknown); } +function repeatTurn(repeatAmount){ + $.post({ + url:'j_turn.php', + dataType:'json', + data:{ + amount:repeatAmount, + is_repeat:true + } + }).then(function(data){ + if(!data.result){ + alert(data.reason); + } + reloadCommandList(); + }, errUnknown); +} + $('#pullTurn').click(function(){ pushTurn(-parseInt($('#repeatAmount').val())); }); @@ -84,6 +100,10 @@ $('#pushTurn').click(function(){ pushTurn(parseInt($('#repeatAmount').val())); }); +$('#repeatTurn').click(function(){ + repeatTurn(parseInt($('#repeatAmount').val())); +}); + function reserveTurn(turnList, command){ console.log(turnList, command); diff --git a/hwe/sammo/Command/General/che_증여.php b/hwe/sammo/Command/General/che_증여.php index e07ab3f2..d8593224 100644 --- a/hwe/sammo/Command/General/che_증여.php +++ b/hwe/sammo/Command/General/che_증여.php @@ -184,28 +184,28 @@ class che_증여 extends Command\GeneralCommand{
arg === null){ + return false; + } //NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('isGold', $this->arg)){ return false; @@ -73,7 +76,7 @@ class che_몰수 extends Command\NationCommand{ $this->setCity(); $this->setNation(['gold', 'rice']); - $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation'], 1); + $destGeneral = General::createGeneralObjFromDB($this->arg['destGeneralID'], ['gold', 'rice', 'npc', 'nation', 'imgsvr', 'picture'], 1); $this->setDestGeneral($destGeneral); $relYear = $env['year'] - $env['startyear']; @@ -131,7 +134,12 @@ class che_몰수 extends Command\NationCommand{ $resName = $isGold?'금':'쌀'; $destGeneral = $this->destGeneralObj; - $amount = Util::valueFit($amount, 0, ($general->getVar($resKey)- $isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice)); + $amount = Util::valueFit( + $amount, + 0, + ($destGeneral->getVar($resKey) - + ($isGold?GameConst::$generalMinimumGold:GameConst::$generalMinimumRice)) + ); $amountText = number_format($amount, 0); if($destGeneral->getVar('npc') >= 2 && Util::randBool(0.01)){ @@ -144,12 +152,12 @@ class che_몰수 extends Command\NationCommand{ ]; $text = Util::choiceRandom($npcTexts); $src = new MessageTarget( - $general->getID(), - $general->getName(), + $destGeneral->getID(), + $destGeneral->getName(), $nationID, $nation['name'], $nation['color'], - GetImageURL($general->getVar('imgsvr'), $general->getVar('picture')) + GetImageURL($destGeneral->getVar('imgsvr'), $destGeneral->getVar('picture')) ); $msg = new Message( Message::MSGTYPE_PUBLIC, @@ -165,7 +173,7 @@ class che_몰수 extends Command\NationCommand{ $logger = $general->getLogger(); - $destGeneral->increaseVarWithLimit($resKey, -$amount); + $destGeneral->increaseVarWithLimit($resKey, -$amount, 0); $db->update('nation', [ $resKey=>$db->sqleval('%b + %i', $resKey, $amount) ], 'nation=%i', $nationID); @@ -228,7 +236,7 @@ class che_몰수 extends Command\NationCommand{

diff --git a/hwe/sammo/Command/Nation/che_발령.php b/hwe/sammo/Command/Nation/che_발령.php index 431d6ca1..0064c05f 100644 --- a/hwe/sammo/Command/Nation/che_발령.php +++ b/hwe/sammo/Command/Nation/che_발령.php @@ -26,6 +26,9 @@ class che_발령 extends Command\NationCommand{ static public $reqArg = true; protected function argTest():bool{ + if($this->arg === null){ + return false; + } //NOTE: 사망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('destGeneralID', $this->arg)){ return false; diff --git a/hwe/sammo/Command/Nation/che_불가침제의.php b/hwe/sammo/Command/Nation/che_불가침제의.php index 157760f5..0c626c4c 100644 --- a/hwe/sammo/Command/Nation/che_불가침제의.php +++ b/hwe/sammo/Command/Nation/che_불가침제의.php @@ -8,13 +8,17 @@ use \sammo\{ GameConst, LastTurn, GameUnitConst, - Command + Command, + MessageTarget, + DiplomaticMessage, + Message, }; use function \sammo\{ getDomesticExpLevelBonus, CriticalRatioDomestic, - CriticalScoreEx + CriticalScoreEx, + GetImageURL }; use \sammo\Constraint\Constraint; @@ -25,6 +29,9 @@ class che_불가침제의 extends Command\NationCommand{ static public $reqArg = true; protected function argTest():bool{ + if($this->arg === null){ + return false; + } //NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('destNationID', $this->arg)){ return false; diff --git a/hwe/sammo/Command/Nation/che_선전포고.php b/hwe/sammo/Command/Nation/che_선전포고.php index 6188df69..305f0e59 100644 --- a/hwe/sammo/Command/Nation/che_선전포고.php +++ b/hwe/sammo/Command/Nation/che_선전포고.php @@ -27,6 +27,9 @@ class che_선전포고 extends Command\NationCommand{ static public $reqArg = true; protected function argTest():bool{ + if($this->arg === null){ + return false; + } //NOTE: 멸망 직전에 턴을 넣을 수 있으므로, 존재하지 않는 국가여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('destNationID', $this->arg)){ return false; diff --git a/hwe/sammo/Command/Nation/che_포상.php b/hwe/sammo/Command/Nation/che_포상.php index c2a9ee21..aa0a365e 100644 --- a/hwe/sammo/Command/Nation/che_포상.php +++ b/hwe/sammo/Command/Nation/che_포상.php @@ -25,6 +25,9 @@ class che_포상 extends Command\NationCommand{ static public $reqArg = true; protected function argTest():bool{ + if($this->arg === null){ + return false; + } //NOTE: 사망 직전에 '포상' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음 if(!key_exists('isGold', $this->arg)){ return false; @@ -201,7 +204,7 @@ class che_포상 extends Command\NationCommand{

diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 322cbad2..bb85f264 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -765,7 +765,7 @@ class GeneralAI{ } if($compNpcWar && $compNpcWar->$resName < 21000){ - $amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10); + $amount = min(100, intdiv(($nation[$resName]-($resName=='rice'?(GameConst::$baserice):(GameConst::$basegold))), 5000)*10 + 10)*100; $commandList[] = [['che_몰수', [ 'destGeneralID'=>$compNpcWar->no, 'isGold'=>$resName=='gold',