From 8be7a7e67d8badd4d9e9ca638a57fd797f375235 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 28 Oct 2018 03:32:03 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9E=9C=EB=8D=A4=20=EC=9E=84=EA=B4=80=20?= =?UTF-8?q?=EA=B9=83=EC=88=98=EC=9A=A9=20=EC=BD=94=EB=93=9C=20=EC=9D=B4?= =?UTF-8?q?=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 7 ++-- hwe/install.php | 14 ++++++++ hwe/j_autoreset.php | 3 +- hwe/j_install.php | 12 ++++--- hwe/j_server_basic_info.php | 17 ++++++++- hwe/js/install.js | 6 ++-- hwe/process_war.php | 7 ++-- hwe/processing.php | 69 +++++++++++++++++++++---------------- hwe/sammo/GameConstBase.php | 19 +++++----- hwe/sammo/ResetHelper.php | 6 +++- js/entrance.js | 2 +- src/sammo/TimeUtil.php | 27 ++++++++++++++- 12 files changed, 135 insertions(+), 54 deletions(-) diff --git a/hwe/func.php b/hwe/func.php index 65c58613..4938903d 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -435,7 +435,7 @@ function commandTable() { $connect=$db->get(); $userID = Session::getUserID(); - $admin = $gameStor->getValues(['startyear', 'year', 'month', 'develcost', 'scenario']); + $admin = $gameStor->getValues(['startyear', 'year', 'month', 'develcost', 'scenario', 'join_mode']); $query = "select no,npc,troop,city,nation,level,crew,makelimit,special from general where owner='{$userID}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -552,7 +552,10 @@ function commandTable() { addCommand("인재탐색(랜덤경험, 자금$develcost)", 29, 0); } - if($me['level'] >= 1 && $city['supply'] != 0) { + if($admin['join_mode'] == 'onlyRandom'){ + //do Nothing + } + else if($me['level'] >= 1 && $city['supply'] != 0) { addCommand("등용(자금{$develcost5}+장수가치)", 22); } else { addCommand("등용(자금{$develcost5}+장수가치)", 22, 0); diff --git a/hwe/install.php b/hwe/install.php index eb512bcb..4fcc5d39 100644 --- a/hwe/install.php +++ b/hwe/install.php @@ -152,6 +152,20 @@ if($session->userGrade < 5 && !$allowReset){ +
+ +
+
+ + +
+
+
+
diff --git a/hwe/j_autoreset.php b/hwe/j_autoreset.php index fb61cd17..33b4f9c0 100644 --- a/hwe/j_autoreset.php +++ b/hwe/j_autoreset.php @@ -87,7 +87,8 @@ $result = ResetHelper::buildScenario( $options['extend'], $options['npcmode'], $options['show_img_level'], - $options['tournament_trig'] + $options['tournament_trig'], + $options['join_mode'] ); $result['affected']=1; diff --git a/hwe/j_install.php b/hwe/j_install.php index f3b300d2..c4a753d5 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', [ @@ -51,8 +52,8 @@ $v->rule('required', [ 'extend', 'npcmode', 'show_img_level', - 'tournament_trig' -]); + 'tournament_trig', +])->rule('in', 'join_mode', ['onlyRandom', 'full']); if(!$v->validate()){ Json::die([ 'result'=>false, @@ -92,6 +93,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 +126,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 +146,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/j_server_basic_info.php b/hwe/j_server_basic_info.php index b65928ce..40a89e5f 100644 --- a/hwe/j_server_basic_info.php +++ b/hwe/j_server_basic_info.php @@ -32,6 +32,20 @@ if(file_exists(__dir__.'/.htaccess')){ $options = Json::decode($reserved['options']); + $otherTextInfo = []; + + if($options['join_mode'] == 'onlyRandom'){ + $otherTextInfo[] = '랜덤 임관 전용'; + } + + if(!$otherTextInfo){ + $otherTextInfo = '표준'; + } + else{ + $otherTextInfo = join(', ', $otherTextInfo); + } + + Json::die([ 'reserved'=>[ 'scenarioName'=>$options['scenarioName'], @@ -39,7 +53,8 @@ if(file_exists(__dir__.'/.htaccess')){ 'fictionMode'=>($options['fiction']?'가상':'사실'), 'npcMode'=>($options['npcmode']?'가능':'불가'), 'openDatetime'=>$reserved['date'], - 'gameConf'=>$options['gameConf'] + 'gameConf'=>$options['gameConf'], + 'otherTextInfo'=>$otherTextInfo ], 'game'=>null, 'me'=>null diff --git a/hwe/js/install.js b/hwe/js/install.js index 97989ff3..893ff3fc 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 input:radio:checked').val(), } }).then(function(result){ var deferred = $.Deferred(); diff --git a/hwe/process_war.php b/hwe/process_war.php index 6acf70f7..0196de92 100644 --- a/hwe/process_war.php +++ b/hwe/process_war.php @@ -30,7 +30,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); @@ -147,7 +147,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); } @@ -561,7 +562,7 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) { } //NPC인 경우 10% 확률로 임관(엔장, 인재, 의병) - if($gen['npc'] >= 2 && $gen['npc'] <= 8 && $gen['npc'] != 5 && rand() % 100 < 10) { + if($admin['join_mode'] != 'onlyRandom' && $gen['npc'] >= 2 && $gen['npc'] <= 8 && $gen['npc'] != 5 && Util::randBool(0.1)) { setGeneralCommand($gen['no'], [0], 'che_임관', ['destNationID'=>$nation['nation']]); } } diff --git a/hwe/processing.php b/hwe/processing.php index dc5af5af..edbe8317 100644 --- a/hwe/processing.php +++ b/hwe/processing.php @@ -188,7 +188,7 @@ function command_99($turn) { $me = MYDB_fetch_array($result); if($me['level'] >= 5) { - setNationCommand($me['nation'], $me['level'], [0], 'che_휴식'); + setNationCommand($me['nation'], $me['level'], range(0, $turn - 1), 'che_휴식'); } header('location:b_chiefcenter.php'); @@ -681,6 +681,9 @@ function command_25($turn, $command) { $connect=$db->get(); $userID = Session::getUserID(); + $gameStor->cacheValues(['year','startyear','month','join_mode']); + + $onlyRandom = $gameStor->join_mode == 'onlyRandom'; starter("임관"); $query = "select no,nations from general where owner='{$userID}'"; @@ -695,11 +698,30 @@ 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; + } + } +?> + 국가에 임관합니다.
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.
바로 군주의 위치로 이동합니다.
+ +랜덤 임관 대상 국가는 아래에서 확인할 수 있습니다.
+ 임관할 국가를 목록에서 선택하세요.
+ !!!는 방랑군을 포함한 랜덤임관입니다. 유니크를 기대하신다면!
???는 방랑군을 제외한 랜덤임관입니다. 유니크 혜택은 없습니다.
임관 금지이거나 초기 제한중인 국가는 붉은색 배경으로 표시됩니다.
@@ -707,37 +729,24 @@ function command_25($turn, $command) {
-"; - for($i=0; $i < count($turn); $i++) { - echo " - "; - } - - echo " -
"; +> + + > + + +Credit"; - /** @var string 사용중인 지도명 */ - public static $mapName = 'che'; - /** @var string 사용중인 유닛셋 */ + /** @var string 게임명 */ + public static $title = "삼국지 모의전투 PHP HiDCHe"; + /** @var string 코드 아래에 붙는 설명 코드 */ + public static $banner = "KOEI의 이미지를 사용, 응용하였습니다 / 제작 : HideD(hided62@gmail.com) / Credit"; + /** @var string 사용중인 지도명 */ + public static $mapName = 'che'; + /** @var string 사용중인 유닛셋 */ public static $unitSet = 'che'; /** @var int 내정시 최하 민심 설정*/ public static $develrate = 50; @@ -76,6 +76,9 @@ class GameConstBase /** @var int 최대 기술 레벨 */ public static $maxTechLevel = 12; + /** @var int 초기 제한시 장수 제한 */ + public static $initialNationGenLimitForRandInit = 3; + /** @var int 초기 제한시 장수 제한 */ public static $initialNationGenLimit = 10; @@ -93,7 +96,7 @@ class GameConstBase public static $maxNationTurn = 12; public static $statGradeLevel = 5; - + /** @var int 초반 제한 기간 */ public static $openingPartYear = 3; /** @var int 거병,임관 제한 기간 */ diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index a83e6156..2a410276 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -107,7 +107,8 @@ class ResetHelper{ int $extend, int $npcmode, int $show_img_level, - int $tournament_trig + int $tournament_trig, + string $join_mode ):array{ //FIXME: 분리할 것 if(120 % $turnterm != 0){ @@ -193,6 +194,8 @@ class ResetHelper{ 'startyear'=>$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, diff --git a/js/entrance.js b/js/entrance.js index edf266f9..7a369025 100644 --- a/js/entrance.js +++ b/js/entrance.js @@ -47,7 +47,7 @@ var serverReservedTemplate = "\ \ - 오픈 일시 : <%openDatetime%> -
\ <%scenarioName%> <%turnterm%>분 턴 서버
\ -(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>)\ +(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>), (기타 설정:<%otherTextInfo%>)\ "; $(function(){ diff --git a/src/sammo/TimeUtil.php b/src/sammo/TimeUtil.php index 0534563c..4e6ec94a 100644 --- a/src/sammo/TimeUtil.php +++ b/src/sammo/TimeUtil.php @@ -109,5 +109,30 @@ class TimeUtil return $seconds; } - + /** + * $baseYear, $baseMonth 부터 $afterMonth 개월 이내인지. $afterMonth 포함. + * + */ + public static function IsRangeMonth(int $baseYear, int $baseMonth, int $afterMonth, int $askYear, int $askMonth):bool{ + if($baseMonth < 1 || $baseMonth > 12){ + throw new \InvalidArgumentException('개월이 올바르지 않음'); + } + if($askMonth < 1 || $askMonth > 12){ + throw new \InvalidArgumentException('개월이 올바르지 않음'); + } + + $minMonth = $baseYear * 12 + $baseMonth; + if($afterMonth < 0){ + $maxMonth = $minMonth; + $minMonth = $maxMonth - $afterMonth; + } + + $maxMonth = $minMonth + $afterMonth; + $askMonth = $askYear * 12 + $askMonth; + if($askMonth < $minMonth || $maxMonth < $askMonth){ + return false; + } + return true; + } + }