랜덤 임관 모드 추가
This commit is contained in:
+12
-5
@@ -105,12 +105,19 @@ function getTurn(array $general, $type, $font=1) {
|
|||||||
case 25: //임관
|
case 25: //임관
|
||||||
$double = $command[1];
|
$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($nationName, '로');
|
||||||
|
$str[$i] = "【{$nationName}】{$josaRo} 임관";
|
||||||
$josaRo = JosaUtil::pick($nation['name'], '로');
|
|
||||||
$str[$i] = "【{$nation['name']}】{$josaRo} 임관";
|
|
||||||
break;
|
break;
|
||||||
case 26: //집합
|
case 26: //집합
|
||||||
$str[$i] = "집합";
|
$str[$i] = "집합";
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ function process_25(&$general) {
|
|||||||
$history = [];
|
$history = [];
|
||||||
$date = substr($general['turntime'],11,5);
|
$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']}'";
|
$query = "select nation from city where city='{$general['city']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
@@ -79,6 +79,10 @@ function process_25(&$general) {
|
|||||||
$command = DecodeCommand($general['turn0']);
|
$command = DecodeCommand($general['turn0']);
|
||||||
$where = $command[1];
|
$where = $command[1];
|
||||||
|
|
||||||
|
if($admin['join_mode'] == 'onlyRandom' && $where < 98){
|
||||||
|
$where = 99;
|
||||||
|
}
|
||||||
|
|
||||||
$nation = null;
|
$nation = null;
|
||||||
|
|
||||||
$joinedNations = Json::decode($general['nations']);
|
$joinedNations = Json::decode($general['nations']);
|
||||||
@@ -126,10 +130,18 @@ function process_25(&$general) {
|
|||||||
|
|
||||||
$allGen = array_sum($generals);
|
$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(
|
$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',
|
'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,
|
$joinedNations,
|
||||||
($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
$genLimit
|
||||||
);
|
);
|
||||||
shuffle($nations);
|
shuffle($nations);
|
||||||
|
|
||||||
@@ -164,6 +176,12 @@ function process_25(&$general) {
|
|||||||
|
|
||||||
if(!$nation) {
|
if(!$nation) {
|
||||||
$log[] = "<C>●</>{$admin['month']}월:임관할 국가가 없습니다. 임관 실패. <1>$date</>";
|
$log[] = "<C>●</>{$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) {
|
} elseif($general['nation'] != 0) {
|
||||||
$log[] = "<C>●</>{$admin['month']}월:재야가 아닙니다. 임관 실패. <1>$date</>";
|
$log[] = "<C>●</>{$admin['month']}월:재야가 아닙니다. 임관 실패. <1>$date</>";
|
||||||
} elseif($nation['nation'] == 0) {
|
} elseif($nation['nation'] == 0) {
|
||||||
|
|||||||
@@ -152,6 +152,20 @@ if($session->userGrade < 5 && !$allowReset){
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="join_mode" class="col-sm-3 col-form-label">임관 모드</label>
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div id="join_mode" class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||||
|
<label class="btn btn-secondary active">
|
||||||
|
<input type="radio" name="join_mode" value="full" checked>일반
|
||||||
|
</label>
|
||||||
|
<label class="btn btn-secondary active">
|
||||||
|
<input type="radio" name="join_mode" value="onlyRandom" checked>랜덤 임관
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="show_img_level" class="col-sm-3 col-form-label">이미지 표기</label>
|
<label for="show_img_level" class="col-sm-3 col-form-label">이미지 표기</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
|
|||||||
+9
-4
@@ -41,6 +41,7 @@ $v->rule('required', [
|
|||||||
'scenario',
|
'scenario',
|
||||||
'fiction',
|
'fiction',
|
||||||
'extend',
|
'extend',
|
||||||
|
'join_mode',
|
||||||
'npcmode',
|
'npcmode',
|
||||||
'show_img_level'
|
'show_img_level'
|
||||||
])->rule('integer', [
|
])->rule('integer', [
|
||||||
@@ -49,10 +50,11 @@ $v->rule('required', [
|
|||||||
'scenario',
|
'scenario',
|
||||||
'fiction',
|
'fiction',
|
||||||
'extend',
|
'extend',
|
||||||
|
'join_mode',
|
||||||
'npcmode',
|
'npcmode',
|
||||||
'show_img_level',
|
'show_img_level',
|
||||||
'tournament_trig'
|
'tournament_trig',
|
||||||
]);
|
])->rule('in', 'join_mode', ['onlyRandom', 'full']);
|
||||||
if(!$v->validate()){
|
if(!$v->validate()){
|
||||||
Json::die([
|
Json::die([
|
||||||
'result'=>false,
|
'result'=>false,
|
||||||
@@ -92,6 +94,7 @@ $extend = (int)$_POST['extend'];
|
|||||||
$npcmode = (int)$_POST['npcmode'];
|
$npcmode = (int)$_POST['npcmode'];
|
||||||
$show_img_level = (int)$_POST['show_img_level'];
|
$show_img_level = (int)$_POST['show_img_level'];
|
||||||
$tournament_trig = (int)$_POST['tournament_trig'];
|
$tournament_trig = (int)$_POST['tournament_trig'];
|
||||||
|
$join_mode = $_POST['join_mode'];
|
||||||
|
|
||||||
if($reserve_open){
|
if($reserve_open){
|
||||||
$reserve_open = new \DateTime($reserve_open);
|
$reserve_open = new \DateTime($reserve_open);
|
||||||
@@ -124,7 +127,8 @@ if($reserve_open){
|
|||||||
'npcmode'=>$npcmode,
|
'npcmode'=>$npcmode,
|
||||||
'show_img_level'=>$show_img_level,
|
'show_img_level'=>$show_img_level,
|
||||||
'tournament_trig'=>$tournament_trig,
|
'tournament_trig'=>$tournament_trig,
|
||||||
'gameConf'=>$scenarioObj->getGameConf()
|
'gameConf'=>$scenarioObj->getGameConf(),
|
||||||
|
'join_mode'=>$join_mode,
|
||||||
]),
|
]),
|
||||||
'date'=>$reserve_open->format('Y-m-d H:i:s')
|
'date'=>$reserve_open->format('Y-m-d H:i:s')
|
||||||
]);
|
]);
|
||||||
@@ -143,5 +147,6 @@ Json::die(ResetHelper::buildScenario(
|
|||||||
$extend,
|
$extend,
|
||||||
$npcmode,
|
$npcmode,
|
||||||
$show_img_level,
|
$show_img_level,
|
||||||
$tournament_trig
|
$tournament_trig,
|
||||||
|
$join_mode
|
||||||
));
|
));
|
||||||
+4
-2
@@ -114,7 +114,8 @@ function formSetup(){
|
|||||||
extend:"required",
|
extend:"required",
|
||||||
npcmode:"required",
|
npcmode:"required",
|
||||||
show_img_level:"required",
|
show_img_level:"required",
|
||||||
tournament_trig:"required"
|
tournament_trig:"required",
|
||||||
|
join_mode:'required',
|
||||||
},
|
},
|
||||||
errorElement: "div",
|
errorElement: "div",
|
||||||
errorPlacement: function ( error, element ) {
|
errorPlacement: function ( error, element ) {
|
||||||
@@ -153,7 +154,8 @@ function formSetup(){
|
|||||||
npcmode:$('#npcmode input:radio:checked').val(),
|
npcmode:$('#npcmode input:radio:checked').val(),
|
||||||
show_img_level:$('#show_img_level input:radio:checked').val(),
|
show_img_level:$('#show_img_level input:radio:checked').val(),
|
||||||
tournament_trig:$('#tournament_trig 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){
|
}).then(function(result){
|
||||||
var deferred = $.Deferred();
|
var deferred = $.Deferred();
|
||||||
|
|||||||
+4
-3
@@ -31,7 +31,7 @@ function processWar(array $rawAttacker, array $rawDefenderCity){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$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);
|
$attacker = new WarUnitGeneral($rawAttacker, $rawAttackerCity, $rawAttackerNation, true, $year, $month);
|
||||||
|
|
||||||
@@ -154,7 +154,8 @@ function processWar(array $rawAttacker, array $rawDefenderCity){
|
|||||||
'startyear'=>$startYear,
|
'startyear'=>$startYear,
|
||||||
'year'=>$year,
|
'year'=>$year,
|
||||||
'month'=>$month,
|
'month'=>$month,
|
||||||
'city_rate'=>$cityRate
|
'city_rate'=>$cityRate,
|
||||||
|
'join_mode'=>$joinMode,
|
||||||
], $attacker->getRaw(), $city->getRaw(), $rawAttackerNation, $rawDefenderNation);
|
], $attacker->getRaw(), $city->getRaw(), $rawAttackerNation, $rawDefenderNation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,7 +569,7 @@ function ConquerCity($admin, $general, $city, $nation, $destnation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//NPC인 경우 10% 확률로 임관(엔장, 인재, 의병)
|
//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); //임관
|
$commissionCommand = EncodeCommand(0, 0, $nation['nation'], 25); //임관
|
||||||
$query = "update general set turn0='$commissionCommand' where no={$gen['no']}";
|
$query = "update general set turn0='$commissionCommand' where no={$gen['no']}";
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
|
|||||||
+33
-28
@@ -686,6 +686,9 @@ function command_25($turn, $command) {
|
|||||||
$connect=$db->get();
|
$connect=$db->get();
|
||||||
$userID = Session::getUserID();
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
|
$gameStor->cacheValues(['year','startyear','month','join_mode']);
|
||||||
|
|
||||||
|
$randomOnly = $gameStor->join_mode == 'randomOnly';
|
||||||
starter("임관");
|
starter("임관");
|
||||||
|
|
||||||
$query = "select no,nations from general where owner='{$userID}'";
|
$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()');
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
국가에 임관합니다.<br>
|
국가에 임관합니다.<br>
|
||||||
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.<br>
|
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.<br>
|
||||||
바로 군주의 위치로 이동합니다.<br>
|
바로 군주의 위치로 이동합니다.<br>
|
||||||
@@ -712,37 +730,24 @@ function command_25($turn, $command) {
|
|||||||
<form name=form1 action=c_double.php method=post>
|
<form name=form1 action=c_double.php method=post>
|
||||||
<select name=double size=1 style=color:white;background-color:black>
|
<select name=double size=1 style=color:white;background-color:black>
|
||||||
<option value=99 style=color:white;background-color:black;>!!!</option>
|
<option value=99 style=color:white;background-color:black;>!!!</option>
|
||||||
<option value=98 style=color:white;background-color:black;>???</option>";
|
<option value=98 style=color:white;background-color:black;>???</option>
|
||||||
|
|
||||||
$scoutStr = "";
|
<?php foreach($nationList as $nation): ?>
|
||||||
foreach($nationList as $nation){
|
<?php if($nation['availableJoin']): ?>
|
||||||
if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit) {
|
<option value='<?=$nation['nation']?>' style='color:<?=$nation['color']?>;background-color:red;' <?=$randomOnly?'disabled':''?>>【 <?=$nation['name']?> 】</option>
|
||||||
echo "
|
<?php else: ?>
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
|
<option value='<?=$nation['nation']?>' style='color:<?=$nation['color']?>;' <?=$randomOnly?'disabled':''?>>【 <?=$nation['name']?> 】</option>
|
||||||
} elseif($nation['scout'] == 1) {
|
<?php endif; ?>
|
||||||
echo "
|
<?php endforeach; ?>
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
|
|
||||||
} elseif(in_array($nation['nation'], $joinedNations)) {
|
|
||||||
/*
|
|
||||||
echo "
|
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red; disabled>【 {$nation['name']} 】</option>";
|
|
||||||
*/
|
|
||||||
} else {
|
|
||||||
echo "
|
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};>【 {$nation['name']} 】</option>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo "
|
|
||||||
</select>
|
</select>
|
||||||
<input type=submit value=임관>
|
<input type=submit value=임관>
|
||||||
<input type=hidden name=command value=$command>";
|
<input type=hidden name=command value=$command>";
|
||||||
for($i=0; $i < count($turn); $i++) {
|
<?php foreach(range(0, count(turn) - 1) as $i): ?>
|
||||||
echo "
|
<input type=hidden name=turn[] value=<?=$turn[$i]?>>
|
||||||
<input type=hidden name=turn[] value=$turn[$i]>";
|
<?php endforeach; ?>
|
||||||
}
|
</form>
|
||||||
|
<?php
|
||||||
echo "
|
|
||||||
</form>";
|
|
||||||
echo getInvitationList($nationList);
|
echo getInvitationList($nationList);
|
||||||
|
|
||||||
ender();
|
ender();
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class GameConstBase
|
|||||||
/** @var int 최대 기술 레벨 */
|
/** @var int 최대 기술 레벨 */
|
||||||
public static $maxTechLevel = 12;
|
public static $maxTechLevel = 12;
|
||||||
|
|
||||||
|
/** @var int 초기 제한시 장수 제한 */
|
||||||
|
public static $initialNationGenLimitForRandInit = 3;
|
||||||
|
|
||||||
/** @var int 초기 제한시 장수 제한 */
|
/** @var int 초기 제한시 장수 제한 */
|
||||||
public static $initialNationGenLimit = 10;
|
public static $initialNationGenLimit = 10;
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ class ResetHelper{
|
|||||||
int $extend,
|
int $extend,
|
||||||
int $npcmode,
|
int $npcmode,
|
||||||
int $show_img_level,
|
int $show_img_level,
|
||||||
int $tournament_trig
|
int $tournament_trig,
|
||||||
|
string $join_mode
|
||||||
):array{
|
):array{
|
||||||
//FIXME: 분리할 것
|
//FIXME: 분리할 것
|
||||||
if(120 % $turnterm != 0){
|
if(120 % $turnterm != 0){
|
||||||
@@ -193,6 +194,8 @@ class ResetHelper{
|
|||||||
'startyear'=>$startyear,
|
'startyear'=>$startyear,
|
||||||
'year'=> $year,
|
'year'=> $year,
|
||||||
'month'=> $month,
|
'month'=> $month,
|
||||||
|
'init_year'=> $year,
|
||||||
|
'init_month'=>$month,
|
||||||
'map_theme' => $scenarioObj->getMapTheme(),
|
'map_theme' => $scenarioObj->getMapTheme(),
|
||||||
'msg'=>'공지사항',//TODO:공지사항
|
'msg'=>'공지사항',//TODO:공지사항
|
||||||
'maxgeneral'=>GameConst::$defaultMaxGeneral,
|
'maxgeneral'=>GameConst::$defaultMaxGeneral,
|
||||||
@@ -207,6 +210,7 @@ class ResetHelper{
|
|||||||
'killturn'=>$killturn,
|
'killturn'=>$killturn,
|
||||||
'genius'=>GameConst::$defaultMaxGenius,
|
'genius'=>GameConst::$defaultMaxGenius,
|
||||||
'show_img_level'=>$show_img_level,
|
'show_img_level'=>$show_img_level,
|
||||||
|
'join_mode'=>$join_mode,
|
||||||
'npcmode'=>$npcmode,
|
'npcmode'=>$npcmode,
|
||||||
'extended_general'=>$extend,
|
'extended_general'=>$extend,
|
||||||
'fiction'=>$fiction,
|
'fiction'=>$fiction,
|
||||||
|
|||||||
Reference in New Issue
Block a user