임관시 $general['nations'] 를 Json Array로 변경
This commit is contained in:
+9
-10
@@ -309,12 +309,11 @@ function processAI($no) {
|
|||||||
//재야인경우
|
//재야인경우
|
||||||
if($general['npc'] == 5 && $general['level'] == 0) {
|
if($general['npc'] == 5 && $general['level'] == 0) {
|
||||||
// 오랑캐는 바로 임관
|
// 오랑캐는 바로 임관
|
||||||
$query = "select nation from general where level=12 and npc=5 and nation not in (0{$general['nations']}0) order by rand() limit 0,1";
|
|
||||||
$result = MYDB_query($query, $connect) or Error("processAI06 ".MYDB_error($connect),"");
|
$rulerNation = $db->queryFirstField('SELECT nation FROM general WHERE `level`=12 AND npc=5 and nation not in %li ORDER BY RAND() limit 1', Json::decode($general['nations']));
|
||||||
$rulerCount = MYDB_num_rows($result);
|
|
||||||
if($rulerCount > 0) {
|
if($ruler) {
|
||||||
$ruler = MYDB_fetch_array($result);
|
$command = EncodeCommand(0, 0, $rulerNation, 25); //임관
|
||||||
$command = EncodeCommand(0, 0, $ruler['nation'], 25); //임관
|
|
||||||
} else {
|
} else {
|
||||||
$command = EncodeCommand(0, 0, 0, 42); //견문
|
$command = EncodeCommand(0, 0, 0, 42); //견문
|
||||||
}
|
}
|
||||||
@@ -328,7 +327,7 @@ function processAI($no) {
|
|||||||
|
|
||||||
$available = true;
|
$available = true;
|
||||||
|
|
||||||
if($admin['startyear']+3 > $admin['year']){
|
if($admin['startyear']+2 > $admin['year']){
|
||||||
//초기 임관 기간에서는 국가가 적을수록 임관 시도가 적음
|
//초기 임관 기간에서는 국가가 적을수록 임관 시도가 적음
|
||||||
$nationCnt = $db->queryFirstField('SELECT count(nation) FROM nation');
|
$nationCnt = $db->queryFirstField('SELECT count(nation) FROM nation');
|
||||||
if(Util::randBool(1/$nationCnt)){
|
if(Util::randBool(1/$nationCnt)){
|
||||||
@@ -346,10 +345,10 @@ function processAI($no) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: case 3: //거병이나 견문 40%
|
case 2: case 3: //거병이나 견문 40%
|
||||||
// 초반이면서 능력이 좋은놈 위주로 1.5%확률로 거병 (300명 재야시 2년간 약 15개 거병 예상)
|
// 초반이면서 능력이 좋은놈 위주로 1.5%확률로 거병
|
||||||
$prop = rand() % 100;
|
$prop = Util::randF() * (GameConst::$defaultStatNPCMax + GameConst::$chiefStatMin) * 2 / 3;
|
||||||
$ratio = Util::round(($general['leader'] + $general['power'] + $general['intel']) / 3);
|
$ratio = Util::round(($general['leader'] + $general['power'] + $general['intel']) / 3);
|
||||||
if($admin['startyear']+2 > $admin['year'] && $prop < $ratio && rand()%200 < 3 && $general['makelimit'] == 0) {
|
if($admin['startyear']+2 > $admin['year'] && $prop < $ratio && Util::randBool(0.01) && $general['makelimit'] == 0) {
|
||||||
//거병
|
//거병
|
||||||
$command = EncodeCommand(0, 0, 0, 55);
|
$command = EncodeCommand(0, 0, 0, 55);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -78,12 +78,14 @@ function process_25(&$general) {
|
|||||||
|
|
||||||
$nation = null;
|
$nation = null;
|
||||||
|
|
||||||
|
$joinedNations = Json::decode($general['nations']);
|
||||||
|
|
||||||
// 랜덤임관인 경우
|
// 랜덤임관인 경우
|
||||||
if($general['npc'] > 2 && $where >= 98 && ($admin['scenario'] == 0 || $admin['scenario'] >= 20 || !$admin['fiction'])){
|
if($general['npc'] > 2 && $where >= 98 && ($admin['scenario'] == 0 || $admin['scenario'] >= 20 || !$admin['fiction'])){
|
||||||
//'사실' 모드에서는 '성향'에 우선을 두되, 장수수, 랜덤에 비중을 둠
|
//'사실' 모드에서는 '성향'에 우선을 두되, 장수수, 랜덤에 비중을 둠
|
||||||
$nations = $db->query(
|
$nations = $db->query(
|
||||||
'SELECT nation.`name` as `name`,nation.nation as nation,scout,nation.`level` as `level`,gennum,`affinity` FROM nation join general on general.nation = nation.nation and general.level = 12 WHERE nation.nation not in %s and gennum < %i and scout = 0',
|
'SELECT nation.`name` as `name`,nation.nation as nation,scout,nation.`level` as `level`,gennum,`affinity` 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',
|
||||||
'0'.$general['nations'].'0',
|
$joinedNations,
|
||||||
($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
||||||
);
|
);
|
||||||
shuffle($nations);
|
shuffle($nations);
|
||||||
@@ -115,8 +117,8 @@ function process_25(&$general) {
|
|||||||
else if($where >= 98) {
|
else if($where >= 98) {
|
||||||
//랜임
|
//랜임
|
||||||
$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 %s 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',
|
||||||
'0'.$general['nations'].'0',
|
$joinedNations,
|
||||||
($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
($admin['year'] < $admin['startyear']+3)?GameConst::$initialNationGenLimit:GameConst::$defaultMaxGeneral
|
||||||
);
|
);
|
||||||
shuffle($nations);
|
shuffle($nations);
|
||||||
@@ -133,7 +135,7 @@ function process_25(&$general) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$score = 1;
|
$score = 1;
|
||||||
if($admin['startyear']+3 > $admin['year']){
|
if($admin['startyear']+3 > $admin['year'] && $general['npc'] > 2){
|
||||||
$score *= sqrt((100-$testNation['injury'])/100);
|
$score *= sqrt((100-$testNation['injury'])/100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +170,7 @@ function process_25(&$general) {
|
|||||||
$log[] = "<C>●</>{$admin['month']}월:현재 <D>{$nation['name']}</>{$josaUn} 임관이 금지되어 있습니다. 임관 실패.";
|
$log[] = "<C>●</>{$admin['month']}월:현재 <D>{$nation['name']}</>{$josaUn} 임관이 금지되어 있습니다. 임관 실패.";
|
||||||
} elseif($general['makelimit'] > 0 && $general['npc'] < 5) {
|
} elseif($general['makelimit'] > 0 && $general['npc'] < 5) {
|
||||||
$log[] = "<C>●</>{$admin['month']}월:재야가 된지 12턴이 지나야 합니다. 임관 실패. <1>$date</>";
|
$log[] = "<C>●</>{$admin['month']}월:재야가 된지 12턴이 지나야 합니다. 임관 실패. <1>$date</>";
|
||||||
} elseif(strpos($general['nations'], ",{$nation['nation']},") > 0) {
|
} elseif(in_array($nation['nation'], $joinedNations)) {
|
||||||
$log[] = "<C>●</>{$admin['month']}월:이미 임관했었던 국가입니다. 임관 실패. <1>$date</>";
|
$log[] = "<C>●</>{$admin['month']}월:이미 임관했었던 국가입니다. 임관 실패. <1>$date</>";
|
||||||
} else {
|
} else {
|
||||||
$josaYi = JosaUtil::pick($general['name'], '이');
|
$josaYi = JosaUtil::pick($general['name'], '이');
|
||||||
@@ -195,15 +197,23 @@ function process_25(&$general) {
|
|||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
$king = MYDB_fetch_array($result);
|
$king = MYDB_fetch_array($result);
|
||||||
|
|
||||||
|
|
||||||
// NPC초반시 임관기록 추가 안함
|
// NPC초반시 임관기록 추가 안함
|
||||||
if($general['npc'] > 1 && $admin['year'] < $admin['startyear']+3) {
|
if($general['npc'] > 1 && $admin['year'] < $admin['startyear']+3) {
|
||||||
} else {
|
} else {
|
||||||
$general['nations'] .= "{$nation['nation']},";
|
$joinedNations[] = $nation['nation'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 국적 바꾸고 등급 일반으로 // 명성 상승
|
// 국적 바꾸고 등급 일반으로 // 명성 상승
|
||||||
$query = "update general set resturn='SUCCESS',nation='{$nation['nation']}',nations='{$general['nations']}',level='1',experience=experience+'$exp',city='{$king['city']}',belong=1 where no='{$general['no']}'";
|
$db->update('general', [
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
'resturn'=>'SUCCESS',
|
||||||
|
'nation'=>$nation['nation'],
|
||||||
|
'nations'=>Json::encode($joinedNations),
|
||||||
|
'level'=>1,
|
||||||
|
'experience'=>$db->sqleval('experience + %i', $exp),
|
||||||
|
'city'=>$king['city'],
|
||||||
|
'belong'=>1
|
||||||
|
], 'no=%i', $general['no']);
|
||||||
|
|
||||||
//국가 기술력 그대로
|
//국가 기술력 그대로
|
||||||
$query = "select no from general where nation='{$nation['nation']}'";
|
$query = "select no from general where nation='{$nation['nation']}'";
|
||||||
|
|||||||
+3
-1
@@ -967,6 +967,8 @@ function command_25($turn, $command) {
|
|||||||
$result = MYDB_query($query, $connect) or Error("command_27 ".MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error("command_27 ".MYDB_error($connect),"");
|
||||||
$me = MYDB_fetch_array($result);
|
$me = MYDB_fetch_array($result);
|
||||||
|
|
||||||
|
$joinedNations = Json::decode($me['nations']);
|
||||||
|
|
||||||
$query = "select nation,name,color,scout,scoutmsg,sabotagelimit,gennum from nation order by gennum";
|
$query = "select nation,name,color,scout,scoutmsg,sabotagelimit,gennum from nation order by gennum";
|
||||||
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
|
||||||
$count = MYDB_num_rows($result);
|
$count = MYDB_num_rows($result);
|
||||||
@@ -1001,7 +1003,7 @@ function command_25($turn, $command) {
|
|||||||
} elseif($nation['scout'] == 1) {
|
} elseif($nation['scout'] == 1) {
|
||||||
echo "
|
echo "
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
|
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
|
||||||
} elseif(strpos($me['nations'], ",{$nation['nation']},") > 0) {
|
} elseif(in_array($nation['nation'], $joinedNations)) {
|
||||||
/*
|
/*
|
||||||
echo "
|
echo "
|
||||||
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red; disabled>【 {$nation['name']} 】</option>";
|
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red; disabled>【 {$nation['name']} 】</option>";
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Personnel{
|
|||||||
return [ScoutMessage::DECLINED, '군주는 등용장을 수락할 수 없습니다.'];
|
return [ScoutMessage::DECLINED, '군주는 등용장을 수락할 수 없습니다.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($general['nations'], ",{$this->nation['nation']},") !== false){
|
if(in_array($this->nation['nation'], Json::decode($general['nations']))){
|
||||||
return [ScoutMessage::DECLINED, '이미 임관했었던 국가입니다.'];
|
return [ScoutMessage::DECLINED, '이미 임관했었던 국가입니다.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,13 +119,16 @@ class Personnel{
|
|||||||
$originalNationGeneralCnt = GameConst::$initialNationGenLimit;
|
$originalNationGeneralCnt = GameConst::$initialNationGenLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$joinedNations = Json::decode($general['nations']);
|
||||||
|
$joinedNations[] = $this->nation['nation'];
|
||||||
|
|
||||||
// 국가 변경, 도시 변경, 일반으로, 수도로
|
// 국가 변경, 도시 변경, 일반으로, 수도로
|
||||||
$setValues = [
|
$setValues = [
|
||||||
'belong'=>1,
|
'belong'=>1,
|
||||||
'level'=>1,
|
'level'=>1,
|
||||||
'nation'=>$this->nation['nation'],
|
'nation'=>$this->nation['nation'],
|
||||||
'city'=>$this->nation['capital'],
|
'city'=>$this->nation['capital'],
|
||||||
'nations'=>$db->sqleval('CONCAT(nations, %s)', "{$this->nation['nation']},"),
|
'nations'=>Json::encode($joinedNations),
|
||||||
'troop'=>0,
|
'troop'=>0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ CREATE TABLE `general` (
|
|||||||
`name` CHAR(32) NOT NULL COLLATE 'utf8mb4_bin',
|
`name` CHAR(32) NOT NULL COLLATE 'utf8mb4_bin',
|
||||||
`name2` CHAR(32) NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
|
`name2` CHAR(32) NULL DEFAULT NULL COLLATE 'utf8mb4_bin',
|
||||||
`nation` INT(6) NULL DEFAULT '0',
|
`nation` INT(6) NULL DEFAULT '0',
|
||||||
`nations` CHAR(64) NULL DEFAULT ',0,',
|
`nations` VARCHAR(64) NOT NULL DEFAULT '[0]',
|
||||||
`city` INT(6) NULL DEFAULT '3',
|
`city` INT(6) NULL DEFAULT '3',
|
||||||
`troop` INT(6) NULL DEFAULT '0',
|
`troop` INT(6) NULL DEFAULT '0',
|
||||||
`leader` INT(3) NULL DEFAULT '50',
|
`leader` INT(3) NULL DEFAULT '50',
|
||||||
|
|||||||
Reference in New Issue
Block a user