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) {
";
+
>
+
+
>
+
+
+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;
+ }
+
}