랜덤 임관 깃수용 코드 이식

This commit is contained in:
2018-10-28 03:32:03 +09:00
parent da612bdc7b
commit 60d5184a7b
12 changed files with 135 additions and 54 deletions
+5 -2
View File
@@ -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);
+14
View File
@@ -152,6 +152,20 @@ if($session->userGrade < 5 && !$allowReset){
</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">
<input type="radio" name="join_mode" value="onlyRandom">랜덤 임관
</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="show_img_level" class="col-sm-3 col-form-label">이미지 표기</label>
<div class="col-sm-9">
+2 -1
View File
@@ -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;
+8 -4
View File
@@ -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
));
+16 -1
View File
@@ -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
+4 -2
View File
@@ -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();
+4 -3
View File
@@ -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']]);
}
}
+39 -30
View File
@@ -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;
}
}
?>
국가에 임관합니다.<br>
이미 임관/등용되었던 국가는 다시 임관할 수 없습니다.<br>
바로 군주의 위치로 이동합니다.<br>
<?php if($onlyRandom): ?>
랜덤 임관 대상 국가는 아래에서 확인할 수 있습니다.<br>
<?php else: ?>
임관할 국가를 목록에서 선택하세요.<br>
<?php endif; ?>
!!!는 방랑군을 포함한 랜덤임관입니다. 유니크를 기대하신다면!<br>
???는 방랑군을 제외한 랜덤임관입니다. 유니크 혜택은 없습니다.<br>
임관 금지이거나 초기 제한중인 국가는 붉은색 배경으로 표시됩니다.<br>
@@ -707,37 +729,24 @@ function command_25($turn, $command) {
<form name=form1 action=c_double.php method=post>
<select name=double size=1 style=color:white;background-color:black>
<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 = "";
foreach($nationList as $nation){
if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= GameConst::$initialNationGenLimit) {
echo "
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
} elseif($nation['scout'] == 1) {
echo "
<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 "
<?php foreach($nationList as $nation): ?>
<?php if($nation['availableJoin']): ?>
<option value='<?=$nation['nation']?>' style='color:<?=$nation['color']?>;background-color:red;' <?=$onlyRandom?'disabled':''?>>【 <?=$nation['name']?> 】</option>
<?php else: ?>
<option value='<?=$nation['nation']?>' style='color:<?=$nation['color']?>;' <?=$onlyRandom?'disabled':''?>>【 <?=$nation['name']?> 】</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<input type=submit value=임관>
<input type=hidden name=command value=$command>";
for($i=0; $i < count($turn); $i++) {
echo "
<input type=hidden name=turn[] value=$turn[$i]>";
}
echo "
</form>";
<input type=hidden name=command value=<?=$command?>>
<?php foreach(range(0, count(turn) - 1) as $i): ?>
<input type=hidden name=turn[] value=<?=$turn[$i]?>>
<?php endforeach; ?>
</form>
<?php
echo getInvitationList($nationList);
ender();
+11 -8
View File
@@ -3,13 +3,13 @@ namespace sammo;
class GameConstBase
{
/** @var string 게임명 */
public static $title = "삼국지 모의전투 PHP HiDCHe";
/** @var string 코드 아래에 붙는 설명 코드 */
public static $banner = "KOEI의 이미지를 사용, 응용하였습니다 / 제작 : HideD(hided62@gmail.com) / <a href='https://sam.hided.net/wiki/hidche/credit' target='_blank' style='color:white;text-decoration: underline;'>Credit</a>";
/** @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) / <a href='https://sam.hided.net/wiki/hidche/credit' target='_blank' style='color:white;text-decoration: underline;'>Credit</a>";
/** @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 거병,임관 제한 기간 */
+5 -1
View File
@@ -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,
+1 -1
View File
@@ -47,7 +47,7 @@ var serverReservedTemplate = "\
<td colspan='4' class='server_reserved'>\
- 오픈 일시 : <%openDatetime%> - <br>\
<span style='color:orange;'><%scenarioName%></span> <span style='color:limegreen;'><%turnterm%>분 턴 서버</span><br>\
(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>)</td>\
(상성 설정:<%fictionMode%>), (빙의 여부:<%npcMode%>), (최대 스탯:<%gameConf.defaultStatTotal%>), (기타 설정:<%otherTextInfo%>)</td>\
";
$(function(){
+26 -1
View File
@@ -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;
}
}