From 01fcc9bcab80736e08582dd0fa6d4ac5c1810624 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 23 Oct 2018 15:05:19 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9E=9C=EB=8D=A4=20=EC=9E=84=EA=B4=80=20?= =?UTF-8?q?=EB=AA=A8=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_command.php | 17 +++++++--- hwe/func_process_personnel.php | 22 ++++++++++-- hwe/install.php | 14 ++++++++ hwe/j_install.php | 13 +++++--- hwe/js/install.js | 6 ++-- hwe/process_war.php | 7 ++-- hwe/processing.php | 61 ++++++++++++++++++---------------- hwe/sammo/GameConstBase.php | 3 ++ hwe/sammo/ResetHelper.php | 6 +++- 9 files changed, 104 insertions(+), 45 deletions(-) diff --git a/hwe/func_command.php b/hwe/func_command.php index 46465e58..f6f3be0a 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -105,12 +105,19 @@ function getTurn(array $general, $type, $font=1) { case 25: //임관 $double = $command[1]; - $nation = getNationStaticInfo($double); + if($double == 98){ + $nationName = '(랜덤국가)'; + } + else if($double == 99){ + $nationName = '[랜덤국가]'; + } + else{ + $nationName = getNationStaticInfo($double)['name']??'?!?!'; + } + - if(!$nation['name']) { $nation['name'] = '????'; } - - $josaRo = JosaUtil::pick($nation['name'], '로'); - $str[$i] = "【{$nation['name']}】{$josaRo} 임관"; + $josaRo = JosaUtil::pick($nationName, '로'); + $str[$i] = "【{$nationName}】{$josaRo} 임관"; break; case 26: //집합 $str[$i] = "집합"; diff --git a/hwe/func_process_personnel.php b/hwe/func_process_personnel.php index 9d58ef53..c4f651ad 100644 --- a/hwe/func_process_personnel.php +++ b/hwe/func_process_personnel.php @@ -70,7 +70,7 @@ function process_25(&$general) { $history = []; $date = substr($general['turntime'],11,5); - $admin = $gameStor->getValues(['startyear', 'year', 'month', 'scenario', 'fiction']); + $admin = $gameStor->getValues(['startyear', 'year', 'month', 'scenario', 'fiction', 'join_mode', 'init_year', 'init_month']); $query = "select nation from city where city='{$general['city']}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -79,6 +79,10 @@ function process_25(&$general) { $command = DecodeCommand($general['turn0']); $where = $command[1]; + if($admin['join_mode'] == 'onlyRandom' && $where < 98){ + $where = 99; + } + $nation = null; $joinedNations = Json::decode($general['nations']); @@ -126,10 +130,18 @@ function process_25(&$general) { $allGen = array_sum($generals); + $genLimit = GameConst::$defaultMaxGeneral; + if($admin['join_mode'] == 'randomOnly' && $admin['init_year'] == $admin['year'] && $admin['init_month'] + 1 <= $admin['month']){ + $genLimit = GameConst::$initialNationGenLimitForRandInit; + } + else if($admin['year'] < $admin['startyear'] + 3){ + $genLimit = GameConst::$initialNationGenLimit; + } + $nations = $db->query( 'SELECT nation.`name` as `name`,nation.nation as nation,scout,nation.`level` as `level`,gennum,`injury` FROM nation join general on general.nation = nation.nation and general.level = 12 WHERE nation.nation not in %li and gennum < %i and scout = 0', $joinedNations, - ($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral + $genLimit ); shuffle($nations); @@ -164,6 +176,12 @@ function process_25(&$general) { if(!$nation) { $log[] = "●{$admin['month']}월:임관할 국가가 없습니다. 임관 실패. <1>$date"; + if($where >= 98 && $genLimit == GameConst::$initialNationGenLimitForRandInit){ + //랜덤 모드, 초기화시에는 랜덤 임관을 대신 한턴 더 넣어준다. + $db->update('general', [ + 'turn1'=>EncodeCommand(0, 0, $where, 25), + ], '`no` = %i', $general['no']); + } } elseif($general['nation'] != 0) { $log[] = "●{$admin['month']}월:재야가 아닙니다. 임관 실패. <1>$date"; } elseif($nation['nation'] == 0) { diff --git a/hwe/install.php b/hwe/install.php index eb512bcb..82ea81e4 100644 --- a/hwe/install.php +++ b/hwe/install.php @@ -152,6 +152,20 @@ if($session->userGrade < 5 && !$allowReset){ +
+ +
+
+ + +
+
+
+
diff --git a/hwe/j_install.php b/hwe/j_install.php index f3b300d2..02c2b4c9 100644 --- a/hwe/j_install.php +++ b/hwe/j_install.php @@ -41,6 +41,7 @@ $v->rule('required', [ 'scenario', 'fiction', 'extend', + 'join_mode', 'npcmode', 'show_img_level' ])->rule('integer', [ @@ -49,10 +50,11 @@ $v->rule('required', [ 'scenario', 'fiction', 'extend', + 'join_mode', 'npcmode', 'show_img_level', - 'tournament_trig' -]); + 'tournament_trig', +])->rule('in', 'join_mode', ['onlyRandom', 'full']); if(!$v->validate()){ Json::die([ 'result'=>false, @@ -92,6 +94,7 @@ $extend = (int)$_POST['extend']; $npcmode = (int)$_POST['npcmode']; $show_img_level = (int)$_POST['show_img_level']; $tournament_trig = (int)$_POST['tournament_trig']; +$join_mode = $_POST['join_mode']; if($reserve_open){ $reserve_open = new \DateTime($reserve_open); @@ -124,7 +127,8 @@ if($reserve_open){ 'npcmode'=>$npcmode, 'show_img_level'=>$show_img_level, 'tournament_trig'=>$tournament_trig, - 'gameConf'=>$scenarioObj->getGameConf() + 'gameConf'=>$scenarioObj->getGameConf(), + 'join_mode'=>$join_mode, ]), 'date'=>$reserve_open->format('Y-m-d H:i:s') ]); @@ -143,5 +147,6 @@ Json::die(ResetHelper::buildScenario( $extend, $npcmode, $show_img_level, - $tournament_trig + $tournament_trig, + $join_mode )); \ No newline at end of file diff --git a/hwe/js/install.js b/hwe/js/install.js index 97989ff3..4fa6c91d 100644 --- a/hwe/js/install.js +++ b/hwe/js/install.js @@ -114,7 +114,8 @@ function formSetup(){ extend:"required", npcmode:"required", show_img_level:"required", - tournament_trig:"required" + tournament_trig:"required", + join_mode:'required', }, errorElement: "div", errorPlacement: function ( error, element ) { @@ -153,7 +154,8 @@ function formSetup(){ npcmode:$('#npcmode input:radio:checked').val(), show_img_level:$('#show_img_level input:radio:checked').val(), tournament_trig:$('#tournament_trig input:radio:checked').val(), - reserve_open:$('#reserve_open').val() + reserve_open:$('#reserve_open').val(), + join_mode:$('#join_mode').val(), } }).then(function(result){ var deferred = $.Deferred(); diff --git a/hwe/process_war.php b/hwe/process_war.php index 4185b531..4cdc9dff 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -31,7 +31,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ } $gameStor = KVStorage::getStorage($db, 'game_env'); - [$startYear, $year, $month, $cityRate] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'city_rate']); + [$startYear, $year, $month, $cityRate, $joinMode] = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'city_rate', 'join_mode']); $attacker = new WarUnitGeneral($rawAttacker, $rawAttackerCity, $rawAttackerNation, true, $year, $month); @@ -154,7 +154,8 @@ function processWar(array $rawAttacker, array $rawDefenderCity){ 'startyear'=>$startYear, 'year'=>$year, 'month'=>$month, - 'city_rate'=>$cityRate + 'city_rate'=>$cityRate, + 'join_mode'=>$joinMode, ], $attacker->getRaw(), $city->getRaw(), $rawAttackerNation, $rawDefenderNation); } @@ -568,7 +569,7 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) { } //NPC인 경우 10% 확률로 임관(엔장, 인재, 의병) - if($gen['npc'] >= 2 && $gen['npc'] <= 8 && rand() % 100 < 10) { + if($admin['join_mode'] != 'randomOnly' && $gen['npc'] >= 2 && $gen['npc'] <= 8 && rand() % 100 < 10) { $commissionCommand = EncodeCommand(0, 0, $nation['nation'], 25); //임관 $query = "update general set turn0='$commissionCommand' where no={$gen['no']}"; MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); diff --git a/hwe/processing.php b/hwe/processing.php index ddcb627f..65593d75 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -686,6 +686,9 @@ function command_25($turn, $command) { $connect=$db->get(); $userID = Session::getUserID(); + $gameStor->cacheValues(['year','startyear','month','join_mode']); + + $randomOnly = $gameStor->join_mode == 'randomOnly'; starter("임관"); $query = "select no,nations from general where owner='{$userID}'"; @@ -700,7 +703,22 @@ function command_25($turn, $command) { $nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg,gennum FROM nation ORDER BY rand()'); - echo " + foreach($nationList as $nation){ + if ($gameStor->year == $gameStor->init_year && $gameStor->month <= $gameStor->init_month && $nation['gennum'] >= GameConst::$initialNationGenLimitForRandInit) { + $nation['availableJoin'] = false; + } + else if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit){ + $nation['availableJoin'] = false; + } + else if($nation['scout'] == 1) { + $nation['availableJoin'] = false; + } + else{ + $nation['availableJoin'] = true; + } + } +?> + 국가에 임관합니다.
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.
바로 군주의 위치로 이동합니다.
@@ -712,37 +730,24 @@ function command_25($turn, $command) {
"; - for($i=0; $i < count($turn); $i++) { - echo " - "; - } - - echo " -
"; + + > + + +$startyear, 'year'=> $year, 'month'=> $month, + 'init_year'=> $year, + 'init_month'=>$month, 'map_theme' => $scenarioObj->getMapTheme(), 'msg'=>'공지사항',//TODO:공지사항 'maxgeneral'=>GameConst::$defaultMaxGeneral, @@ -207,6 +210,7 @@ class ResetHelper{ 'killturn'=>$killturn, 'genius'=>GameConst::$defaultMaxGenius, 'show_img_level'=>$show_img_level, + 'join_mode'=>$join_mode, 'npcmode'=>$npcmode, 'extended_general'=>$extend, 'fiction'=>$fiction,