From feee4b20220eb44d0571a3749dac8f59f05af448 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 18 Apr 2020 22:49:50 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 3 +++ hwe/func_gamerule.php | 6 +++--- hwe/func_history.php | 2 +- hwe/index.php | 16 +++++++-------- hwe/join_post.php | 2 +- hwe/js/install.js | 28 ++++++++++++++++++++++++++ hwe/sammo/Command/BaseCommand.php | 5 ++++- hwe/sammo/Command/General/che_귀환.php | 2 +- hwe/sammo/GameUnitConstBase.php | 2 +- hwe/sammo/General.php | 6 +++--- hwe/sammo/GeneralAI.php | 18 +++++++++-------- hwe/sammo/ResetHelper.php | 12 +++++++---- hwe/sammo/Scenario/NPC.php | 2 +- hwe/sql/schema.sql | 2 +- 14 files changed, 73 insertions(+), 33 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index 8f97606a..2016b8b2 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1982,6 +1982,9 @@ function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) { else if($baseDateTime instanceof \DateTime){ $baseDateTime = \DateTimeImmutable::createFromMutable($baseDateTime); } + else if($baseDateTime instanceof \DateTimeImmutable){ + //do Nothing + } else{ throw new MustNotBeReachedException(); } diff --git a/hwe/func_gamerule.php b/hwe/func_gamerule.php index e30667fe..247c3dfa 100644 --- a/hwe/func_gamerule.php +++ b/hwe/func_gamerule.php @@ -344,7 +344,7 @@ function preUpdateMonthly() { //계략, 전쟁표시 해제 $db->update('city', [ 'state'=>$db->sqleval(<<$db->sqleval('greatest(0, term - 1'), + 'term'=>$db->sqleval('greatest(0, term - 1)'), 'conflict'=>$db->sqleval('if(term = 0,%s,conflict)', '{}'), ], true); diff --git a/hwe/func_history.php b/hwe/func_history.php index 6674bf79..6c5be9bc 100644 --- a/hwe/func_history.php +++ b/hwe/func_history.php @@ -363,7 +363,7 @@ function getGeneralPublicRecordWithDate(int $year, int $month):array { ); if(!$texts){ - return "●{$month}월: 기록 없음"; + return ["●{$month}월: 기록 없음"]; } return $texts; } diff --git a/hwe/index.php b/hwe/index.php index fd3c85c0..f9de3d01 100644 --- a/hwe/index.php +++ b/hwe/index.php @@ -162,17 +162,17 @@ echo " "; -switch ($gameStor->tnmt_type) { -case 0: $str = "전력전"; break; -case 1: $str = "통솔전"; break; -case 2: $str = "일기토"; break; -case 3: $str = "설전"; break; -} -$str2 = getTournament($gameStor->tournament); -$str3 = getTournamentTime(); if ($gameStor->tournament == 0) { echo "현재 토너먼트 경기 없음"; } else { + switch ($gameStor->tnmt_type) { + case 0: $str = "전력전"; break; + case 1: $str = "통솔전"; break; + case 2: $str = "일기토"; break; + case 3: $str = "설전"; break; + } + $str2 = getTournament($gameStor->tournament); + $str3 = getTournamentTime(); echo "{$str} {$str2} {$str3}↑"; } diff --git a/hwe/join_post.php b/hwe/join_post.php index 7061fa6e..86bd486f 100644 --- a/hwe/join_post.php +++ b/hwe/join_post.php @@ -265,7 +265,7 @@ foreach(Util::range(GameConst::$maxTurn) as $turnIdx){ } $db->insert('general_turn', $turnRows); -foreach(General::RANK_COLUMN as $rankColumn){ +foreach(array_keys(General::RANK_COLUMN) as $rankColumn){ $db->insert('rank_data', [ 'general_id'=>$generalID, 'nation_id'=>0, diff --git a/hwe/js/install.js b/hwe/js/install.js index 10034b89..762017b7 100644 --- a/hwe/js/install.js +++ b/hwe/js/install.js @@ -105,6 +105,22 @@ function scenarioPreview(){ } function formSetup(){ + $.validator.addMethod("autorun_user", function(value,element){ + var parent = $(element).parent('.input-group'); + var checkCnt = parent.find('input:checked').length; + if(value <= 0){ + if(checkCnt > 0){ + return false; + } + return true; + } + + + if(checkCnt == 0){ + return false; + } + return true; + }, "유효 시간과 옵션은 동시에 설정해야합니다."); $('#game_form').validate({ rules:{ turnterm:"required", @@ -116,6 +132,7 @@ function formSetup(){ show_img_level:"required", tournament_trig:"required", join_mode:'required', + autorun_user_minutes:{required: true, autorun_user: true, min:0} }, errorElement: "div", errorPlacement: function ( error, element ) { @@ -140,6 +157,15 @@ function formSetup(){ if(!$("#game_form").valid()){ return; } + + var autorun_user_minutes = parseInt($('#autorun_user_minutes').val()); + var autorun_user = []; + if(autorun_user_minutes > 0){ + $('.autorun_user_chk:checked').each(function(){ + autorun_user.push($(this).data('key')); + }); + } + $.ajax({ cache:false, type:'post', @@ -157,6 +183,8 @@ function formSetup(){ reserve_open:$('#reserve_open').val(), pre_reserve_open:$('#pre_reserve_open').val(), join_mode:$('#join_mode input:radio:checked').val(), + autorun_user_minutes:autorun_user_minutes, + autorun_user:autorun_user } }).then(function(result){ var deferred = $.Deferred(); diff --git a/hwe/sammo/Command/BaseCommand.php b/hwe/sammo/Command/BaseCommand.php index 4a59586e..01a98e50 100644 --- a/hwe/sammo/Command/BaseCommand.php +++ b/hwe/sammo/Command/BaseCommand.php @@ -234,7 +234,10 @@ abstract class BaseCommand{ return static::getName(); } - public function getRawClassName():string{ + public function getRawClassName(bool $shortName=true):string{ + if($shortName){ + return Util::getClassNameFromObj($this); + } return static::class; } diff --git a/hwe/sammo/Command/General/che_귀환.php b/hwe/sammo/Command/General/che_귀환.php index f2cbdd70..41f63742 100644 --- a/hwe/sammo/Command/General/che_귀환.php +++ b/hwe/sammo/Command/General/che_귀환.php @@ -12,7 +12,7 @@ use \sammo\{ use function \sammo\{ - function getNationStaticInfo, + getNationStaticInfo, tryUniqueItemLottery }; diff --git a/hwe/sammo/GameUnitConstBase.php b/hwe/sammo/GameUnitConstBase.php index 341af7e5..4b482069 100644 --- a/hwe/sammo/GameUnitConstBase.php +++ b/hwe/sammo/GameUnitConstBase.php @@ -14,7 +14,7 @@ class GameUnitConstBase{ const T_SIEGE = 5; const T_MISC = 6; - const DEFAULT_CREWTYPE = 0; + const DEFAULT_CREWTYPE = 1100; diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 1d64170b..68217369 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -886,7 +886,7 @@ class General implements iAction{ ]; if($reqColumns === null){ - return [$fullColumn, static::RANK_COLUMN]; + return [$fullColumn, array_keys(static::RANK_COLUMN)]; } $rankColumn = []; @@ -933,14 +933,14 @@ class General implements iAction{ if($generalIDList === null){ $rawGenerals = Util::convertArrayToDict( - $db->queryFirstRow('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)), + $db->query('SELECT %l FROM general WHERE 1', Util::formatListOfBackticks($column)), 'no' ); $generalIDList = array_keys($rawGenerals); } else{ $rawGenerals = Util::convertArrayToDict( - $db->queryFirstRow('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList), + $db->query('SELECT %l FROM general WHERE no IN %li', Util::formatListOfBackticks($column), $generalIDList), 'no' ); } diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 0a52cc98..25b9abe5 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -109,6 +109,13 @@ class GeneralAI 'color' => '#000000', 'name' => '재야', ]; + + $serverPolicy = KVStorage::getStorage($db, 'autorun_nation_policy_0'); + $nationPolicy = KVStorage::getStorage($db, "autorun_nation_policy_{$this->nation['nation']}"); + + $this->nationPolicy = new AutorunNationPolicy($general, $nationPolicy->getAll(), $serverPolicy->getAll()); + $this->generalPolicy = new AutorunGeneralPolicy($general, $this->env['autorun_user']['options']??[]); + $this->nation['aux'] = Json::decode($this->nation['aux']??'{}'); $this->leadership = $general->getLeadership(); @@ -119,15 +126,10 @@ class GeneralAI $this->fullStrength = $general->getStrength(false); $this->fullIntel = $general->getIntel(false); - $this->genType = $this::calcGenType($general); + + $this->genType = $this->calcGenType($general); $this->calcDiplomacyState(); - - $serverPolicy = KVStorage::getStorage($db, 'autorun_nation_policy_0'); - $nationPolicy = KVStorage::getStorage($db, "autorun_nation_policy_{$this->nation['nation']}"); - - $this->nationPolicy = new AutorunNationPolicy($general, $nationPolicy->getAll(), $serverPolicy->getAll()); - $this->generalPolicy = new AutorunGeneralPolicy($general, $this->env['autorun_user']['options']??[]); } public function getGeneralObj(): General @@ -135,7 +137,7 @@ class GeneralAI return $this->general; } - protected static function calcGenType(General $general) + protected function calcGenType(General $general) { $leadership = $general->getLeadership(); $strength = Util::valueFit($general->getStrength(), 1); diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 384a15d4..8bf9f257 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -257,7 +257,8 @@ class ResetHelper{ 'fiction'=>$fiction, 'tnmt_trig'=>$tournament_trig, 'prev_winner'=>$prevWinner, - 'autorun_user'=>$autorun_user + 'autorun_user'=>$autorun_user, + 'tournament'=>0, ]; foreach(RootDB::db()->query('SELECT `no`, `name`, `picture`, `imgsvr` FROM member WHERE grade >= 5') as $admin){ @@ -283,14 +284,17 @@ class ResetHelper{ } $db->insert('general_turn', $turnRows); - foreach(General::RANK_COLUMN as $rankColumn){ - $db->insert('rank_data', [ + + $rank_data = []; + foreach(array_keys(General::RANK_COLUMN) as $rankColumn){ + $rank_data[] = [ 'general_id'=>$generalID, 'nation_id'=>0, 'type'=>$rankColumn, 'value'=>0 - ]); + ]; } + $db->insert('rank_data', $rank_data); } foreach($env as $key=>$value){ diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index f9efe569..8dbfceca 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -358,7 +358,7 @@ class NPC{ } $db->insert('general_turn', $turnRows); - foreach(\sammo\General::RANK_COLUMN as $rankColumn){ + foreach(array_keys(\sammo\General::RANK_COLUMN) as $rankColumn){ $db->insert('rank_data', [ 'general_id'=>$this->generalID, 'nation_id'=>0, diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index d928c635..b45a5f40 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -97,7 +97,7 @@ CREATE TABLE `general_turn` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `general_id` INT(11) NOT NULL, `turn_idx` INT(4) NOT NULL, - `action` VARCHAR(16) NOT NULL, + `action` VARCHAR(20) NOT NULL, `arg` TEXT NULL DEFAULT NULL, `brief` TEXT NULL DEFAULT NULL, PRIMARY KEY (`id`),