국기 변경 수정, 아이템 보상 추가
This commit is contained in:
+1
-1
@@ -328,7 +328,7 @@ if ($admin['voteopen'] >= 2 || $isVoteAdmin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$per = round($nationVote[$nation['nation']][$k]??0 / $memCount * 100, 1);
|
||||
$per = round(($nationVote[$nation['nation']][$k]??0) / $memCount * 100, 1);
|
||||
|
||||
if($i == $voteTypeCount-1){
|
||||
$per = 100-$totalPer;
|
||||
|
||||
+710
-619
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use sammo\Event\Action;
|
||||
@@ -26,7 +27,7 @@ require_once('func_command.php');
|
||||
*
|
||||
* @return array|null nationID에 해당하는 국가가 있을 경우 array 반환. 그외의 경우 null
|
||||
*/
|
||||
function getNationStaticInfo($nationID, $forceRefresh=false)
|
||||
function getNationStaticInfo($nationID, $forceRefresh = false)
|
||||
{
|
||||
static $nationList = null;
|
||||
|
||||
@@ -35,38 +36,38 @@ function getNationStaticInfo($nationID, $forceRefresh=false)
|
||||
}
|
||||
|
||||
if ($nationID === null) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
if($nationID === -1 && $nationList !== null){
|
||||
if ($nationID === -1 && $nationList !== null) {
|
||||
return $nationList;
|
||||
}
|
||||
|
||||
if($nationID === 0){
|
||||
if ($nationID === 0) {
|
||||
return [
|
||||
'nation'=>0,
|
||||
'name'=>'재야',
|
||||
'color'=>'#000000',
|
||||
'type'=>GameConst::$neutralNationType,
|
||||
'level'=>0,
|
||||
'capital'=>0,
|
||||
'gold'=>0,
|
||||
'rice'=>2000,
|
||||
'tech'=>0,
|
||||
'gennum'=>1,
|
||||
'power'=>1
|
||||
'nation' => 0,
|
||||
'name' => '재야',
|
||||
'color' => '#000000',
|
||||
'type' => GameConst::$neutralNationType,
|
||||
'level' => 0,
|
||||
'capital' => 0,
|
||||
'gold' => 0,
|
||||
'rice' => 2000,
|
||||
'tech' => 0,
|
||||
'gennum' => 1,
|
||||
'power' => 1
|
||||
];
|
||||
}
|
||||
|
||||
if($nationList === null){
|
||||
if ($nationList === null) {
|
||||
$nationAll = DB::db()->query("select nation, name, color, type, level, capital, gennum, power from nation");
|
||||
$nationList = Util::convertArrayToDict($nationAll, "nation");
|
||||
}
|
||||
|
||||
if($nationID === -1){
|
||||
if ($nationID === -1) {
|
||||
return $nationList;
|
||||
}
|
||||
|
||||
if(isset($nationList[$nationID])){
|
||||
if (isset($nationList[$nationID])) {
|
||||
return $nationList[$nationID];
|
||||
}
|
||||
return null;
|
||||
@@ -88,8 +89,9 @@ function getAllNationStaticInfo()
|
||||
return getNationStaticInfo(-1);
|
||||
}
|
||||
|
||||
function GetImageURL($imgsvr, $filepath='') {
|
||||
if($imgsvr == 0) {
|
||||
function GetImageURL($imgsvr, $filepath = '')
|
||||
{
|
||||
if ($imgsvr == 0) {
|
||||
return ServConfig::getSharedIconPath($filepath);
|
||||
} else {
|
||||
return AppConf::getUserIconPathWeb($filepath);
|
||||
@@ -100,35 +102,38 @@ function GetImageURL($imgsvr, $filepath='') {
|
||||
* @param null|int $con 장수의 벌점
|
||||
* @param null|int $conlimit 최대 벌점
|
||||
*/
|
||||
function checkLimit($con = null) {
|
||||
function checkLimit($con = null)
|
||||
{
|
||||
$session = Session::getInstance();
|
||||
if($session->userGrade>=4){
|
||||
if ($session->userGrade >= 4) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
if($con === null){
|
||||
if ($con === null) {
|
||||
$con = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', Session::getUserID());
|
||||
}
|
||||
$conlimit = $gameStor->conlimit;
|
||||
|
||||
if($con > $conlimit) {
|
||||
if ($con > $conlimit) {
|
||||
return 2;
|
||||
//접속제한 90%이면 경고문구
|
||||
} elseif($con > $conlimit * 0.9) {
|
||||
//접속제한 90%이면 경고문구
|
||||
} elseif ($con > $conlimit * 0.9) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function getBlockLevel() {
|
||||
function getBlockLevel()
|
||||
{
|
||||
return DB::db()->queryFirstField('select block from general where no = %i', Session::getInstance()->generalID);
|
||||
}
|
||||
|
||||
function getRandGenName() {
|
||||
function getRandGenName()
|
||||
{
|
||||
$firstname = Util::choiceRandom(GameConst::$randGenFirstName);
|
||||
$middlename = Util::choiceRandom(GameConst::$randGenMiddleName);
|
||||
$lastname = Util::choiceRandom(GameConst::$randGenLastName);
|
||||
@@ -138,7 +143,8 @@ function getRandGenName() {
|
||||
|
||||
|
||||
|
||||
function cityInfo(General $generalObj) {
|
||||
function cityInfo(General $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
// 도시 정보
|
||||
@@ -147,7 +153,7 @@ function cityInfo(General $generalObj) {
|
||||
|
||||
$nation = getNationStaticInfo($city['nation']);
|
||||
|
||||
if(!$nation){
|
||||
if (!$nation) {
|
||||
$nation = getNationStaticInfo(0);
|
||||
}
|
||||
|
||||
@@ -158,12 +164,12 @@ function cityInfo(General $generalObj) {
|
||||
$city['levelText'] = CityConst::$levelMap[$city['level']];
|
||||
|
||||
$officerName = [
|
||||
2=>'-',
|
||||
3=>'-',
|
||||
4=>'-'
|
||||
2 => '-',
|
||||
3 => '-',
|
||||
4 => '-'
|
||||
];
|
||||
|
||||
foreach($db->query('SELECT `officer_level`, `name`, npc, no FROM general WHERE officer_city = %i', $cityID) as $officer){
|
||||
foreach ($db->query('SELECT `officer_level`, `name`, npc, no FROM general WHERE officer_city = %i', $cityID) as $officer) {
|
||||
$officerName[$officer['officer_level']] = getColoredName($officer['name'], $officer['npc']);
|
||||
}
|
||||
|
||||
@@ -174,117 +180,146 @@ function cityInfo(General $generalObj) {
|
||||
return $templates->render('mainCityInfo', $city);
|
||||
}
|
||||
|
||||
function myNationInfo() {
|
||||
function myNationInfo()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$admin = $gameStor->getValues(['startyear','year']);
|
||||
$admin = $gameStor->getValues(['startyear', 'year']);
|
||||
|
||||
$query = "select no,nation from general where owner='{$userID}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select nation,name,color,power,msg,gold,rice,bill,rate,scout,war,strategic_cmd_limit,surlimit,tech,level,type from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select COUNT(*) as cnt, SUM(pop) as totpop, SUM(pop_max) as maxpop from city where nation='{$nation['nation']}'"; // 도시 이름 목록
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$city = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select COUNT(*) as cnt, SUM(crew) as totcrew,SUM(leadership)*100 as maxcrew from general where nation='{$nation['nation']}'"; // 장수 목록
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$general = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select name from general where nation='{$nation['nation']}' and officer_level='12'";
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$level12 = MYDB_fetch_array($genresult);
|
||||
|
||||
$query = "select name from general where nation='{$nation['nation']}' and officer_level='11'";
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$level11 = MYDB_fetch_array($genresult);
|
||||
|
||||
echo "<table width=498 class='tb_layout bg2 nation_info'>
|
||||
<tr>
|
||||
<td colspan=4 ";
|
||||
|
||||
if($me['nation'] == 0) { echo "style='color:white;background-color:000000;font-weight:bold;font-size:13px;text-align:center;'>【재 야】"; }
|
||||
else { echo "style='color:".newColor($nation['color']).";background-color:{$nation['color']};font-weight:bold;font-size:13px;text-align:center'>국가【 {$nation['name']} 】"; }
|
||||
if ($me['nation'] == 0) {
|
||||
echo "style='color:white;background-color:000000;font-weight:bold;font-size:13px;text-align:center;'>【재 야】";
|
||||
} else {
|
||||
echo "style='color:" . newColor($nation['color']) . ";background-color:{$nation['color']};font-weight:bold;font-size:13px;text-align:center'>국가【 {$nation['name']} 】";
|
||||
}
|
||||
|
||||
echo "
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bg1 center'><b>성 향</b></td>
|
||||
<td colspan=3 class='center'><font color=\"yellow\">".getNationType($nation['type'])."</font> (".getNationType2($nation['type']).")</td>
|
||||
<td colspan=3 class='center'><font color=\"yellow\">" . getNationType($nation['type']) . "</font> (" . getNationType2($nation['type']) . ")</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width=68 class='bg1 center'><b>".getOfficerLevelText(12, $nation['level'])."</b></td>
|
||||
<td width=178 class='center'>";echo $level12?$level12['name']:"-"; echo "</td>
|
||||
<td width=68 class='bg1 center'><b>".getOfficerLevelText(11, $nation['level'])."</b></td>
|
||||
<td width=178 class='center'>";echo $level11?$level11['name']:"-"; echo "</td>
|
||||
<td width=68 class='bg1 center'><b>" . getOfficerLevelText(12, $nation['level']) . "</b></td>
|
||||
<td width=178 class='center'>";
|
||||
echo $level12 ? $level12['name'] : "-";
|
||||
echo "</td>
|
||||
<td width=68 class='bg1 center'><b>" . getOfficerLevelText(11, $nation['level']) . "</b></td>
|
||||
<td width=178 class='center'>";
|
||||
echo $level11 ? $level11['name'] : "-";
|
||||
echo "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bg1 center'><b>총주민</b></td>
|
||||
<td class='center'>";echo $me['nation']==0?"해당 없음":"{$city['totpop']}/{$city['maxpop']}";echo "</td>
|
||||
<td class='center'>";
|
||||
echo $me['nation'] == 0 ? "해당 없음" : "{$city['totpop']}/{$city['maxpop']}";
|
||||
echo "</td>
|
||||
<td class='bg1 center'><b>총병사</b></td>
|
||||
<td class='center'>";echo $me['nation']==0?"해당 없음":"{$general['totcrew']}/{$general['maxcrew']}"; echo "</td>
|
||||
<td class='center'>";
|
||||
echo $me['nation'] == 0 ? "해당 없음" : "{$general['totcrew']}/{$general['maxcrew']}";
|
||||
echo "</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bg1 center'><b>국 고</b></td>
|
||||
<td class='center'>";echo $me['nation']==0?"해당 없음":"{$nation['gold']}";echo "</td>
|
||||
<td class='center'>";
|
||||
echo $me['nation'] == 0 ? "해당 없음" : "{$nation['gold']}";
|
||||
echo "</td>
|
||||
<td class='bg1 center'><b>병 량</b></td>
|
||||
<td class='center'>";echo $me['nation']==0?"해당 없음":"{$nation['rice']}";echo "</td>
|
||||
<td class='center'>";
|
||||
echo $me['nation'] == 0 ? "해당 없음" : "{$nation['rice']}";
|
||||
echo "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='bg1 center'><b>지급률</b></td>
|
||||
<td class='center'>";
|
||||
if($me['nation'] == 0) {
|
||||
if ($me['nation'] == 0) {
|
||||
echo "해당 없음";
|
||||
} else {
|
||||
echo $nation['bill']==0?"0 %":"{$nation['bill']} %";
|
||||
echo $nation['bill'] == 0 ? "0 %" : "{$nation['bill']} %";
|
||||
}
|
||||
echo "
|
||||
</td>
|
||||
<td class='bg1 center'><b>세 율</b></td>
|
||||
<td class='center'>";
|
||||
if($me['nation'] == 0) {
|
||||
if ($me['nation'] == 0) {
|
||||
echo "해당 없음";
|
||||
} else {
|
||||
echo $nation['rate']==0?"0 %":"{$nation['rate']} %";
|
||||
echo $nation['rate'] == 0 ? "0 %" : "{$nation['rate']} %";
|
||||
}
|
||||
|
||||
$techCall = getTechCall($nation['tech']);
|
||||
|
||||
if(TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) { $nation['tech'] = "<font color=magenta>".floor($nation['tech'])."</font>"; }
|
||||
else { $nation['tech'] = "<font color=limegreen>".floor($nation['tech'])."</font>"; }
|
||||
if (TechLimit($admin['startyear'], $admin['year'], $nation['tech'])) {
|
||||
$nation['tech'] = "<font color=magenta>" . floor($nation['tech']) . "</font>";
|
||||
} else {
|
||||
$nation['tech'] = "<font color=limegreen>" . floor($nation['tech']) . "</font>";
|
||||
}
|
||||
|
||||
$nation['tech'] = "$techCall / {$nation['tech']}";
|
||||
|
||||
if($me['nation']==0){
|
||||
|
||||
if ($me['nation'] == 0) {
|
||||
$nation['strategic_cmd_limit'] = "<font color=white>해당 없음</font>";
|
||||
$nation['surlimit'] = "<font color=white>해당 없음</font>";
|
||||
$nation['scout'] = "<font color=white>해당 없음</font>";
|
||||
$nation['war'] = "<font color=white>해당 없음</font>";
|
||||
$nation['power'] = "<font color=white>해당 없음</font>";
|
||||
} else {
|
||||
if($nation['strategic_cmd_limit'] != 0) { $nation['strategic_cmd_limit'] = "<font color=red>{$nation['strategic_cmd_limit']}턴</font>"; }
|
||||
else { $nation['strategic_cmd_limit'] = "<font color=limegreen>가 능</font>"; }
|
||||
|
||||
if($nation['surlimit'] != 0) { $nation['surlimit'] = "<font color=red>{$nation['surlimit']}턴</font>"; }
|
||||
else { $nation['surlimit'] = "<font color=limegreen>가 능</font>"; }
|
||||
|
||||
if($nation['scout'] != 0) { $nation['scout'] = "<font color=red>금 지</font>"; }
|
||||
else { $nation['scout'] = "<font color=limegreen>허 가</font>"; }
|
||||
|
||||
if($nation['war'] != 0) { $nation['war'] = "<font color=red>금 지</font>"; }
|
||||
else { $nation['war'] = "<font color=limegreen>허 가</font>"; }
|
||||
|
||||
|
||||
if ($nation['strategic_cmd_limit'] != 0) {
|
||||
$nation['strategic_cmd_limit'] = "<font color=red>{$nation['strategic_cmd_limit']}턴</font>";
|
||||
} else {
|
||||
$nation['strategic_cmd_limit'] = "<font color=limegreen>가 능</font>";
|
||||
}
|
||||
|
||||
if ($nation['surlimit'] != 0) {
|
||||
$nation['surlimit'] = "<font color=red>{$nation['surlimit']}턴</font>";
|
||||
} else {
|
||||
$nation['surlimit'] = "<font color=limegreen>가 능</font>";
|
||||
}
|
||||
|
||||
if ($nation['scout'] != 0) {
|
||||
$nation['scout'] = "<font color=red>금 지</font>";
|
||||
} else {
|
||||
$nation['scout'] = "<font color=limegreen>허 가</font>";
|
||||
}
|
||||
|
||||
if ($nation['war'] != 0) {
|
||||
$nation['war'] = "<font color=red>금 지</font>";
|
||||
} else {
|
||||
$nation['war'] = "<font color=limegreen>허 가</font>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
@@ -292,15 +327,21 @@ function myNationInfo() {
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='text-align:center;' class='bg1'><b>속 령</b></td>
|
||||
<td style='text-align:center;'>";echo $me['nation']==0?"-":"{$city['cnt']}"; echo "</td>
|
||||
<td style='text-align:center;'>";
|
||||
echo $me['nation'] == 0 ? "-" : "{$city['cnt']}";
|
||||
echo "</td>
|
||||
<td style='text-align:center;' class='bg1'><b>장 수</b></td>
|
||||
<td style='text-align:center;'>";echo $me['nation']==0?"-":"{$general['cnt']}"; echo "</td>
|
||||
<td style='text-align:center;'>";
|
||||
echo $me['nation'] == 0 ? "-" : "{$general['cnt']}";
|
||||
echo "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='text-align:center;' class='bg1'><b>국 력</b></td>
|
||||
<td style='text-align:center;'>{$nation['power']}</td>
|
||||
<td style='text-align:center;' class='bg1'><b>기술력</b></td>
|
||||
<td style='text-align:center;'>";echo $me['nation']==0?"-":"{$nation['tech']}"; echo "</td>
|
||||
<td style='text-align:center;'>";
|
||||
echo $me['nation'] == 0 ? "-" : "{$nation['tech']}";
|
||||
echo "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='text-align:center;' class='bg1'><b>전 략</b></td>
|
||||
@@ -318,60 +359,55 @@ function myNationInfo() {
|
||||
";
|
||||
}
|
||||
|
||||
function checkSecretMaxPermission($penalty){
|
||||
function checkSecretMaxPermission($penalty)
|
||||
{
|
||||
$secretMax = 4;
|
||||
if($penalty['noTopSecret']??false){
|
||||
if ($penalty['noTopSecret'] ?? false) {
|
||||
$secretMax = 1;
|
||||
}
|
||||
else if($penalty['noChief']??false){
|
||||
} else if ($penalty['noChief'] ?? false) {
|
||||
$secretMax = 1;
|
||||
}
|
||||
else if($penalty['noAmbassador']??false){
|
||||
} else if ($penalty['noAmbassador'] ?? false) {
|
||||
$secretMax = 2;
|
||||
}
|
||||
return $secretMax;
|
||||
}
|
||||
|
||||
function checkSecretPermission(array $me, $checkSecretLimit=true){
|
||||
if(!key_exists('penalty', $me) || !key_exists('permission', $me)){
|
||||
trigger_error ('canAccessSecret() 함수에 필요한 인자가 부족');
|
||||
function checkSecretPermission(array $me, $checkSecretLimit = true)
|
||||
{
|
||||
if (!key_exists('penalty', $me) || !key_exists('permission', $me)) {
|
||||
trigger_error('canAccessSecret() 함수에 필요한 인자가 부족');
|
||||
}
|
||||
$penalty = Json::decode($me['penalty'])??[];
|
||||
$penalty = Json::decode($me['penalty']) ?? [];
|
||||
$permission = $me['permission'];
|
||||
|
||||
if(!$me['nation']){
|
||||
if (!$me['nation']) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if($me['officer_level'] == 0){
|
||||
if ($me['officer_level'] == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if($penalty['noSecret']??false){
|
||||
|
||||
if ($penalty['noSecret'] ?? false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$secretMin = 0;
|
||||
$secretMax = checkSecretMaxPermission($me, $penalty);
|
||||
|
||||
|
||||
if($me['officer_level'] == 12){
|
||||
|
||||
if ($me['officer_level'] == 12) {
|
||||
$secretMin = 4;
|
||||
}
|
||||
else if($me['permission'] == 'ambassador'){
|
||||
} else if ($me['permission'] == 'ambassador') {
|
||||
$secretMin = 4;
|
||||
}
|
||||
else if($me['permission'] == 'auditor'){
|
||||
} else if ($me['permission'] == 'auditor') {
|
||||
$secretMin = 3;
|
||||
}
|
||||
else if($me['officer_level'] >= 5){
|
||||
} else if ($me['officer_level'] >= 5) {
|
||||
$secretMin = 2;
|
||||
}
|
||||
else if($me['officer_level'] > 1){
|
||||
} else if ($me['officer_level'] > 1) {
|
||||
$secretMin = 1;
|
||||
}
|
||||
else if($checkSecretLimit){
|
||||
} else if ($checkSecretLimit) {
|
||||
$db = DB::db();
|
||||
$secretLimit = $db->queryFirstField('SELECT secretlimit FROM nation WHERE nation = %i', $me['nation']);
|
||||
if ($me['belong'] >= $secretLimit) {
|
||||
@@ -382,9 +418,10 @@ function checkSecretPermission(array $me, $checkSecretLimit=true){
|
||||
return min($secretMin, $secretMax);
|
||||
}
|
||||
|
||||
function addCommand($typename, $value, $valid = 1, $color=0) {
|
||||
if($valid == 1) {
|
||||
switch($color) {
|
||||
function addCommand($typename, $value, $valid = 1, $color = 0)
|
||||
{
|
||||
if ($valid == 1) {
|
||||
switch ($color) {
|
||||
case 0:
|
||||
echo "
|
||||
<option style='color:white;background-color:black;' value='{$value}'>{$typename}</option>";
|
||||
@@ -404,8 +441,9 @@ function addCommand($typename, $value, $valid = 1, $color=0) {
|
||||
}
|
||||
}
|
||||
|
||||
function commandGroup($typename, $type=0) {
|
||||
if($type == 0) {
|
||||
function commandGroup($typename, $type = 0)
|
||||
{
|
||||
if ($type == 0) {
|
||||
echo "
|
||||
<optgroup label='{$typename}' style='color:skyblue;background-color:black;'>";
|
||||
} else {
|
||||
@@ -414,7 +452,8 @@ function commandGroup($typename, $type=0) {
|
||||
}
|
||||
}
|
||||
|
||||
function printCommandTable(General $generalObj) {
|
||||
function printCommandTable(General $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$userID = Session::getUserID();
|
||||
@@ -423,50 +462,46 @@ function printCommandTable(General $generalObj) {
|
||||
$env = $gameStor->getAll();
|
||||
|
||||
?>
|
||||
<select id='generalCommandList' name='commandtype' size=1 style='height:20px;width:260px;color:white;background-color:black;font-size:12px;'>";
|
||||
<?php
|
||||
<select id='generalCommandList' name='commandtype' size=1 style='height:20px;width:260px;color:white;background-color:black;font-size:12px;'>";
|
||||
<?php
|
||||
|
||||
//보정(Pros,Cons) 여부.
|
||||
$getCompensateClassName = function($value){
|
||||
if($value > 0){
|
||||
return 'compensatePositive';
|
||||
}
|
||||
else if($value < 0){
|
||||
return 'compensateNegative';
|
||||
}
|
||||
return 'compensateNeutral';
|
||||
};
|
||||
//보정(Pros,Cons) 여부.
|
||||
$getCompensateClassName = function ($value) {
|
||||
if ($value > 0) {
|
||||
return 'compensatePositive';
|
||||
} else if ($value < 0) {
|
||||
return 'compensateNegative';
|
||||
}
|
||||
return 'compensateNeutral';
|
||||
};
|
||||
|
||||
foreach(GameConst::$availableGeneralCommand as $commandCategory => $commandList){
|
||||
if($commandCategory){
|
||||
commandGroup("======= {$commandCategory} =======");
|
||||
}
|
||||
foreach (GameConst::$availableGeneralCommand as $commandCategory => $commandList) {
|
||||
if ($commandCategory) {
|
||||
commandGroup("======= {$commandCategory} =======");
|
||||
}
|
||||
|
||||
foreach($commandList as $commandClassName){
|
||||
$commandObj = buildGeneralCommandClass($commandClassName, $generalObj, $env);
|
||||
if(!$commandObj->canDisplay()){
|
||||
continue;
|
||||
foreach ($commandList as $commandClassName) {
|
||||
$commandObj = buildGeneralCommandClass($commandClassName, $generalObj, $env);
|
||||
if (!$commandObj->canDisplay()) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option class='commandBasic <?= $getCompensateClassName($commandObj->getCompensationStyle()) ?> <?= $commandObj->hasMinConditionMet() ? '' : 'commandImpossible' ?>' value='<?= Util::getClassNameFromObj($commandObj) ?>' data-reqArg='<?= ($commandObj::$reqArg) ? 'true' : 'false' ?>'><?= $commandObj->getCommandDetailTitle() ?><?= $commandObj->hasMinConditionMet() ? '' : '(불가)' ?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ($commandCategory) {
|
||||
commandGroup('', 1);
|
||||
}
|
||||
?>
|
||||
<option
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->hasMinConditionMet()?'':'commandImpossible'?>'
|
||||
value='<?=Util::getClassNameFromObj($commandObj)?>'
|
||||
data-reqArg='<?=($commandObj::$reqArg)?'true':'false'?>'
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->hasMinConditionMet()?'':'(불가)'?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($commandCategory){
|
||||
commandGroup('', 1);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
function chiefCommandTable(General $generalObj) {
|
||||
function chiefCommandTable(General $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$userID = Session::getUserID();
|
||||
@@ -475,50 +510,46 @@ function chiefCommandTable(General $generalObj) {
|
||||
$env = $gameStor->getAll();
|
||||
|
||||
?>
|
||||
<select id='chiefCommandList' name='commandtype' size=1 style='height:20px;color:white;background-color:black;font-size:13px;display:inline-block;'>";
|
||||
<?php
|
||||
<select id='chiefCommandList' name='commandtype' size=1 style='height:20px;color:white;background-color:black;font-size:13px;display:inline-block;'>";
|
||||
<?php
|
||||
|
||||
//보정(Pros,Cons) 여부.
|
||||
$getCompensateClassName = function($value){
|
||||
if($value > 0){
|
||||
return 'compensatePositive';
|
||||
}
|
||||
else if($value < 0){
|
||||
return 'compensateNegative';
|
||||
}
|
||||
return 'compensateNeutral';
|
||||
};
|
||||
//보정(Pros,Cons) 여부.
|
||||
$getCompensateClassName = function ($value) {
|
||||
if ($value > 0) {
|
||||
return 'compensatePositive';
|
||||
} else if ($value < 0) {
|
||||
return 'compensateNegative';
|
||||
}
|
||||
return 'compensateNeutral';
|
||||
};
|
||||
|
||||
foreach(GameConst::$availableChiefCommand as $commandCategory => $commandList){
|
||||
if($commandCategory){
|
||||
commandGroup("======= {$commandCategory} =======");
|
||||
}
|
||||
foreach (GameConst::$availableChiefCommand as $commandCategory => $commandList) {
|
||||
if ($commandCategory) {
|
||||
commandGroup("======= {$commandCategory} =======");
|
||||
}
|
||||
|
||||
foreach($commandList as $commandClassName){
|
||||
$commandObj = buildNationCommandClass($commandClassName, $generalObj, $env, new LastTurn());
|
||||
if(!$commandObj->canDisplay()){
|
||||
continue;
|
||||
foreach ($commandList as $commandClassName) {
|
||||
$commandObj = buildNationCommandClass($commandClassName, $generalObj, $env, new LastTurn());
|
||||
if (!$commandObj->canDisplay()) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option class='commandBasic <?= $getCompensateClassName($commandObj->getCompensationStyle()) ?> <?= $commandObj->hasMinConditionMet() ? '' : 'commandImpossible' ?>' value='<?= Util::getClassNameFromObj($commandObj) ?>' data-reqArg='<?= ($commandObj::$reqArg) ? 'true' : 'false' ?>'><?= $commandObj->getCommandDetailTitle() ?><?= $commandObj->hasMinConditionMet() ? '' : '(불가)' ?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ($commandCategory) {
|
||||
commandGroup('', 1);
|
||||
}
|
||||
?>
|
||||
<option
|
||||
class='commandBasic <?=$getCompensateClassName($commandObj->getCompensationStyle())?> <?=$commandObj->hasMinConditionMet()?'':'commandImpossible'?>'
|
||||
value='<?=Util::getClassNameFromObj($commandObj)?>'
|
||||
data-reqArg='<?=($commandObj::$reqArg)?'true':'false'?>'
|
||||
><?=$commandObj->getCommandDetailTitle()?><?=$commandObj->hasMinConditionMet()?'':'(불가)'?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
if($commandCategory){
|
||||
commandGroup('', 1);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
function generalInfo(General $generalObj) {
|
||||
function generalInfo(General $generalObj)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -528,24 +559,22 @@ function generalInfo(General $generalObj) {
|
||||
$nation = getNationStaticInfo($generalObj->getNationID());
|
||||
|
||||
$lbonus = calcLeadershipBonus($generalObj->getVar('officer_level'), $nation['level']);
|
||||
if($lbonus > 0) {
|
||||
if ($lbonus > 0) {
|
||||
$lbonus = "<font color=cyan>+{$lbonus}</font>";
|
||||
} else {
|
||||
$lbonus = "";
|
||||
}
|
||||
|
||||
if($generalObj->getVar('troop') == 0){
|
||||
if ($generalObj->getVar('troop') == 0) {
|
||||
$troopInfo = '-';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$troopCity = $db->queryFirstField('SELECT city FROM general WHERE no=%i', $generalObj->getVar('troop'));
|
||||
$troopTurn = $db->queryFirstField('SELECT `brief` FROM general_turn WHERE general_id = %i AND turn_idx = 0', $generalObj->getVar('troop'));
|
||||
$troopInfo = $db->queryFirstField('SELECT name FROM troop WHERE troop_leader = %i', $generalObj->getVar('troop'));
|
||||
|
||||
if($troopTurn !== '집합'){
|
||||
|
||||
if ($troopTurn !== '집합') {
|
||||
$troopInfo = "<strike style='color:gray;'>{$troopInfo}</strike>";
|
||||
}
|
||||
else if($troopCity != $generalObj->getCityID()){
|
||||
} else if ($troopCity != $generalObj->getCityID()) {
|
||||
$troopCityName = CityConst::byID($troopCity)->name;
|
||||
$troopInfo = "<span style='color:orange;'>{$troopInfo}({$troopCityName})</span>";
|
||||
}
|
||||
@@ -554,7 +583,7 @@ function generalInfo(General $generalObj) {
|
||||
$officerLevel = $generalObj->getVar('officer_level');
|
||||
$officerLevelText = getOfficerLevelText($officerLevel, $nation['level']);
|
||||
|
||||
if(2 <= $officerLevel && $officerLevel <= 4){
|
||||
if (2 <= $officerLevel && $officerLevel <= 4) {
|
||||
$cityOfficerName = CityConst::byID($generalObj->getVar('officer_city'))->name;
|
||||
$officerLevelText = "{$cityOfficerName} {$officerLevelText}";
|
||||
}
|
||||
@@ -569,83 +598,97 @@ function generalInfo(General $generalObj) {
|
||||
$leadership = $generalObj->getLeadership(true, false, false);
|
||||
$strength = $generalObj->getStrength(true, false, false);
|
||||
$intel = $generalObj->getIntel(true, false, false);
|
||||
|
||||
|
||||
|
||||
|
||||
$injury = $generalObj->getVar('injury');
|
||||
if($injury > 60) { $color = "<font color=red>"; $injury = "위독"; }
|
||||
elseif($injury > 40) { $color = "<font color=magenta>"; $injury = "심각"; }
|
||||
elseif($injury > 20) { $color = "<font color=orange>"; $injury = "중상"; }
|
||||
elseif($injury > 0) { $color = "<font color=yellow>"; $injury = "경상"; }
|
||||
else { $color = "<font color=white>"; $injury = "건강"; }
|
||||
if ($injury > 60) {
|
||||
$color = "<font color=red>";
|
||||
$injury = "위독";
|
||||
} elseif ($injury > 40) {
|
||||
$color = "<font color=magenta>";
|
||||
$injury = "심각";
|
||||
} elseif ($injury > 20) {
|
||||
$color = "<font color=orange>";
|
||||
$injury = "중상";
|
||||
} elseif ($injury > 0) {
|
||||
$color = "<font color=yellow>";
|
||||
$injury = "경상";
|
||||
} else {
|
||||
$color = "<font color=white>";
|
||||
$injury = "건강";
|
||||
}
|
||||
|
||||
$remaining = (new \DateTimeImmutable($generalObj->getTurnTime()))->diff(new \DateTimeImmutable())->i;
|
||||
|
||||
if($nation['color'] == "") { $nation['color'] = "#000000"; }
|
||||
if ($nation['color'] == "") {
|
||||
$nation['color'] = "#000000";
|
||||
}
|
||||
|
||||
$age = $generalObj->getVar('age');
|
||||
if($age < GameConst::$retirementYear*0.75) {$age = "<font color=limegreen>{$age} 세</font>"; }
|
||||
elseif($age < GameConst::$retirementYear) { $age = "<font color=yellow>{$age} 세</font>"; }
|
||||
else { $age = "<font color=red>{$age} 세</font>"; }
|
||||
if ($age < GameConst::$retirementYear * 0.75) {
|
||||
$age = "<font color=limegreen>{$age} 세</font>";
|
||||
} elseif ($age < GameConst::$retirementYear) {
|
||||
$age = "<font color=yellow>{$age} 세</font>";
|
||||
} else {
|
||||
$age = "<font color=red>{$age} 세</font>";
|
||||
}
|
||||
|
||||
$connectCnt = round($generalObj->getVar('connect'), -1);
|
||||
$specialDomestic = $generalObj->getVar('special')===GameConst::$defaultSpecialDomestic
|
||||
?"{$generalObj->getVar('specage')}세"
|
||||
: "<font color=limegreen>".displayiActionObjInfo($generalObj->getSpecialDomestic())."</font>";
|
||||
$specialWar = $generalObj->getVar('special2')===GameConst::$defaultSpecialDomestic
|
||||
?"{$generalObj->getVar('specage2')}세"
|
||||
: "<font color=limegreen>".displayiActionObjInfo($generalObj->getSpecialWar())."</font>";
|
||||
$specialDomestic = $generalObj->getVar('special') === GameConst::$defaultSpecialDomestic
|
||||
? "{$generalObj->getVar('specage')}세"
|
||||
: "<font color=limegreen>" . displayiActionObjInfo($generalObj->getSpecialDomestic()) . "</font>";
|
||||
$specialWar = $generalObj->getVar('special2') === GameConst::$defaultSpecialDomestic
|
||||
? "{$generalObj->getVar('specage2')}세"
|
||||
: "<font color=limegreen>" . displayiActionObjInfo($generalObj->getSpecialWar()) . "</font>";
|
||||
|
||||
$atmos = $generalObj->getVar('atmos');
|
||||
$atmosBonus = $generalObj->onCalcStat($generalObj, 'bonusAtmos', $atmos) - $atmos;
|
||||
if($atmosBonus > 0){
|
||||
if ($atmosBonus > 0) {
|
||||
$atmos = "<font color=cyan>{$atmos} (+{$atmosBonus})</font>";
|
||||
}
|
||||
else if($atmosBonus < 0){
|
||||
} else if ($atmosBonus < 0) {
|
||||
$atmos = "<font color=magenta>{$atmos} ({$atmosBonus})</font>";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$atmos = "$atmos";
|
||||
}
|
||||
|
||||
$train = $generalObj->getVar('train');
|
||||
$trainBonus = $generalObj->onCalcStat($generalObj, 'bonusTrain', $train) - $train;
|
||||
if($trainBonus > 0){
|
||||
if ($trainBonus > 0) {
|
||||
$train = "<font color=cyan>{$train} (+{$trainBonus})</font>";
|
||||
}
|
||||
else if($trainBonus < 0){
|
||||
} else if ($trainBonus < 0) {
|
||||
$train = "<font color=magenta>{$train} ({$trainBonus})</font>";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$train = "$train";
|
||||
}
|
||||
|
||||
if($generalObj->getVar('defence_train') === 999){
|
||||
if ($generalObj->getVar('defence_train') === 999) {
|
||||
$defenceTrain = "<font color=red>수비 안함</font>";
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$defenceTrain = "<font color=limegreen>수비 함(훈사{$generalObj->getVar('defence_train')})</font>";
|
||||
}
|
||||
|
||||
$crewType = $generalObj->getCrewTypeObj();
|
||||
|
||||
$weapImage = ServConfig::$gameImagePath."/crewtype{$crewType->id}.png";
|
||||
if($show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; };
|
||||
$weapImage = ServConfig::$gameImagePath . "/crewtype{$crewType->id}.png";
|
||||
if ($show_img_level < 2) {
|
||||
$weapImage = ServConfig::$sharedIconPath . "/default.jpg";
|
||||
};
|
||||
$imagePath = GetImageURL(...$generalObj->getVars('imgsvr', 'picture'));
|
||||
echo "<table width=498 class='tb_layout bg2'>
|
||||
<tr>
|
||||
<td width=64 height=64 rowspan=3 class='generalIcon' style='text-align:center;background:no-repeat center url(\"{$imagePath}\");background-size:64px;'> </td>
|
||||
<td colspan=9 height=16 style=text-align:center;color:".newColor($nation['color']).";background-color:{$nation['color']};font-weight:bold;font-size:13px;>{$generalObj->getName()} 【 {$officerLevelText} | {$call} | {$color}{$injury}</font> 】 ".$generalObj->getTurnTime($generalObj::TURNTIME_HMS)."</td>
|
||||
<td colspan=9 height=16 style=text-align:center;color:" . newColor($nation['color']) . ";background-color:{$nation['color']};font-weight:bold;font-size:13px;>{$generalObj->getName()} 【 {$officerLevelText} | {$call} | {$color}{$injury}</font> 】 " . $generalObj->getTurnTime($generalObj::TURNTIME_HMS) . "</td>
|
||||
</tr>
|
||||
<tr height=16>
|
||||
<td style='text-align:center;' class='bg1'><b>통솔</b></td>
|
||||
<td style='text-align:center;'> {$color}{$leadership}</font>{$lbonus} </td>
|
||||
<td style='text-align:center;' width=45>".bar(expStatus($generalObj->getVar('leadership_exp')), 20)."</td>
|
||||
<td style='text-align:center;' width=45>" . bar(expStatus($generalObj->getVar('leadership_exp')), 20) . "</td>
|
||||
<td style='text-align:center;' class='bg1'><b>무력</b></td>
|
||||
<td style='text-align:center;'> {$color}{$strength}</font> </td>
|
||||
<td style='text-align:center;' width=45>".bar(expStatus($generalObj->getVar('strength_exp')), 20)."</td>
|
||||
<td style='text-align:center;' width=45>" . bar(expStatus($generalObj->getVar('strength_exp')), 20) . "</td>
|
||||
<td style='text-align:center;' class='bg1'><b>지력</b></td>
|
||||
<td style='text-align:center;'> {$color}{$intel}</font> </td>
|
||||
<td style='text-align:center;' width=45>".bar(expStatus($generalObj->getVar('intel_exp')), 20)."</td>
|
||||
<td style='text-align:center;' width=45>" . bar(expStatus($generalObj->getVar('intel_exp')), 20) . "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='text-align:center;' class='bg1'><b>명마</b></td>
|
||||
@@ -670,7 +713,7 @@ function generalInfo(General $generalObj) {
|
||||
<td style='text-align:center;' class='bg1'><b>병사</b></td>
|
||||
<td style='text-align:center;' colspan=2>{$generalObj->getVar('crew')}</td>
|
||||
<td style='text-align:center;' class='bg1'><b>성격</b></td>
|
||||
<td style='text-align:center;' colspan=2>".displayiActionObjInfo($generalObj->getPersonality())."</td>
|
||||
<td style='text-align:center;' colspan=2>" . displayiActionObjInfo($generalObj->getPersonality()) . "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style='text-align:center;' class='bg1'><b>훈련</b></td>
|
||||
@@ -683,7 +726,7 @@ function generalInfo(General $generalObj) {
|
||||
<tr height=20>
|
||||
<td style='text-align:center;' class='bg1'><b>Lv</b></td>
|
||||
<td style='text-align:center;'> {$generalObj->getVar('explevel')} </td>
|
||||
<td style='text-align:center;' colspan=5>".bar(getLevelPer(...$generalObj->getVars('experience', 'explevel')), 20)."</td>
|
||||
<td style='text-align:center;' colspan=5>" . bar(getLevelPer(...$generalObj->getVars('experience', 'explevel')), 20) . "</td>
|
||||
<td style='text-align:center;' class='bg1'><b>연령</b></td>
|
||||
<td style='text-align:center;' colspan=2>{$age}</td>
|
||||
</tr>
|
||||
@@ -699,37 +742,34 @@ function generalInfo(General $generalObj) {
|
||||
<td style='text-align:center;' class='bg1'><b>부대</b></td>
|
||||
<td style='text-align:center;' colspan=3>{$troopInfo}</td>
|
||||
<td style='text-align:center;' class='bg1'><b>벌점</b></td>
|
||||
<td style='text-align:center;' colspan=5>".getConnect($connectCnt)." {$connectCnt}({$generalObj->getVar('con')})</td>
|
||||
<td style='text-align:center;' colspan=5>" . getConnect($connectCnt) . " {$connectCnt}({$generalObj->getVar('con')})</td>
|
||||
</tr>
|
||||
</table>";
|
||||
}
|
||||
|
||||
function generalInfo2(General $generalObj) {
|
||||
function generalInfo2(General $generalObj)
|
||||
{
|
||||
$general = $generalObj->getRaw();
|
||||
|
||||
$winRate = round($generalObj->getRankVar('killnum')/max($generalObj->getRankVar('warnum'),1)*100, 2);
|
||||
$killRate = round($generalObj->getRankVar('killcrew')/max($generalObj->getRankVar('deathcrew'),1)*100, 2);
|
||||
$winRate = round($generalObj->getRankVar('killnum') / max($generalObj->getRankVar('warnum'), 1) * 100, 2);
|
||||
$killRate = round($generalObj->getRankVar('killcrew') / max($generalObj->getRankVar('deathcrew'), 1) * 100, 2);
|
||||
|
||||
$experienceBonus = $generalObj->onCalcStat($generalObj, 'experience', 10000) - 10000;
|
||||
if($experienceBonus > 0){
|
||||
$experience = "<font color=cyan>".getHonor($general['experience'])." ({$general['experience']})</font>";
|
||||
}
|
||||
else if($experienceBonus < 0){
|
||||
$experience = "<font color=magenta>".getHonor($general['experience'])." ({$general['experience']})</font>";
|
||||
}
|
||||
else{
|
||||
$experience = getHonor($general['experience'])." ({$general['experience']})";
|
||||
if ($experienceBonus > 0) {
|
||||
$experience = "<font color=cyan>" . getHonor($general['experience']) . " ({$general['experience']})</font>";
|
||||
} else if ($experienceBonus < 0) {
|
||||
$experience = "<font color=magenta>" . getHonor($general['experience']) . " ({$general['experience']})</font>";
|
||||
} else {
|
||||
$experience = getHonor($general['experience']) . " ({$general['experience']})";
|
||||
}
|
||||
|
||||
$dedicationBonus = $generalObj->onCalcStat($generalObj, 'dedication', 10000) - 10000;
|
||||
if($dedicationBonus > 0){
|
||||
$dedication = "<font color=cyan>".getHonor($general['dedication'])." ({$general['dedication']})</font>";
|
||||
}
|
||||
else if($dedicationBonus < 0){
|
||||
$dedication = "<font color=magenta>".getHonor($general['dedication'])." ({$general['dedication']})</font>";
|
||||
}
|
||||
else{
|
||||
$dedication = getHonor($general['dedication'])." ({$general['dedication']})";
|
||||
if ($dedicationBonus > 0) {
|
||||
$dedication = "<font color=cyan>" . getHonor($general['dedication']) . " ({$general['dedication']})</font>";
|
||||
} else if ($dedicationBonus < 0) {
|
||||
$dedication = "<font color=magenta>" . getHonor($general['dedication']) . " ({$general['dedication']})</font>";
|
||||
} else {
|
||||
$dedication = getHonor($general['dedication']) . " ({$general['dedication']})";
|
||||
}
|
||||
|
||||
$dex1 = $general['dex1'] / GameConst::$dexLimit * 100;
|
||||
@@ -738,11 +778,21 @@ function generalInfo2(General $generalObj) {
|
||||
$dex4 = $general['dex4'] / GameConst::$dexLimit * 100;
|
||||
$dex5 = $general['dex5'] / GameConst::$dexLimit * 100;
|
||||
|
||||
if($dex1 > 100) { $dex1 = 100; }
|
||||
if($dex2 > 100) { $dex2 = 100; }
|
||||
if($dex3 > 100) { $dex3 = 100; }
|
||||
if($dex4 > 100) { $dex4 = 100; }
|
||||
if($dex5 > 100) { $dex5 = 100; }
|
||||
if ($dex1 > 100) {
|
||||
$dex1 = 100;
|
||||
}
|
||||
if ($dex2 > 100) {
|
||||
$dex2 = 100;
|
||||
}
|
||||
if ($dex3 > 100) {
|
||||
$dex3 = 100;
|
||||
}
|
||||
if ($dex4 > 100) {
|
||||
$dex4 = 100;
|
||||
}
|
||||
if ($dex5 > 100) {
|
||||
$dex5 = 100;
|
||||
}
|
||||
|
||||
$general['dex1_text'] = getDexCall($general['dex1']);
|
||||
$general['dex2_text'] = getDexCall($general['dex2']);
|
||||
@@ -750,11 +800,11 @@ function generalInfo2(General $generalObj) {
|
||||
$general['dex4_text'] = getDexCall($general['dex4']);
|
||||
$general['dex5_text'] = getDexCall($general['dex5']);
|
||||
|
||||
$general['dex1_short'] = sprintf('%.1fK', $general['dex1']/1000);
|
||||
$general['dex2_short'] = sprintf('%.1fK', $general['dex2']/1000);
|
||||
$general['dex3_short'] = sprintf('%.1fK', $general['dex3']/1000);
|
||||
$general['dex4_short'] = sprintf('%.1fK', $general['dex4']/1000);
|
||||
$general['dex5_short'] = sprintf('%.1fK', $general['dex5']/1000);
|
||||
$general['dex1_short'] = sprintf('%.1fK', $general['dex1'] / 1000);
|
||||
$general['dex2_short'] = sprintf('%.1fK', $general['dex2'] / 1000);
|
||||
$general['dex3_short'] = sprintf('%.1fK', $general['dex3'] / 1000);
|
||||
$general['dex4_short'] = sprintf('%.1fK', $general['dex4'] / 1000);
|
||||
$general['dex5_short'] = sprintf('%.1fK', $general['dex5'] / 1000);
|
||||
|
||||
echo "<table width=498 class='tb_layout bg2'>
|
||||
<tr><td style='text-align:center;' colspan=6 class='bg1'><b>추 가 정 보</b></td></tr>
|
||||
@@ -795,96 +845,104 @@ function generalInfo2(General $generalObj) {
|
||||
<td width=64 style='text-align:center;' class='bg1'><b>보병</b></td>
|
||||
<td width=40> {$general['dex1_text']}</td>
|
||||
<td width=60 align=right>{$general['dex1_short']} </td>
|
||||
<td width=330 style='text-align:center;'>".bar($dex1, 16)."</td>
|
||||
<td width=330 style='text-align:center;'>" . bar($dex1, 16) . "</td>
|
||||
</tr>
|
||||
<tr height=16>
|
||||
<td style='text-align:center;' class='bg1'><b>궁병</b></td>
|
||||
<td> {$general['dex2_text']}</td>
|
||||
<td align=right>{$general['dex2_short']} </td>
|
||||
<td style='text-align:center;'>".bar($dex2, 16)."</td>
|
||||
<td style='text-align:center;'>" . bar($dex2, 16) . "</td>
|
||||
</tr>
|
||||
<tr height=16>
|
||||
<td style='text-align:center;' class='bg1'><b>기병</b></td>
|
||||
<td> {$general['dex3_text']}</td>
|
||||
<td align=right>{$general['dex3_short']} </td>
|
||||
<td style='text-align:center;'>".bar($dex3, 16)."</td>
|
||||
<td style='text-align:center;'>" . bar($dex3, 16) . "</td>
|
||||
</tr>
|
||||
<tr height=16>
|
||||
<td style='text-align:center;' class='bg1'><b>귀병</b></td>
|
||||
<td> {$general['dex4_text']}</td>
|
||||
<td align=right>{$general['dex4_short']} </td>
|
||||
<td style='text-align:center;'>".bar($dex4, 16)."</td>
|
||||
<td style='text-align:center;'>" . bar($dex4, 16) . "</td>
|
||||
</tr>
|
||||
<tr height=16>
|
||||
<td style='text-align:center;' class='bg1'><b>차병</b></td>
|
||||
<td> {$general['dex5_text']}</td>
|
||||
<td align=right>{$general['dex5_short']} </td>
|
||||
<td style='text-align:center;'>".bar($dex5, 16)."</td>
|
||||
<td style='text-align:center;'>" . bar($dex5, 16) . "</td>
|
||||
</tr>
|
||||
</table>";
|
||||
}
|
||||
|
||||
function getOnlineNum() {
|
||||
function getOnlineNum()
|
||||
{
|
||||
return KVStorage::getStorage(DB::db(), 'game_env')->online;
|
||||
}
|
||||
|
||||
function onlinegen() {
|
||||
function onlinegen()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$onlinegen = "";
|
||||
$generalID = Session::getInstance()->generalID;
|
||||
$nationID = DB::db()->queryFirstField('select `nation` from `general` where `no` = %i', $generalID);
|
||||
if($nationID === null || Util::toInt($nationID) === 0) {
|
||||
if ($nationID === null || Util::toInt($nationID) === 0) {
|
||||
$onlinegen = $gameStor->onlinegen;
|
||||
} else {
|
||||
$onlinegen = DB::db()->queryFirstField('select onlinegen from nation where nation=%i',$nationID);
|
||||
$onlinegen = DB::db()->queryFirstField('select onlinegen from nation where nation=%i', $nationID);
|
||||
}
|
||||
return $onlinegen;
|
||||
}
|
||||
|
||||
function nationMsg(General $general) {
|
||||
function nationMsg(General $general)
|
||||
{
|
||||
$db = DB::db();
|
||||
$msg = $db->queryFirstField(
|
||||
'SELECT msg FROM nation WHERE nation = %i',
|
||||
$general->getNationID()
|
||||
);
|
||||
|
||||
return $msg?:'';
|
||||
return $msg ?: '';
|
||||
}
|
||||
|
||||
function banner() {
|
||||
function banner()
|
||||
{
|
||||
|
||||
return sprintf(
|
||||
'<font size=2>%s %s / %s</font>',
|
||||
GameConst::$title,
|
||||
VersionGit::$version,
|
||||
GameConst::$banner);
|
||||
GameConst::$banner
|
||||
);
|
||||
}
|
||||
|
||||
function addTurn($date, int $turnterm, int $turn=1, bool $withFraction=true) {
|
||||
function addTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
|
||||
{
|
||||
$date = new \DateTime($date);
|
||||
$target = $turnterm*$turn;
|
||||
$target = $turnterm * $turn;
|
||||
$date->add(new \DateInterval("PT{$target}M"));
|
||||
if($withFraction){
|
||||
if ($withFraction) {
|
||||
return $date->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
function subTurn($date, int $turnterm, int $turn=1, bool $withFraction=true) {
|
||||
function subTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
|
||||
{
|
||||
$date = new \DateTime($date);
|
||||
$target = $turnterm*$turn;
|
||||
$target = $turnterm * $turn;
|
||||
$date->sub(new \DateInterval("PT{$target}M"));
|
||||
if($withFraction){
|
||||
if ($withFraction) {
|
||||
return $date->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
function cutTurn($date, int $turnterm, bool $withFraction=true) {
|
||||
function cutTurn($date, int $turnterm, bool $withFraction = true)
|
||||
{
|
||||
$date = new \DateTime($date);
|
||||
|
||||
|
||||
$baseDate = new \DateTime($date->format('Y-m-d'));
|
||||
$baseDate->sub(new \DateInterval("P1D"));
|
||||
$baseDate->add(new \DateInterval("PT1H"));
|
||||
@@ -893,16 +951,16 @@ function cutTurn($date, int $turnterm, bool $withFraction=true) {
|
||||
$diffMin -= $diffMin % $turnterm;
|
||||
|
||||
$baseDate->add(new \DateInterval("PT{$diffMin}M"));
|
||||
if($withFraction){
|
||||
if ($withFraction) {
|
||||
return $baseDate->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
return $baseDate->format('Y-m-d H:i:s');
|
||||
|
||||
}
|
||||
|
||||
function cutDay($date, int $turnterm, bool $withFraction=true) {
|
||||
function cutDay($date, int $turnterm, bool $withFraction = true)
|
||||
{
|
||||
$date = new \DateTime($date);
|
||||
|
||||
|
||||
$baseDate = new \DateTime($date->format('Y-m-d'));
|
||||
$baseDate->sub(new \DateInterval("P1D"));
|
||||
$baseDate->add(new \DateInterval("PT1H"));
|
||||
@@ -915,24 +973,24 @@ function cutDay($date, int $turnterm, bool $withFraction=true) {
|
||||
$newMonth = intdiv($timeAdjust, $turnterm) + 1;
|
||||
|
||||
$yearPulled = false;
|
||||
if($newMonth > 3){//3월 이후일때는
|
||||
if ($newMonth > 3) { //3월 이후일때는
|
||||
$yearPulled = true;
|
||||
$diffMin += $baseGap;
|
||||
}
|
||||
$diffMin -= $timeAdjust;
|
||||
|
||||
$baseDate->add(new \DateInterval("PT{$diffMin}M"));
|
||||
if($withFraction){
|
||||
if ($withFraction) {
|
||||
$dateTimeString = $baseDate->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$dateTimeString = $baseDate->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
|
||||
return [$dateTimeString, $yearPulled, $newMonth];
|
||||
}
|
||||
|
||||
function increaseRefresh($type="", $cnt=1) {
|
||||
function increaseRefresh($type = "", $cnt = 1)
|
||||
{
|
||||
//FIXME: 로그인, 비로그인 시 처리가 명확하지 않음
|
||||
$session = Session::getInstance();
|
||||
$userID = $session->userID;
|
||||
@@ -943,16 +1001,16 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$gameStor->refresh = $gameStor->refresh+$cnt; //TODO: +로 증가하는 값은 별도로 분리
|
||||
$gameStor->refresh = $gameStor->refresh + $cnt; //TODO: +로 증가하는 값은 별도로 분리
|
||||
$isunited = $gameStor->isunited;
|
||||
|
||||
if($isunited != 2 && $generalID && $userGrade < 6) {
|
||||
if ($isunited != 2 && $generalID && $userGrade < 6) {
|
||||
$db->update('general', [
|
||||
'lastrefresh'=>$date,
|
||||
'con'=>$db->sqleval('con + %i', $cnt),
|
||||
'connect'=>$db->sqleval('connect + %i', $cnt),
|
||||
'refcnt'=>$db->sqleval('refcnt + %i', $cnt),
|
||||
'refresh'=>$db->sqleval('refresh + %i', $cnt)
|
||||
'lastrefresh' => $date,
|
||||
'con' => $db->sqleval('con + %i', $cnt),
|
||||
'connect' => $db->sqleval('connect + %i', $cnt),
|
||||
'refcnt' => $db->sqleval('refcnt + %i', $cnt),
|
||||
'refresh' => $db->sqleval('refresh + %i', $cnt)
|
||||
], 'owner=%i', $userID);
|
||||
}
|
||||
|
||||
@@ -960,7 +1018,7 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
$date2 = substr($date, 0, 10);
|
||||
$online = getOnlineNum();
|
||||
file_put_contents(
|
||||
__DIR__."/logs/".UniqueConst::$serverID."/_{$date2}_refresh.txt",
|
||||
__DIR__ . "/logs/" . UniqueConst::$serverID . "/_{$date2}_refresh.txt",
|
||||
sprintf(
|
||||
"%s, %s, %s, %s, %s, %d\n",
|
||||
$date,
|
||||
@@ -992,12 +1050,12 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
);
|
||||
|
||||
$str = "";
|
||||
foreach($proxy_headers as $x) {
|
||||
if(isset($_SERVER[$x])) $str .= "//{$x}:{$_SERVER[$x]}";
|
||||
foreach ($proxy_headers as $x) {
|
||||
if (isset($_SERVER[$x])) $str .= "//{$x}:{$_SERVER[$x]}";
|
||||
}
|
||||
if($str != "") {
|
||||
if ($str != "") {
|
||||
file_put_contents(
|
||||
__DIR__."/logs/".UniqueConst::$serverID."/_{$date2}_ipcheck.txt",
|
||||
__DIR__ . "/logs/" . UniqueConst::$serverID . "/_{$date2}_ipcheck.txt",
|
||||
sprintf(
|
||||
"%s, %s, %s%s\n",
|
||||
$session->userName,
|
||||
@@ -1005,46 +1063,51 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
$_SERVER['REMOTE_ADDR'],
|
||||
$str
|
||||
),
|
||||
FILE_APPEND);
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function updateTraffic() {
|
||||
function updateTraffic()
|
||||
{
|
||||
$online = getOnlineNum();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$admin = $gameStor->getValues(['year','month','refresh','maxonline','maxrefresh']);
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
|
||||
|
||||
//최다갱신자
|
||||
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
|
||||
|
||||
if($admin['maxrefresh'] < $admin['refresh']) {
|
||||
if ($admin['maxrefresh'] < $admin['refresh']) {
|
||||
$admin['maxrefresh'] = $admin['refresh'];
|
||||
}
|
||||
if($admin['maxonline'] < $online) {
|
||||
if ($admin['maxonline'] < $online) {
|
||||
$admin['maxonline'] = $online;
|
||||
}
|
||||
$gameStor->refresh = 0;
|
||||
$gameStor->maxrefresh = $admin['maxrefresh'];
|
||||
$gameStor->maxonline = $admin['maxonline'];
|
||||
|
||||
$db->update('general', ['refresh'=>0], true);
|
||||
$db->update('general', ['refresh' => 0], true);
|
||||
|
||||
$date = TimeUtil::now();
|
||||
//일시|년|월|총갱신|접속자|최다갱신자
|
||||
file_put_contents(__DIR__."/logs/".UniqueConst::$serverID."/_traffic.txt",
|
||||
file_put_contents(
|
||||
__DIR__ . "/logs/" . UniqueConst::$serverID . "/_traffic.txt",
|
||||
Json::encode([
|
||||
$date,
|
||||
$admin['year'],
|
||||
$admin['month'],
|
||||
$admin['refresh'],
|
||||
$online,
|
||||
$user['name']."(".$user['refresh'].")"
|
||||
])."\n"
|
||||
, FILE_APPEND);
|
||||
$user['name'] . "(" . $user['refresh'] . ")"
|
||||
]) . "\n",
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
function CheckOverhead() {
|
||||
function CheckOverhead()
|
||||
{
|
||||
//서버정보
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
@@ -1053,39 +1116,43 @@ function CheckOverhead() {
|
||||
$con = Util::round(pow($turnterm, 0.6) * 3) * 10;
|
||||
|
||||
|
||||
if($con != $conlimit){
|
||||
if ($con != $conlimit) {
|
||||
$gameStor->conlimit = $con;
|
||||
}
|
||||
}
|
||||
|
||||
function isLock() {
|
||||
function isLock()
|
||||
{
|
||||
return DB::db()->queryFirstField("SELECT plock from plock limit 1") != 0;
|
||||
}
|
||||
|
||||
function tryLock():bool{
|
||||
function tryLock(): bool
|
||||
{
|
||||
//NOTE: 게임 로직과 관련한 모든 insert, update 함수들은 lock을 거칠것을 권장함.
|
||||
$db = DB::db();
|
||||
|
||||
// 잠금
|
||||
$db->update('plock', [
|
||||
'plock'=>1,
|
||||
'locktime'=>TimeUtil::now(true)
|
||||
'plock' => 1,
|
||||
'locktime' => TimeUtil::now(true)
|
||||
], 'plock=0');
|
||||
|
||||
return $db->affectedRows() > 0;
|
||||
}
|
||||
|
||||
function unlock():bool{
|
||||
function unlock(): bool
|
||||
{
|
||||
// 풀림
|
||||
$db = DB::db();
|
||||
$db->update('plock', [
|
||||
'plock'=>0
|
||||
'plock' => 0
|
||||
], true);
|
||||
|
||||
return $db->affectedRows() > 0;
|
||||
}
|
||||
|
||||
function timeover():bool {
|
||||
function timeover(): bool
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -1095,11 +1162,15 @@ function timeover():bool {
|
||||
$t = min($turnterm, 5);
|
||||
|
||||
$term = $diff;
|
||||
if($term >= $t || $term < 0) { return true; }
|
||||
else { return false; }
|
||||
if ($term >= $t || $term < 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkDelay() {
|
||||
function checkDelay()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -1107,21 +1178,19 @@ function checkDelay() {
|
||||
$now = new \DateTimeImmutable();
|
||||
$turntime = new \DateTimeImmutable($gameStor->turntime);
|
||||
$timeMinDiff = intdiv($now->getTimestamp() - $turntime->getTimestamp(), 60);
|
||||
|
||||
|
||||
// 1턴이상 갱신 없었으면 서버 지연
|
||||
$term = $gameStor->turnterm;
|
||||
if($term >= 20){
|
||||
if ($term >= 20) {
|
||||
$threshold = 1;
|
||||
}
|
||||
else if($term >= 10){
|
||||
} else if ($term >= 10) {
|
||||
$threshold = 3;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$threshold = 6;
|
||||
}
|
||||
//지연 해야할 밀린 턴 횟수
|
||||
$iter = intdiv($timeMinDiff, $term);
|
||||
if($iter > $threshold) {
|
||||
if ($iter > $threshold) {
|
||||
$minute = $iter * $term;
|
||||
$newTurntime = $turntime->add(new \DateInterval("PT{$minute}M"));
|
||||
$newNextTurntime = $turntime->add(new \DateInterval("PT{$term}M"));
|
||||
@@ -1131,85 +1200,87 @@ function checkDelay() {
|
||||
->format('Y-m-d H:i:s');
|
||||
|
||||
$db->update('general', [
|
||||
'turntime'=> $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
'turntime' => $db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
|
||||
], 'turntime<=DATE_ADD(turntime, INTERVAL %i MINUTE)', $term);
|
||||
$db->update('auction', [
|
||||
'expire'=> $db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
|
||||
'expire' => $db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
|
||||
], true);
|
||||
}
|
||||
}
|
||||
|
||||
function updateOnline() {
|
||||
function updateOnline()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
$nationname = ["재야"];
|
||||
|
||||
//국가별 이름 매핑
|
||||
foreach(getAllNationStaticInfo() as $nation) {
|
||||
foreach (getAllNationStaticInfo() as $nation) {
|
||||
$nationname[$nation['nation']] = $nation['name'];
|
||||
}
|
||||
|
||||
|
||||
//동접수
|
||||
$query = "select no,name,nation from general where lastrefresh > DATE_SUB(NOW(), INTERVAL 5 MINUTE)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$onlinenum = MYDB_num_rows($result);
|
||||
|
||||
$onnation = array();
|
||||
$onnationstr = "";
|
||||
|
||||
$onnation = array();
|
||||
$onnationstr = "";
|
||||
|
||||
//국가별 접속중인 장수
|
||||
for($i=0; $i < $onlinenum; $i++) {
|
||||
for ($i = 0; $i < $onlinenum; $i++) {
|
||||
$general = MYDB_fetch_array($result);
|
||||
if(isset($onnation[$general['nation']])){
|
||||
$onnation[$general['nation']] .= $general['name'].', ';
|
||||
}else {
|
||||
$onnation[$general['nation']] = $general['name'].', ';
|
||||
if (isset($onnation[$general['nation']])) {
|
||||
$onnation[$general['nation']] .= $general['name'] . ', ';
|
||||
} else {
|
||||
$onnation[$general['nation']] = $general['name'] . ', ';
|
||||
}
|
||||
}
|
||||
|
||||
//$onnation이 empty라면 굳이 foreach를 수행 할 이유가 없음.
|
||||
if(!empty($onnation)){
|
||||
foreach($onnation as $key => $val) {
|
||||
$onnationstr .= "【{$nationname[$key]}】, ";
|
||||
|
||||
if($key == 0) {
|
||||
|
||||
//$onnation이 empty라면 굳이 foreach를 수행 할 이유가 없음.
|
||||
if (!empty($onnation)) {
|
||||
foreach ($onnation as $key => $val) {
|
||||
$onnationstr .= "【{$nationname[$key]}】, ";
|
||||
|
||||
if ($key == 0) {
|
||||
$gameStor->onlinegen = $onnation[0];
|
||||
} else {
|
||||
$query = "update nation set onlinegen='$onnation[$key]' where nation='$key'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$query = "update nation set onlinegen='$onnation[$key]' where nation='$key'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//접속중인 국가
|
||||
$gameStor->online = $onlinenum;
|
||||
$gameStor->onlinenation = $onnationstr;
|
||||
}
|
||||
|
||||
function addAge() {
|
||||
function addAge()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
|
||||
//나이와 호봉 증가
|
||||
$db->update('general', [
|
||||
'age'=>$db->sqleval('age+1'),
|
||||
'belong'=>$db->sqleval('belong+1')
|
||||
'age' => $db->sqleval('age+1'),
|
||||
'belong' => $db->sqleval('belong+1')
|
||||
], true);
|
||||
|
||||
[$startYear, $year, $month] = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
|
||||
|
||||
if($year >= $startYear+3) {
|
||||
foreach($db->query('SELECT no,name,nation,leadership,strength,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general){
|
||||
if ($year >= $startYear + 3) {
|
||||
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel from general where specage<=age and special=%s', GameConst::$defaultSpecialDomestic) as $general) {
|
||||
$generalID = $general['no'];
|
||||
$special = SpecialityHelper::pickSpecialDomestic($general);
|
||||
$specialClass = buildGeneralSpecialDomesticClass($special);
|
||||
$specialText = $specialClass->getName();
|
||||
$db->update('general', [
|
||||
'special'=>$special
|
||||
], 'no=%i',$generalID);
|
||||
'special' => $special
|
||||
], 'no=%i', $generalID);
|
||||
|
||||
$logger = new ActionLogger($generalID, $general['nation'], $year, $month);
|
||||
|
||||
@@ -1218,15 +1289,15 @@ function addAge() {
|
||||
$logger->pushGeneralHistoryLog("특기 【<b><C>{$specialText}</></b>】{$josaUl} 습득");
|
||||
}
|
||||
|
||||
foreach($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5 from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general){
|
||||
foreach ($db->query('SELECT no,name,nation,leadership,strength,intel,npc,dex1,dex2,dex3,dex4,dex5 from general where specage2<=age and special2=%s', GameConst::$defaultSpecialWar) as $general) {
|
||||
$generalID = $general['no'];
|
||||
$special2 = SpecialityHelper::pickSpecialWar($general);
|
||||
$specialClass = buildGeneralSpecialWarClass($special2);
|
||||
$specialText = $specialClass->getName();
|
||||
|
||||
$db->update('general', [
|
||||
'special2'=>$special2
|
||||
], 'no=%i',$general['no']);
|
||||
'special2' => $special2
|
||||
], 'no=%i', $general['no']);
|
||||
|
||||
$logger = new ActionLogger($generalID, $general['nation'], $year, $month);
|
||||
|
||||
@@ -1237,7 +1308,8 @@ function addAge() {
|
||||
}
|
||||
}
|
||||
|
||||
function turnDate($curtime) {
|
||||
function turnDate($curtime)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$admin = $gameStor->getValues(['startyear', 'starttime', 'turnterm', 'year', 'month']);
|
||||
@@ -1245,17 +1317,17 @@ function turnDate($curtime) {
|
||||
$turn = $admin['starttime'];
|
||||
$curturn = cutTurn($curtime, $admin['turnterm']);
|
||||
$term = $admin['turnterm'];
|
||||
|
||||
$num = intdiv((strtotime($curturn) - strtotime($turn)), $term*60);
|
||||
|
||||
$num = intdiv((strtotime($curturn) - strtotime($turn)), $term * 60);
|
||||
|
||||
$date = $admin['startyear'] * 12;
|
||||
$date += $num;
|
||||
|
||||
|
||||
$year = intdiv($date, 12);
|
||||
$month = 1 + $date % 12;
|
||||
$month = 1 + $date % 12;
|
||||
|
||||
// 바뀐 경우만 업데이트
|
||||
if($admin['month'] != $month || $admin['year'] != $year) {
|
||||
if ($admin['month'] != $month || $admin['year'] != $year) {
|
||||
$gameStor->year = $year;
|
||||
$gameStor->month = $month;
|
||||
}
|
||||
@@ -1264,22 +1336,26 @@ function turnDate($curtime) {
|
||||
}
|
||||
|
||||
|
||||
function triggerTournament() {
|
||||
function triggerTournament()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$admin = $gameStor->getValues(['tournament', 'tnmt_trig']);
|
||||
|
||||
//현재 토너먼트 없고, 자동개시 걸려있을때, 40%확률
|
||||
if($admin['tournament'] == 0 && $admin['tnmt_trig'] > 0 && rand() % 100 < 40) {
|
||||
if ($admin['tournament'] == 0 && $admin['tnmt_trig'] > 0 && rand() % 100 < 40) {
|
||||
$type = rand() % 5; // 0 : 전력전, 1 : 통솔전, 2 : 일기토, 3 : 설전
|
||||
//전력전 40%, 통, 일, 설 각 20%
|
||||
if($type > 3) { $type = 0; }
|
||||
if ($type > 3) {
|
||||
$type = 0;
|
||||
}
|
||||
startTournament($admin['tnmt_trig'], $type);
|
||||
}
|
||||
}
|
||||
|
||||
function CheckHall($no) {
|
||||
function CheckHall($no)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -1305,7 +1381,7 @@ function CheckHall($no) {
|
||||
["betwin", 'rank'],
|
||||
["betwingold", 'rank'],
|
||||
["betrate", 'calc'],
|
||||
];//XXX: 순서가 DB에 박혀있다 ㅜㅜ
|
||||
]; //XXX: 순서가 DB에 박혀있다 ㅜㅜ
|
||||
|
||||
$generalObj = General::createGeneralObjFromDB($no, null, 2);
|
||||
|
||||
@@ -1316,39 +1392,39 @@ function CheckHall($no) {
|
||||
$tlw = $generalObj->getRankVar('tlw');
|
||||
$tld = $generalObj->getRankVar('tld');
|
||||
$tll = $generalObj->getRankVar('tll');
|
||||
|
||||
|
||||
$tsw = $generalObj->getRankVar('tsw');
|
||||
$tsd = $generalObj->getRankVar('tsd');
|
||||
$tsl = $generalObj->getRankVar('tsl');
|
||||
|
||||
|
||||
$tiw = $generalObj->getRankVar('tiw');
|
||||
$tid = $generalObj->getRankVar('tid');
|
||||
$til = $generalObj->getRankVar('til');
|
||||
|
||||
$betWinGold = $generalObj->getRankVar('betwingold');
|
||||
$betGold = Util::valueFit($generalObj->getRankVar('betgold'), 1);
|
||||
|
||||
|
||||
$win = $generalObj->getRankVar('killnum');
|
||||
$war = Util::valueFit($generalObj->getRankVar('warnum'), 1);
|
||||
|
||||
$kill = $generalObj->getRankVar('killcrew');
|
||||
$death = Util::valueFit($generalObj->getRankVar('deathcrew'), 1);
|
||||
|
||||
$tt = Util::valueFit($ttw+$ttd+$ttl, 1);
|
||||
$tl = Util::valueFit($tlw+$tld+$tll, 1);
|
||||
$ts = Util::valueFit($tsw+$tsd+$tsl, 1);
|
||||
$ti = Util::valueFit($tiw+$tid+$til, 1);
|
||||
$tt = Util::valueFit($ttw + $ttd + $ttl, 1);
|
||||
$tl = Util::valueFit($tlw + $tld + $tll, 1);
|
||||
$ts = Util::valueFit($tsw + $tsd + $tsl, 1);
|
||||
$ti = Util::valueFit($tiw + $tid + $til, 1);
|
||||
|
||||
$calcVar = [];
|
||||
$calcVar['ttrate'] = $ttw/$tt;
|
||||
$calcVar['tlrate'] = $tlw/$tl;
|
||||
$calcVar['tsrate'] = $tsw/$ts;
|
||||
$calcVar['tirate'] = $tiw/$ti;
|
||||
$calcVar['betrate'] = $betWinGold/$betGold;
|
||||
$calcVar['winrate'] = $win/$war;
|
||||
$calcVar['killrate'] = $kill/$death;
|
||||
|
||||
if($generalObj instanceof DummyGeneral){
|
||||
$calcVar['ttrate'] = $ttw / $tt;
|
||||
$calcVar['tlrate'] = $tlw / $tl;
|
||||
$calcVar['tsrate'] = $tsw / $ts;
|
||||
$calcVar['tirate'] = $tiw / $ti;
|
||||
$calcVar['betrate'] = $betWinGold / $betGold;
|
||||
$calcVar['winrate'] = $win / $war;
|
||||
$calcVar['killrate'] = $kill / $death;
|
||||
|
||||
if ($generalObj instanceof DummyGeneral) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1360,170 +1436,138 @@ function CheckHall($no) {
|
||||
[$scenarioIdx, $scenarioName, $startTime] = $gameStor->getValuesAsArray(['scenario', 'scenario_text', 'starttime']);
|
||||
|
||||
$ownerName = $generalObj->getVar('owner_name');
|
||||
if($generalObj->getVar('owner')){
|
||||
if ($generalObj->getVar('owner')) {
|
||||
$ownerName = RootDB::db()->queryFirstField('SELECT name FROM member WHERE no = %i', $generalObj->getVar('owner'));
|
||||
}
|
||||
|
||||
foreach($types as $idx=>[$typeName, $valueType]) {
|
||||
|
||||
if($valueType === 'natural'){
|
||||
foreach ($types as $idx => [$typeName, $valueType]) {
|
||||
|
||||
if ($valueType === 'natural') {
|
||||
$value = $generalObj->getVar($typeName);
|
||||
}
|
||||
else if($valueType === 'rank'){
|
||||
} else if ($valueType === 'rank') {
|
||||
$value = $generalObj->getRankVar($typeName);
|
||||
}
|
||||
else if($valueType === 'calc'){
|
||||
} else if ($valueType === 'calc') {
|
||||
$value = $calcVar[$typeName];
|
||||
}
|
||||
|
||||
//승률,살상률인데 10회 미만 전투시 스킵
|
||||
if(($typeName === 'winrate' || $typeName === 'killrate') && $generalObj->getRankVar('warnum')<10) { continue; }
|
||||
if (($typeName === 'winrate' || $typeName === 'killrate') && $generalObj->getRankVar('warnum') < 10) {
|
||||
continue;
|
||||
}
|
||||
//토너승률인데 50회 미만시 스킵
|
||||
if($typeName === 'ttrate' && $tt < 50) { continue; }
|
||||
if ($typeName === 'ttrate' && $tt < 50) {
|
||||
continue;
|
||||
}
|
||||
//토너승률인데 50회 미만시 스킵
|
||||
if($typeName === 'tlrate' && $tl < 50) { continue; }
|
||||
if ($typeName === 'tlrate' && $tl < 50) {
|
||||
continue;
|
||||
}
|
||||
//토너승률인데 50회 미만시 스킵
|
||||
if($typeName === 'tsrate' && $ts < 50) { continue; }
|
||||
if ($typeName === 'tsrate' && $ts < 50) {
|
||||
continue;
|
||||
}
|
||||
//토너승률인데 50회 미만시 스킵
|
||||
if($typeName === 'tirate' && $ti < 50) { continue; }
|
||||
if ($typeName === 'tirate' && $ti < 50) {
|
||||
continue;
|
||||
}
|
||||
//수익률인데 1000미만시 스킵
|
||||
if($typeName === 'betrate' && $generalObj->getRankVar('betgold') < 1000) { continue; }
|
||||
if ($typeName === 'betrate' && $generalObj->getRankVar('betgold') < 1000) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($value<=0){
|
||||
if ($value <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$aux = [
|
||||
'name'=>$generalObj->getName(),
|
||||
'nationName'=>$nation['name'],
|
||||
'bgColor'=>$nation['color'],
|
||||
'fgColor'=>newColor($nation['color']),
|
||||
'picture'=>$generalObj->getVar('picture'),
|
||||
'imgsvr'=>$generalObj->getVar('imgsvr'),
|
||||
'startTime'=>$startTime,
|
||||
'unitedTime'=>$unitedDate,
|
||||
'ownerName'=>$ownerName,
|
||||
'serverID'=>UniqueConst::$serverID,
|
||||
'serverIdx'=>$serverCnt,
|
||||
'serverName'=>UniqueConst::$serverName,
|
||||
'scenarioName'=>$scenarioName,
|
||||
'name' => $generalObj->getName(),
|
||||
'nationName' => $nation['name'],
|
||||
'bgColor' => $nation['color'],
|
||||
'fgColor' => newColor($nation['color']),
|
||||
'picture' => $generalObj->getVar('picture'),
|
||||
'imgsvr' => $generalObj->getVar('imgsvr'),
|
||||
'startTime' => $startTime,
|
||||
'unitedTime' => $unitedDate,
|
||||
'ownerName' => $ownerName,
|
||||
'serverID' => UniqueConst::$serverID,
|
||||
'serverIdx' => $serverCnt,
|
||||
'serverName' => UniqueConst::$serverName,
|
||||
'scenarioName' => $scenarioName,
|
||||
];
|
||||
$jsonAux = Json::encode($aux);
|
||||
|
||||
$db->insertIgnore('ng_hall', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'season'=>UniqueConst::$seasonIdx,
|
||||
'scenario'=>$scenarioIdx,
|
||||
'general_no'=>$no,
|
||||
'type'=>$idx,
|
||||
'value'=>$value,
|
||||
'owner'=>$generalObj->getVar('owner'),
|
||||
'aux'=>$jsonAux
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'season' => UniqueConst::$seasonIdx,
|
||||
'scenario' => $scenarioIdx,
|
||||
'general_no' => $no,
|
||||
'type' => $idx,
|
||||
'value' => $value,
|
||||
'owner' => $generalObj->getVar('owner'),
|
||||
'aux' => $jsonAux
|
||||
]);
|
||||
|
||||
if($db->affectedRows() == 0){
|
||||
$db->update('ng_hall', [
|
||||
'value'=>$value,
|
||||
'aux'=>$jsonAux
|
||||
],
|
||||
'server_id = %s AND scenario = %i AND general_no = %i AND type = %i AND value < %d',
|
||||
UniqueConst::$serverID,
|
||||
$scenarioIdx,
|
||||
$no,
|
||||
$idx,
|
||||
$value);
|
||||
if ($db->affectedRows() == 0) {
|
||||
$db->update(
|
||||
'ng_hall',
|
||||
[
|
||||
'value' => $value,
|
||||
'aux' => $jsonAux
|
||||
],
|
||||
'server_id = %s AND scenario = %i AND general_no = %i AND type = %i AND value < %d',
|
||||
UniqueConst::$serverID,
|
||||
$scenarioIdx,
|
||||
$no,
|
||||
$idx,
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function tryUniqueItemLottery(General $general, string $acquireType='아이템'):bool{
|
||||
function giveRandomUniqueItem(General $general, string $acquireType): bool
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
if($general->getVar('npc') >= 2){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($general->getVar('npc') > 6){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($general->getItems() as $item){
|
||||
if(!$item){
|
||||
continue;
|
||||
}
|
||||
if(!$item->isBuyable()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$scenario = $gameStor->scenario;
|
||||
$genCount = $db->queryFirstField('SELECT count(*) FROM general WHERE npc<2');
|
||||
|
||||
if ($scenario < 100) {
|
||||
$prob = 1 / ($genCount * 5); // 5~6개월에 하나씩 등장
|
||||
}
|
||||
else {
|
||||
$prob = 1 / $genCount; // 1~2개월에 하나씩 등장
|
||||
}
|
||||
|
||||
if($acquireType == '투표'){
|
||||
$prob = 1 / ($genCount * 0.7 / 3); // 투표율 70%, 투표 한번에 2~3개 등장
|
||||
}
|
||||
else if($acquireType == '랜덤 임관'){
|
||||
$prob = 1 / ($genCount / 10/ 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
||||
}
|
||||
else if($acquireType == '건국'){
|
||||
$prob = 1 / ($genCount / 10/ 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
|
||||
}
|
||||
|
||||
$prob = Util::valueFit($prob, 1/3, 1);
|
||||
|
||||
if(!Util::randBool($prob)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//아이템 습득 상황
|
||||
$availableUnique = [];
|
||||
|
||||
|
||||
//TODO: 너무 바보 같다. 장기적으로는 유니크 아이템 테이블 같은게 필요하지 않을까?
|
||||
//일단은 '획득' 시에만 동작하므로 이대로 사용하기로...
|
||||
$occupiedUnique = [];
|
||||
|
||||
|
||||
foreach (array_keys(GameConst::$allItems) as $itemType) {
|
||||
foreach($db->queryAllLists('SELECT %b, count(*) as cnt FROM general GROUP BY %b', $itemType, $itemType) as [$itemCode, $cnt]){
|
||||
foreach ($db->queryAllLists('SELECT %b, count(*) as cnt FROM general GROUP BY %b', $itemType, $itemType) as [$itemCode, $cnt]) {
|
||||
$itemClass = buildItemClass($itemCode);
|
||||
if(!$itemClass){
|
||||
if (!$itemClass) {
|
||||
continue;
|
||||
}
|
||||
if($itemClass->isBuyable()){
|
||||
if ($itemClass->isBuyable()) {
|
||||
continue;
|
||||
}
|
||||
$occupiedUnique[$itemCode] = $cnt;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(GameConst::$allItems as $itemType=>$itemCategories){
|
||||
foreach($itemCategories as $itemCode => $cnt){
|
||||
if(!key_exists($itemCode, $occupiedUnique)){
|
||||
foreach (GameConst::$allItems as $itemType => $itemCategories) {
|
||||
foreach ($itemCategories as $itemCode => $cnt) {
|
||||
if (!key_exists($itemCode, $occupiedUnique)) {
|
||||
$availableUnique[] = [[$itemType, $itemCode], $cnt];
|
||||
continue;
|
||||
}
|
||||
|
||||
$remain = $cnt - $occupiedUnique[$itemCode];
|
||||
if($remain > 0){
|
||||
if ($remain > 0) {
|
||||
$availableUnique[] = [[$itemType, $itemCode], $remain];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$availableUnique){
|
||||
if (!$availableUnique) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[$itemType, $itemCode] = Util::choiceRandomUsingWeightPair($availableUnique);
|
||||
|
||||
|
||||
$nationName = $general->getStaticNation()['name'];
|
||||
$generalName = $general->getName();
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
@@ -1545,24 +1589,75 @@ function tryUniqueItemLottery(General $general, string $acquireType='아이템')
|
||||
return true;
|
||||
}
|
||||
|
||||
function getAdmin() {
|
||||
function tryUniqueItemLottery(General $general, string $acquireType = '아이템'): bool
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
if ($general->getVar('npc') >= 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($general->getVar('npc') > 6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($general->getItems() as $item) {
|
||||
if (!$item) {
|
||||
continue;
|
||||
}
|
||||
if (!$item->isBuyable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$scenario = $gameStor->scenario;
|
||||
$genCount = $db->queryFirstField('SELECT count(*) FROM general WHERE npc<2');
|
||||
|
||||
if ($scenario < 100) {
|
||||
$prob = 1 / ($genCount * 5); // 5~6개월에 하나씩 등장
|
||||
} else {
|
||||
$prob = 1 / $genCount; // 1~2개월에 하나씩 등장
|
||||
}
|
||||
|
||||
if ($acquireType == '투표') {
|
||||
$prob = 1 / ($genCount * 0.7 / 3); // 투표율 70%, 투표 한번에 2~3개 등장
|
||||
} else if ($acquireType == '랜덤 임관') {
|
||||
$prob = 1 / ($genCount / 10 / 2); // 랜임시 2개(10%) 등장(200명중 20명 랜임시도?)
|
||||
} else if ($acquireType == '건국') {
|
||||
$prob = 1 / ($genCount / 10 / 4); // 건국시 4개(20%) 등장(200명시 20국 정도 됨)
|
||||
}
|
||||
|
||||
$prob = Util::valueFit($prob, 1 / 3, 1);
|
||||
|
||||
if (!Util::randBool($prob)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return giveRandomUniqueItem($general, $acquireType);
|
||||
}
|
||||
|
||||
function getAdmin()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
return $gameStor->getAll();
|
||||
}
|
||||
|
||||
function getCity($city, $sel="*") {
|
||||
function getCity($city, $sel = "*")
|
||||
{
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
|
||||
$query = "select {$sel} from city where city='$city'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$city = MYDB_fetch_array($result);
|
||||
|
||||
return $city;
|
||||
}
|
||||
|
||||
function deleteNation(General $general) {
|
||||
function deleteNation(General $general)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -1591,27 +1686,27 @@ function deleteNation(General $general) {
|
||||
|
||||
// 전 장수 재야로 // 전 장수 소속 무소속으로
|
||||
$db->update('general', [
|
||||
'belong'=>0,
|
||||
'troop'=>0,
|
||||
'officer_level'=>0,
|
||||
'officer_city'=>0,
|
||||
'nation'=>0,
|
||||
'makelimit'=>12,
|
||||
'permission'=>'normal',
|
||||
'belong' => 0,
|
||||
'troop' => 0,
|
||||
'officer_level' => 0,
|
||||
'officer_city' => 0,
|
||||
'nation' => 0,
|
||||
'makelimit' => 12,
|
||||
'permission' => 'normal',
|
||||
], 'nation=%i', $nationID);
|
||||
// 도시 공백지로
|
||||
$db->update('city', [
|
||||
'nation'=>0,
|
||||
'front'=>0,
|
||||
'nation' => 0,
|
||||
'front' => 0,
|
||||
], 'nation=%i', $nationID);
|
||||
// 부대 삭제
|
||||
$db->delete('troop', 'nation=%i', $nationID);
|
||||
// 국가 삭제
|
||||
|
||||
$db->insert('ng_old_nations', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation'=>$nationID,
|
||||
'data'=>Json::encode($oldNation)
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation' => $nationID,
|
||||
'data' => Json::encode($oldNation)
|
||||
]);
|
||||
$db->delete('nation', 'nation=%i', $nationID);
|
||||
$db->delete('nation_turn', 'nation_id=%i', $nationID);
|
||||
@@ -1621,10 +1716,11 @@ function deleteNation(General $general) {
|
||||
refreshNationStaticInfo();
|
||||
}
|
||||
|
||||
function nextRuler(General $general) {
|
||||
function nextRuler(General $general)
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
|
||||
[$year, $month] = $gameStor->getValuesAsArray(['year', 'month']);
|
||||
$nation = $general->getStaticNation();
|
||||
$nationName = $nation['name'];
|
||||
@@ -1633,7 +1729,7 @@ function nextRuler(General $general) {
|
||||
$candidate = null;
|
||||
|
||||
//npc or npc유저인 경우 후계 찾기
|
||||
if($general->getVar('npc') > 0) {
|
||||
if ($general->getVar('npc') > 0) {
|
||||
$candidate = $db->queryFirstRow(
|
||||
'SELECT no,name,officer_level,IF(ABS(affinity-%i)>75,150-ABS(affinity-%i),ABS(affinity-%i)) as npcmatch2 from general where nation=%i and officer_level!=12 and 1 <= npc and npc<=3 order by npcmatch2,rand() LIMIT 1',
|
||||
$general->getVar('affinity'),
|
||||
@@ -1642,13 +1738,13 @@ function nextRuler(General $general) {
|
||||
$nationID
|
||||
);
|
||||
}
|
||||
if(!$candidate){
|
||||
if (!$candidate) {
|
||||
$candidate = $db->queryFirstRow(
|
||||
'SELECT no,name,npc,officer_level FROM general WHERE nation=%i and officer_level!= 12 AND officer_level >= 9 and npc != 5 ORDER BY officer_level DESC LIMIT 1',
|
||||
$nationID
|
||||
);
|
||||
}
|
||||
if(!$candidate){
|
||||
if (!$candidate) {
|
||||
$candidate = $db->queryFirstRow(
|
||||
'SELECT no,name,npc,officer_level FROM general WHERE nation=%i and officer_level!= 12 and npc != 5 ORDER BY dedication DESC LIMIT 1',
|
||||
$nationID
|
||||
@@ -1656,7 +1752,7 @@ function nextRuler(General $general) {
|
||||
}
|
||||
|
||||
|
||||
if(!$candidate){
|
||||
if (!$candidate) {
|
||||
DeleteConflict($general->getNationID());
|
||||
deleteNation($general);
|
||||
return;
|
||||
@@ -1669,10 +1765,10 @@ function nextRuler(General $general) {
|
||||
$general->setVar('officer_city', 0);
|
||||
|
||||
$db->update('general', [
|
||||
'officer_level'=>12,
|
||||
'officer_city'=>0,
|
||||
'officer_level' => 12,
|
||||
'officer_city' => 0,
|
||||
], 'no=%i AND nation=%i', $nextRulerID, $nationID);
|
||||
if($db->affectedRows()==0){
|
||||
if ($db->affectedRows() == 0) {
|
||||
throw new \RuntimeException('선양되지 않음');
|
||||
}
|
||||
|
||||
@@ -1691,7 +1787,8 @@ function nextRuler(General $general) {
|
||||
* @param $maxDist 검색하고자 하는 최대 거리
|
||||
* @param $distForm 리턴 타입. true일 경우 $result[$dist] = [...$city] 이며, false일 경우 $result[$city] = $dist 임
|
||||
*/
|
||||
function searchDistance(int $from, int $maxDist=99, bool $distForm = false) {
|
||||
function searchDistance(int $from, int $maxDist = 99, bool $distForm = false)
|
||||
{
|
||||
$queue = new \SplQueue();
|
||||
|
||||
$cities = [];
|
||||
@@ -1699,35 +1796,34 @@ function searchDistance(int $from, int $maxDist=99, bool $distForm = false) {
|
||||
|
||||
$queue->enqueue([$from, 0]);
|
||||
|
||||
while(!$queue->isEmpty()){
|
||||
while (!$queue->isEmpty()) {
|
||||
list($cityID, $dist) = $queue->dequeue();
|
||||
if(key_exists($cityID, $cities)){
|
||||
if (key_exists($cityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!key_exists($dist, $distanceList)){
|
||||
if (!key_exists($dist, $distanceList)) {
|
||||
$distanceList[$dist] = [];
|
||||
}
|
||||
$distanceList[$dist][] = $cityID;
|
||||
|
||||
$cities[$cityID] = $dist;
|
||||
if($dist >= $maxDist){
|
||||
if ($dist >= $maxDist) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach(array_keys(CityConst::byID($cityID)->path) as $connCityID){
|
||||
if(key_exists($connCityID, $cities)){
|
||||
foreach (array_keys(CityConst::byID($cityID)->path) as $connCityID) {
|
||||
if (key_exists($connCityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
$queue->enqueue([$connCityID, $dist+1]);
|
||||
$queue->enqueue([$connCityID, $dist + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
if($distForm){
|
||||
if ($distForm) {
|
||||
unset($distanceList[0]);
|
||||
return $distanceList;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return $cities;
|
||||
}
|
||||
}
|
||||
@@ -1739,63 +1835,60 @@ function searchDistance(int $from, int $maxDist=99, bool $distForm = false) {
|
||||
* @param array|null $linkNationList 경로에 해당하는 국가 리스트, null인 경우 제한 없음
|
||||
* @return null|int 거리.
|
||||
*/
|
||||
function calcCityDistance(int $from, int $to, ?array $linkNationList):?int{
|
||||
function calcCityDistance(int $from, int $to, ?array $linkNationList): ?int
|
||||
{
|
||||
$queue = new \SplQueue();
|
||||
|
||||
$cities = [];
|
||||
|
||||
if($linkNationList === []){
|
||||
if ($linkNationList === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($linkNationList !== null){
|
||||
if ($linkNationList !== null) {
|
||||
$db = DB::db();
|
||||
//TODO: 도시-국가 캐싱이 있으면 쓸모 있지 않을까
|
||||
$allowedCityList = [];
|
||||
foreach($db->queryFirstColumn(
|
||||
foreach ($db->queryFirstColumn(
|
||||
'SELECT city FROM city WHERE nation IN %li',
|
||||
$linkNationList
|
||||
) as $cityID){
|
||||
) as $cityID) {
|
||||
$allowedCityList[$cityID] = $cityID;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$allowedCityList = CityConst::all();
|
||||
}
|
||||
|
||||
if(!key_exists($to, $allowedCityList)){
|
||||
if (!key_exists($to, $allowedCityList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($from === $to){
|
||||
if ($from === $to) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$queue->enqueue([$from, 0]);
|
||||
|
||||
while(!$queue->isEmpty()){
|
||||
while (!$queue->isEmpty()) {
|
||||
list($cityID, $dist) = $queue->dequeue();
|
||||
if(key_exists($cityID, $cities)){
|
||||
if (key_exists($cityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cities[$cityID] = $dist;
|
||||
|
||||
if($cityID === $to){
|
||||
if ($cityID === $to) {
|
||||
return $dist;
|
||||
}
|
||||
|
||||
foreach(array_keys(CityConst::byID($cityID)->path) as $connCityID){
|
||||
if(!key_exists($connCityID, $allowedCityList)){
|
||||
foreach (array_keys(CityConst::byID($cityID)->path) as $connCityID) {
|
||||
if (!key_exists($connCityID, $allowedCityList)) {
|
||||
continue;
|
||||
}
|
||||
if(key_exists($connCityID, $cities)){
|
||||
if (key_exists($connCityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
$queue->enqueue([$connCityID, $dist+1]);
|
||||
|
||||
$queue->enqueue([$connCityID, $dist + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1809,7 +1902,8 @@ function calcCityDistance(int $from, int $to, ?array $linkNationList):?int{
|
||||
* @param $linkNationList 경로에 해당하는 국가 리스트
|
||||
* @return array $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움
|
||||
*/
|
||||
function searchDistanceListToDest(int $from, int $to, array $linkNationList) {
|
||||
function searchDistanceListToDest(int $from, int $to, array $linkNationList)
|
||||
{
|
||||
$queue = new \SplQueue();
|
||||
|
||||
$cities = [];
|
||||
@@ -1818,49 +1912,48 @@ function searchDistanceListToDest(int $from, int $to, array $linkNationList) {
|
||||
|
||||
//TODO: 도시-국가 캐싱이 있으면 쓸모 있지 않을까
|
||||
$allowedCityList = [];
|
||||
foreach($db->queryAllLists(
|
||||
foreach ($db->queryAllLists(
|
||||
'SELECT city, nation FROM city WHERE nation IN %li',
|
||||
$linkNationList
|
||||
) as [$cityID, $nationID]){
|
||||
) as [$cityID, $nationID]) {
|
||||
$allowedCityList[$cityID] = $nationID;
|
||||
}
|
||||
|
||||
$remainFromCities = [];
|
||||
foreach(array_keys(CityConst::byID($from)->path) as $fromCityID){
|
||||
if(key_exists($fromCityID, $allowedCityList)){
|
||||
foreach (array_keys(CityConst::byID($from)->path) as $fromCityID) {
|
||||
if (key_exists($fromCityID, $allowedCityList)) {
|
||||
$remainFromCities[$fromCityID] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!key_exists($to, $allowedCityList)){
|
||||
if (!key_exists($to, $allowedCityList)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$queue->enqueue([$to, 0]);
|
||||
|
||||
while(!empty($remainFromCities) && !$queue->isEmpty()){
|
||||
while (!empty($remainFromCities) && !$queue->isEmpty()) {
|
||||
list($cityID, $dist) = $queue->dequeue();
|
||||
if(key_exists($cityID, $cities)){
|
||||
if (key_exists($cityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cities[$cityID] = $dist;
|
||||
|
||||
if(key_exists($cityID, $remainFromCities)){
|
||||
if (key_exists($cityID, $remainFromCities)) {
|
||||
unset($remainFromCities[$cityID]);
|
||||
$result[$dist][] = [$cityID, $allowedCityList[$cityID]];
|
||||
}
|
||||
|
||||
foreach(array_keys(CityConst::byID($cityID)->path) as $connCityID){
|
||||
if($allowedCityList !== null && !key_exists($connCityID, $allowedCityList)){
|
||||
foreach (array_keys(CityConst::byID($cityID)->path) as $connCityID) {
|
||||
if ($allowedCityList !== null && !key_exists($connCityID, $allowedCityList)) {
|
||||
continue;
|
||||
}
|
||||
if(key_exists($connCityID, $cities)){
|
||||
if (key_exists($connCityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
$queue->enqueue([$connCityID, $dist+1]);
|
||||
|
||||
$queue->enqueue([$connCityID, $dist + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1872,20 +1965,21 @@ function searchDistanceListToDest(int $from, int $to, array $linkNationList) {
|
||||
* @param $cityIDList 이동 가능한 도시 리스트.
|
||||
* @return array [from][to] 로 표시되는 거리값
|
||||
*/
|
||||
function searchAllDistanceByCityList(array $cityIDList):array {
|
||||
if(!$cityIDList){
|
||||
function searchAllDistanceByCityList(array $cityIDList): array
|
||||
{
|
||||
if (!$cityIDList) {
|
||||
return [];
|
||||
}
|
||||
$cityList = [];
|
||||
foreach($cityIDList as $cityID){
|
||||
foreach ($cityIDList as $cityID) {
|
||||
$cityList[$cityID] = $cityID;
|
||||
}
|
||||
|
||||
$distanceList = [];
|
||||
foreach($cityIDList as $cityID){
|
||||
$nearList = [$cityID=>0];
|
||||
foreach(array_keys(CityConst::byID($cityID)->path) as $nextCityID){
|
||||
if(!key_exists($nextCityID, $cityList)){
|
||||
foreach ($cityIDList as $cityID) {
|
||||
$nearList = [$cityID => 0];
|
||||
foreach (array_keys(CityConst::byID($cityID)->path) as $nextCityID) {
|
||||
if (!key_exists($nextCityID, $cityList)) {
|
||||
continue;
|
||||
}
|
||||
$nearList[$nextCityID] = 1;
|
||||
@@ -1894,21 +1988,21 @@ function searchAllDistanceByCityList(array $cityIDList):array {
|
||||
}
|
||||
|
||||
//Floyd-Warshall
|
||||
foreach($cityList as $cityStop){
|
||||
foreach($cityList as $cityFrom){
|
||||
foreach($cityList as $cityTo){
|
||||
if(!key_exists($cityStop, $distanceList[$cityFrom])){
|
||||
foreach ($cityList as $cityStop) {
|
||||
foreach ($cityList as $cityFrom) {
|
||||
foreach ($cityList as $cityTo) {
|
||||
if (!key_exists($cityStop, $distanceList[$cityFrom])) {
|
||||
continue;
|
||||
}
|
||||
if(!key_exists($cityTo, $distanceList[$cityStop])){
|
||||
if (!key_exists($cityTo, $distanceList[$cityStop])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!key_exists($cityTo, $distanceList[$cityFrom])){
|
||||
if (!key_exists($cityTo, $distanceList[$cityFrom])) {
|
||||
$distanceList[$cityFrom][$cityTo] = $distanceList[$cityFrom][$cityStop] + $distanceList[$cityStop][$cityTo];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$distanceList[$cityFrom][$cityTo] = min($distanceList[$cityFrom][$cityStop] + $distanceList[$cityStop][$cityTo], $distanceList[$cityFrom][$cityTo]);
|
||||
}
|
||||
}
|
||||
@@ -1923,42 +2017,42 @@ function searchAllDistanceByCityList(array $cityIDList):array {
|
||||
* @param $suppliedCityOnly 보급된 도시만을 이용해 검색
|
||||
* @return array [from][to] 로 표시되는 거리값
|
||||
*/
|
||||
function searchAllDistanceByNationList(array $linkNationList, bool $suppliedCityOnly=false):array {
|
||||
if(!$linkNationList){
|
||||
function searchAllDistanceByNationList(array $linkNationList, bool $suppliedCityOnly = false): array
|
||||
{
|
||||
if (!$linkNationList) {
|
||||
return [];
|
||||
}
|
||||
$db = DB::db();
|
||||
if($suppliedCityOnly){
|
||||
$cityIDList = $db->queryFirstColumn('SELECT city FROM city WHERE nation IN %li AND supply=1',$linkNationList);
|
||||
}
|
||||
else{
|
||||
$cityIDList = $db->queryFirstColumn('SELECT city FROM city WHERE nation IN %li',$linkNationList);
|
||||
if ($suppliedCityOnly) {
|
||||
$cityIDList = $db->queryFirstColumn('SELECT city FROM city WHERE nation IN %li AND supply=1', $linkNationList);
|
||||
} else {
|
||||
$cityIDList = $db->queryFirstColumn('SELECT city FROM city WHERE nation IN %li', $linkNationList);
|
||||
}
|
||||
return searchAllDistanceByCityList($cityIDList);
|
||||
}
|
||||
|
||||
function isNeighbor(int $nation1, int $nation2, bool $includeNoSupply=true) {
|
||||
if($nation1 === $nation2){
|
||||
function isNeighbor(int $nation1, int $nation2, bool $includeNoSupply = true)
|
||||
{
|
||||
if ($nation1 === $nation2) {
|
||||
return false;
|
||||
}
|
||||
$db = DB::db();
|
||||
|
||||
$nation1Cities = [];
|
||||
|
||||
if($includeNoSupply){
|
||||
if ($includeNoSupply) {
|
||||
$supplySql = '';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$supplySql = 'AND supply = 1';
|
||||
}
|
||||
|
||||
foreach($db->queryFirstColumn('SELECT city FROM city WHERE nation = %i %l', $nation1, $supplySql) as $city){
|
||||
foreach ($db->queryFirstColumn('SELECT city FROM city WHERE nation = %i %l', $nation1, $supplySql) as $city) {
|
||||
$nation1Cities[$city] = $city;
|
||||
}
|
||||
|
||||
foreach($db->queryFirstColumn('SELECT city FROM city WHERE nation = %i %l', $nation2, $supplySql) as $city){
|
||||
foreach(array_keys(CityConst::byID($city)->path) as $adjCity){
|
||||
if(key_exists($adjCity, $nation1Cities)){
|
||||
foreach ($db->queryFirstColumn('SELECT city FROM city WHERE nation = %i %l', $nation2, $supplySql) as $city) {
|
||||
foreach (array_keys(CityConst::byID($city)->path) as $adjCity) {
|
||||
if (key_exists($adjCity, $nation1Cities)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1967,16 +2061,17 @@ function isNeighbor(int $nation1, int $nation2, bool $includeNoSupply=true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function SabotageInjury(array $cityGeneralList, string $reason):int{
|
||||
function SabotageInjury(array $cityGeneralList, string $reason): int
|
||||
{
|
||||
$injuryCount = 0;
|
||||
$josaRo = JosaUtil::pick($reason, '로');
|
||||
$text = "<M>{$reason}</>{$josaRo} 인해 <R>부상</>을 당했습니다.";
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
foreach($cityGeneralList as $general){
|
||||
foreach ($cityGeneralList as $general) {
|
||||
/** @var General $general */
|
||||
if(!Util::randBool(0.3)){
|
||||
if (!Util::randBool(0.3)) {
|
||||
continue;
|
||||
}
|
||||
$general->getLogger()->pushGeneralActionLog($text);
|
||||
@@ -1985,7 +2080,7 @@ function SabotageInjury(array $cityGeneralList, string $reason):int{
|
||||
$general->multiplyVar('crew', 0.98);
|
||||
$general->multiplyVar('atmos', 0.98);
|
||||
$general->multiplyVar('train', 0.98);
|
||||
|
||||
|
||||
$general->applyDB($db);
|
||||
|
||||
$injuryCount += 1;
|
||||
@@ -1994,39 +2089,35 @@ function SabotageInjury(array $cityGeneralList, string $reason):int{
|
||||
return $injuryCount;
|
||||
}
|
||||
|
||||
function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null) {
|
||||
if($baseDateTime === null){
|
||||
function getRandTurn($term, ?\DateTimeInterface $baseDateTime = null)
|
||||
{
|
||||
if ($baseDateTime === null) {
|
||||
$baseDateTime = new \DateTimeImmutable();
|
||||
}
|
||||
else if($baseDateTime instanceof \DateTime){
|
||||
} else if ($baseDateTime instanceof \DateTime) {
|
||||
$baseDateTime = \DateTimeImmutable::createFromMutable($baseDateTime);
|
||||
}
|
||||
else if($baseDateTime instanceof \DateTimeImmutable){
|
||||
} else if ($baseDateTime instanceof \DateTimeImmutable) {
|
||||
//do Nothing
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw new MustNotBeReachedException();
|
||||
}
|
||||
|
||||
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
|
||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
||||
|
||||
return $baseDateTime->add(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
function getRandTurn2($term, ?\DateTimeInterface $baseDateTime = null)
|
||||
{
|
||||
if($baseDateTime === null){
|
||||
if ($baseDateTime === null) {
|
||||
$baseDateTime = new \DateTimeImmutable();
|
||||
}
|
||||
else if($baseDateTime instanceof \DateTime){
|
||||
} else if ($baseDateTime instanceof \DateTime) {
|
||||
$baseDateTime = \DateTimeImmutable::createFromMutable($baseDateTime);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
throw new MustNotBeReachedException();
|
||||
}
|
||||
$randSecond = Util::randRangeInt(0, 60 * $term - 1);
|
||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000;//6자리 소수
|
||||
|
||||
$randFraction = Util::randRangeInt(0, 999999) / 1000000; //6자리 소수
|
||||
|
||||
return $baseDateTime->sub(TimeUtil::secondsToDateInterval($randSecond + $randFraction))->format('Y-m-d H:i:s');
|
||||
}
|
||||
}
|
||||
|
||||
+504
-414
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use Monolog\Logger;
|
||||
@@ -7,7 +8,8 @@ use Monolog\Logger;
|
||||
* 게임 룰에 해당하는 함수 모음
|
||||
*/
|
||||
|
||||
function getNationLevelList():array{
|
||||
function getNationLevelList(): array
|
||||
{
|
||||
$table = [
|
||||
0 => ['방랑군', 2, 0],
|
||||
1 => ['호족', 2, 1],
|
||||
@@ -21,7 +23,8 @@ function getNationLevelList():array{
|
||||
return $table;
|
||||
}
|
||||
|
||||
function getCityLevelList():array{
|
||||
function getCityLevelList(): array
|
||||
{
|
||||
return [
|
||||
1 => '수',
|
||||
2 => '진',
|
||||
@@ -35,67 +38,71 @@ function getCityLevelList():array{
|
||||
}
|
||||
|
||||
//한국가의 전체 전방 설정
|
||||
function SetNationFront($nationNo) {
|
||||
if(!$nationNo) { return; }
|
||||
function SetNationFront($nationNo)
|
||||
{
|
||||
if (!$nationNo) {
|
||||
return;
|
||||
}
|
||||
// 도시소유 국가와 선포,교전중인 국가
|
||||
|
||||
|
||||
$adj3 = [];
|
||||
$adj2 = [];
|
||||
$adj1 = [];
|
||||
|
||||
$db = DB::db();
|
||||
foreach($db->queryFirstColumn(
|
||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 0 AND me = %i'
|
||||
, $nationNo
|
||||
) as $city){
|
||||
foreach(CityConst::byID($city)->path as $adjKey=>$adjVal){
|
||||
foreach ($db->queryFirstColumn(
|
||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 0 AND me = %i',
|
||||
$nationNo
|
||||
) as $city) {
|
||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||
$adj3[$adjKey] = $adjVal;
|
||||
}
|
||||
};
|
||||
foreach($db->queryFirstColumn(
|
||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 1 AND diplomacy.term <= 5 AND me = %i'
|
||||
, $nationNo
|
||||
) as $city){
|
||||
foreach(CityConst::byID($city)->path as $adjKey=>$adjVal){
|
||||
foreach ($db->queryFirstColumn(
|
||||
'SELECT city FROM city JOIN diplomacy ON diplomacy.you = city.nation WHERE diplomacy.state = 1 AND diplomacy.term <= 5 AND me = %i',
|
||||
$nationNo
|
||||
) as $city) {
|
||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||
$adj1[$adjKey] = $adjVal;
|
||||
}
|
||||
}
|
||||
if(!$adj3 && !$adj1){
|
||||
if (!$adj3 && !$adj1) {
|
||||
//평시이면 공백지
|
||||
//NOTE: if, else일 경우 NPC는 전쟁시에는 공백지로 출병하지 않는다는 뜻이 된다.
|
||||
foreach ($db->queryFirstColumn('SELECT city from city where nation=0') as $city) {
|
||||
foreach(CityConst::byID($city)->path as $adjKey=>$adjVal){
|
||||
foreach (CityConst::byID($city)->path as $adjKey => $adjVal) {
|
||||
$adj2[$adjKey] = $adjVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->update('city', [
|
||||
'front'=>0
|
||||
'front' => 0
|
||||
], 'nation=%i', $nationNo);
|
||||
|
||||
if($adj1){
|
||||
if ($adj1) {
|
||||
$db->update('city', [
|
||||
'front'=>1,
|
||||
'front' => 1,
|
||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj1));
|
||||
}
|
||||
if($adj2){
|
||||
if ($adj2) {
|
||||
$db->update('city', [
|
||||
'front'=>2,
|
||||
'front' => 2,
|
||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj2));
|
||||
}
|
||||
if($adj3){
|
||||
if ($adj3) {
|
||||
$db->update('city', [
|
||||
'front'=>3,
|
||||
'front' => 3,
|
||||
], 'nation=%i and city in %li', $nationNo, array_keys($adj3));
|
||||
}
|
||||
}
|
||||
|
||||
function checkSupply() {
|
||||
function checkSupply()
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
$cities = [];
|
||||
foreach($db->query('SELECT city, nation FROM city WHERE nation != 0') as $city){
|
||||
foreach ($db->query('SELECT city, nation FROM city WHERE nation != 0') as $city) {
|
||||
$newCity = new \stdClass();
|
||||
$newCity->id = Util::toInt($city['city']);
|
||||
$newCity->nation = Util::toInt($city['nation']);
|
||||
@@ -103,33 +110,33 @@ function checkSupply() {
|
||||
|
||||
$cities[$newCity->id] = $newCity;
|
||||
}
|
||||
|
||||
|
||||
$queue = new \SplQueue();
|
||||
foreach($db->queryAllLists('SELECT capital, nation FROM nation WHERE `level` > 0') as list($capitalID, $nationID)){
|
||||
if(!key_exists($capitalID, $cities)){
|
||||
foreach ($db->queryAllLists('SELECT capital, nation FROM nation WHERE `level` > 0') as list($capitalID, $nationID)) {
|
||||
if (!key_exists($capitalID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
$city = $cities[$capitalID];
|
||||
if($nationID != $city->nation){
|
||||
if ($nationID != $city->nation) {
|
||||
continue;
|
||||
}
|
||||
$city->supply = true;
|
||||
$queue->enqueue($city);
|
||||
}
|
||||
|
||||
while(!$queue->isEmpty()){
|
||||
while (!$queue->isEmpty()) {
|
||||
$cityLink = $queue->dequeue();
|
||||
$city = CityConst::byID($cityLink->id);
|
||||
|
||||
foreach(array_keys($city->path) as $connCityID){
|
||||
if(!key_exists($connCityID, $cities)){
|
||||
foreach (array_keys($city->path) as $connCityID) {
|
||||
if (!key_exists($connCityID, $cities)) {
|
||||
continue;
|
||||
}
|
||||
$connCity = $cities[$connCityID];
|
||||
if($connCity->nation != $cityLink->nation){
|
||||
if ($connCity->nation != $cityLink->nation) {
|
||||
continue;
|
||||
}
|
||||
if($connCity->supply){
|
||||
if ($connCity->supply) {
|
||||
continue;
|
||||
}
|
||||
$connCity->supply = true;
|
||||
@@ -137,69 +144,73 @@ function checkSupply() {
|
||||
}
|
||||
}
|
||||
|
||||
$db->update('city',[
|
||||
'supply'=>1
|
||||
$db->update('city', [
|
||||
'supply' => 1
|
||||
], 'nation=0');
|
||||
|
||||
$db->update('city',[
|
||||
'supply'=>0
|
||||
$db->update('city', [
|
||||
'supply' => 0
|
||||
], 'nation!=0');
|
||||
|
||||
$supply = [];
|
||||
|
||||
foreach($cities as $city){
|
||||
if($city->supply){
|
||||
foreach ($cities as $city) {
|
||||
if ($city->supply) {
|
||||
$supply[] = $city->id;
|
||||
}
|
||||
}
|
||||
|
||||
if($supply){
|
||||
if ($supply) {
|
||||
$db->update('city', [
|
||||
'supply'=>1
|
||||
'supply' => 1
|
||||
], 'city IN %li', $supply);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function updateYearly() {
|
||||
function updateYearly()
|
||||
{
|
||||
//통계
|
||||
checkStatistic();
|
||||
}
|
||||
|
||||
//관직 변경 해제
|
||||
function updateQuaterly() {
|
||||
function updateQuaterly()
|
||||
{
|
||||
$db = DB::db();
|
||||
|
||||
//천도 제한 해제, 관직 변경 제한 해제
|
||||
$db->update('nation', [
|
||||
'l12set'=>0,
|
||||
'l11set'=>0,
|
||||
'l10set'=>0,
|
||||
'l9set'=>0,
|
||||
'l8set'=>0,
|
||||
'l7set'=>0,
|
||||
'l6set'=>0,
|
||||
'l5set'=>0,
|
||||
'l12set' => 0,
|
||||
'l11set' => 0,
|
||||
'l10set' => 0,
|
||||
'l9set' => 0,
|
||||
'l8set' => 0,
|
||||
'l7set' => 0,
|
||||
'l6set' => 0,
|
||||
'l5set' => 0,
|
||||
], true);
|
||||
//관직 변경 제한 해제
|
||||
$db->update('city', [
|
||||
'officer4set'=>0,
|
||||
'officer3set'=>0,
|
||||
'officer2set'=>0,
|
||||
'officer4set' => 0,
|
||||
'officer3set' => 0,
|
||||
'officer2set' => 0,
|
||||
], true);
|
||||
}
|
||||
|
||||
// 벌점 감소와 건국제한-1 전턴제한-1 외교제한-1, 1달마다 실행, 병사 있는 장수의 군량 감소, 수입비율 조정
|
||||
function preUpdateMonthly() {
|
||||
function preUpdateMonthly()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
//연감 월결산
|
||||
$result = LogHistory();
|
||||
|
||||
if($result == false) { return false; }
|
||||
|
||||
if ($result == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$admin = $gameStor->getValues(['startyear', 'year', 'month']);
|
||||
$logger = new ActionLogger(0, 0, $admin['year'], $admin['month']);
|
||||
@@ -208,70 +219,70 @@ function preUpdateMonthly() {
|
||||
checkSupply();
|
||||
//미보급도시 10% 감소
|
||||
$db->update('city', [
|
||||
'pop'=>$db->sqleval('pop * 0.9'),
|
||||
'trust'=>$db->sqleval('trust * 0.9'),
|
||||
'agri'=>$db->sqleval('agri * 0.9'),
|
||||
'comm'=>$db->sqleval('comm * 0.9'),
|
||||
'secu'=>$db->sqleval('secu * 0.9'),
|
||||
'def'=>$db->sqleval('def * 0.9'),
|
||||
'wall'=>$db->sqleval('wall * 0.9'),
|
||||
'pop' => $db->sqleval('pop * 0.9'),
|
||||
'trust' => $db->sqleval('trust * 0.9'),
|
||||
'agri' => $db->sqleval('agri * 0.9'),
|
||||
'comm' => $db->sqleval('comm * 0.9'),
|
||||
'secu' => $db->sqleval('secu * 0.9'),
|
||||
'def' => $db->sqleval('def * 0.9'),
|
||||
'wall' => $db->sqleval('wall * 0.9'),
|
||||
], 'supply = 0');
|
||||
//미보급도시 장수 병 훈 사 5%감소
|
||||
//NOTE: update inner join도 가능하지만, meekrodb 기준으로 깔끔하게.
|
||||
$unsuppliedCities = $db->query('SELECT city, nation, trust, name FROM city WHERE supply = 0');
|
||||
foreach(Util::arrayGroupBy($unsuppliedCities, 'nation') as $nationID => $cityList){
|
||||
foreach (Util::arrayGroupBy($unsuppliedCities, 'nation') as $nationID => $cityList) {
|
||||
$cityIDList = Util::squeezeFromArray($cityList, 'city');
|
||||
$db->update('general', [
|
||||
'crew'=>$db->sqleval('crew*0.95'),
|
||||
'atmos'=>$db->sqleval('atmos*0.95'),
|
||||
'train'=>$db->sqleval('train*0.95'),
|
||||
'crew' => $db->sqleval('crew*0.95'),
|
||||
'atmos' => $db->sqleval('atmos*0.95'),
|
||||
'train' => $db->sqleval('train*0.95'),
|
||||
], 'city IN %li AND nation = %i', $cityIDList, $nationID);
|
||||
}
|
||||
|
||||
//민심30이하 공백지 처리
|
||||
$lostCities = [];
|
||||
foreach($unsuppliedCities as $unsuppliedCity){
|
||||
if($unsuppliedCity['trust'] >= 30){
|
||||
foreach ($unsuppliedCities as $unsuppliedCity) {
|
||||
if ($unsuppliedCity['trust'] >= 30) {
|
||||
continue;
|
||||
}
|
||||
$lostCities[$unsuppliedCity['city']] = $unsuppliedCity;
|
||||
}
|
||||
|
||||
if($lostCities){
|
||||
foreach($lostCities as $lostCity){
|
||||
|
||||
if ($lostCities) {
|
||||
foreach ($lostCities as $lostCity) {
|
||||
$josaYi = JosaUtil::pick($lostCity['name'], '이');
|
||||
$logger->pushGlobalHistoryLog("<R><b>【고립】</b></><G><b>{$lostCity['name']}</b></>{$josaYi} 보급이 끊겨 <R>미지배</> 도시가 되었습니다.");
|
||||
}
|
||||
$db->update('general', [
|
||||
'officer_level'=>1,
|
||||
'officer_city'=>0
|
||||
'officer_level' => 1,
|
||||
'officer_city' => 0
|
||||
], 'officer_city IN %li', array_keys($lostCities));
|
||||
$db->update('city', [
|
||||
'nation'=>0,
|
||||
'officer4set'=>0,
|
||||
'officer3set'=>0,
|
||||
'officer2set'=>0,
|
||||
'conflict'=>'{}',
|
||||
'term'=>0,
|
||||
'front'=>0
|
||||
'nation' => 0,
|
||||
'officer4set' => 0,
|
||||
'officer3set' => 0,
|
||||
'officer2set' => 0,
|
||||
'conflict' => '{}',
|
||||
'term' => 0,
|
||||
'front' => 0
|
||||
], 'city IN %li', array_keys($lostCities));
|
||||
}
|
||||
|
||||
|
||||
//접률감소, 건국제한-1
|
||||
$db->update('general', [
|
||||
'connect'=>$db->sqleval('floor(connect*0.99)'),
|
||||
'makelimit'=>$db->sqleval('greatest(0, makelimit - 1)'),
|
||||
'connect' => $db->sqleval('floor(connect*0.99)'),
|
||||
'makelimit' => $db->sqleval('greatest(0, makelimit - 1)'),
|
||||
], true);
|
||||
//전략제한-1, 외교제한-1, 세율동기화
|
||||
$db->update('nation', [
|
||||
'strategic_cmd_limit'=>$db->sqleval('greatest(0, strategic_cmd_limit - 1)'),
|
||||
'surlimit'=>$db->sqleval('greatest(0, surlimit - 1)'),
|
||||
'rate_tmp'=>$db->sqleval('rate')
|
||||
'strategic_cmd_limit' => $db->sqleval('greatest(0, strategic_cmd_limit - 1)'),
|
||||
'surlimit' => $db->sqleval('greatest(0, surlimit - 1)'),
|
||||
'rate_tmp' => $db->sqleval('rate')
|
||||
], true);
|
||||
|
||||
//도시훈사 180년 60, 220년 87, 240년 100
|
||||
$rate = Util::round(($admin['year'] - $admin['startyear']) / 1.5) + 60;
|
||||
if($rate > 100) $rate = 100;
|
||||
if ($rate > 100) $rate = 100;
|
||||
|
||||
// 20 ~ 140원
|
||||
$develcost = ($admin['year'] - $admin['startyear'] + 10) * 2;
|
||||
@@ -283,7 +294,7 @@ function preUpdateMonthly() {
|
||||
|
||||
//계략, 전쟁표시 해제
|
||||
$db->update('city', [
|
||||
'state'=>$db->sqleval(<<<EOD
|
||||
'state' => $db->sqleval(<<<EOD
|
||||
(CASE
|
||||
WHEN state=31 THEN 0
|
||||
WHEN state=32 THEN 31
|
||||
@@ -294,36 +305,36 @@ WHEN state=42 THEN 41
|
||||
WHEN state=43 THEN 42
|
||||
ELSE state END)
|
||||
EOD),
|
||||
'term'=>$db->sqleval('greatest(0, term - 1)'),
|
||||
'conflict'=>$db->sqleval('if(term = 0,%s,conflict)', '{}'),
|
||||
'term' => $db->sqleval('greatest(0, term - 1)'),
|
||||
'conflict' => $db->sqleval('if(term = 0,%s,conflict)', '{}'),
|
||||
], true);
|
||||
|
||||
//첩보-1
|
||||
foreach($db->queryAllLists("SELECT nation, spy FROM nation WHERE spy!='' AND spy!='{}'") as [$nationNo, $rawSpy]){
|
||||
foreach ($db->queryAllLists("SELECT nation, spy FROM nation WHERE spy!='' AND spy!='{}'") as [$nationNo, $rawSpy]) {
|
||||
$spyInfo = Json::decode($rawSpy);
|
||||
|
||||
foreach($spyInfo as $cityNo => $remainMonth){
|
||||
if($remainMonth <= 1){
|
||||
foreach ($spyInfo as $cityNo => $remainMonth) {
|
||||
if ($remainMonth <= 1) {
|
||||
unset($spyInfo[$cityNo]);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$spyInfo[$cityNo] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
$db->update('nation', [
|
||||
'spy'=>Json::encode($spyInfo, Json::EMPTY_ARRAY_IS_DICT)
|
||||
'spy' => Json::encode($spyInfo, Json::EMPTY_ARRAY_IS_DICT)
|
||||
], 'nation=%i', $nationNo);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 외교 로그처리, 외교 상태 처리
|
||||
function postUpdateMonthly() {
|
||||
function postUpdateMonthly()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
|
||||
$admin = $gameStor->getValues(['startyear', 'year', 'month', 'scenario']);
|
||||
|
||||
@@ -331,8 +342,8 @@ function postUpdateMonthly() {
|
||||
|
||||
//도시 수 측정
|
||||
$cityNations = [];
|
||||
foreach($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $cityNation]){
|
||||
if(!key_exists($cityNation, $cityNations)){
|
||||
foreach ($db->queryAllLists('SELECT city, name, nation FROM city') as [$cityID, $cityName, $cityNation]) {
|
||||
if (!key_exists($cityNation, $cityNations)) {
|
||||
$cityNations[$cityNation] = [];
|
||||
}
|
||||
$cityNations[$cityNation][] = $cityName;
|
||||
@@ -340,15 +351,15 @@ function postUpdateMonthly() {
|
||||
|
||||
//각 국가 전월 장수수 대비 당월 장수수로 단합도 산정
|
||||
//각 국가 장수수를 구하고 국력 산정
|
||||
// $query = "select nation,gennum from nation where level>0";
|
||||
// 국력=
|
||||
// 자원(국가/장수의 금,쌀)
|
||||
// 기술력
|
||||
// 인구수*내정%
|
||||
// 장수능력
|
||||
// 접속률
|
||||
// 숙련도
|
||||
// 명성,공헌
|
||||
// $query = "select nation,gennum from nation where level>0";
|
||||
// 국력=
|
||||
// 자원(국가/장수의 금,쌀)
|
||||
// 기술력
|
||||
// 인구수*내정%
|
||||
// 장수능력
|
||||
// 접속률
|
||||
// 숙련도
|
||||
// 명성,공헌
|
||||
$nations = $db->query('SELECT
|
||||
A.nation,
|
||||
A.gennum, A.aux,
|
||||
@@ -369,32 +380,32 @@ function postUpdateMonthly() {
|
||||
(select sum(crew) from general where nation=A.nation) as totalCrew
|
||||
from nation A
|
||||
group by A.nation');
|
||||
foreach($nations as $nation) {
|
||||
foreach ($nations as $nation) {
|
||||
$genNum[$nation['nation']] = $nation['gennum'];
|
||||
|
||||
$aux = Json::decode($nation['aux']);
|
||||
|
||||
//약간의 랜덤치 부여 (95% ~ 105%)
|
||||
|
||||
$nation['power'] = Util::round($nation['power'] * (rand()%101 + 950) / 1000);
|
||||
$aux['maxPower'] = max($aux['maxPower']??0, $nation['power']);
|
||||
$aux['maxCrew'] = max($aux['maxCrew']??0, Util::toInt($nation['totalCrew']));
|
||||
|
||||
if(count($cityNations[$nation['nation']]??[]) > count($aux['maxCities']??[])){
|
||||
$nation['power'] = Util::round($nation['power'] * (rand() % 101 + 950) / 1000);
|
||||
$aux['maxPower'] = max($aux['maxPower'] ?? 0, $nation['power']);
|
||||
$aux['maxCrew'] = max($aux['maxCrew'] ?? 0, Util::toInt($nation['totalCrew']));
|
||||
|
||||
if (count($cityNations[$nation['nation']] ?? []) > count($aux['maxCities'] ?? [])) {
|
||||
$aux['maxCities'] = $cityNations[$nation['nation']];
|
||||
}
|
||||
|
||||
$db->update('nation', [
|
||||
'power'=>$nation['power'],
|
||||
'aux'=>Json::encode($aux)
|
||||
'power' => $nation['power'],
|
||||
'aux' => Json::encode($aux)
|
||||
], 'nation=%i', $nation['nation']);
|
||||
}
|
||||
|
||||
// 전쟁기한 세팅
|
||||
$query = "select me,you,dead,term from diplomacy where state='0'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$dipCount = MYDB_num_rows($result);
|
||||
for($i=0; $i < $dipCount; $i++) {
|
||||
for ($i = 0; $i < $dipCount; $i++) {
|
||||
$dip = MYDB_fetch_array($result);
|
||||
$genCount = $genNum[$dip['me']];
|
||||
// 25% 참여율일때 두당 10턴에 4000명 소모한다고 계산
|
||||
@@ -402,19 +413,19 @@ function postUpdateMonthly() {
|
||||
$term = floor($dip['dead'] / 100 / $genCount);
|
||||
$dip['dead'] -= $term * 100 * $genCount;
|
||||
$term = Util::valueFit($dip['term'] + $term, 0, 13);
|
||||
|
||||
|
||||
$db->update('diplomacy', [
|
||||
'term' => $term,
|
||||
'dead'=> $dip['dead'],
|
||||
'dead' => $dip['dead'],
|
||||
], 'me = %i AND you = %i', $dip['me'], $dip['you']);
|
||||
}
|
||||
|
||||
//개전국 로그
|
||||
$query = "select me,you from diplomacy where state='1' and term<='1' and me<you";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$dipCount = MYDB_num_rows($result);
|
||||
|
||||
for($i=0; $i < $dipCount; $i++) {
|
||||
|
||||
for ($i = 0; $i < $dipCount; $i++) {
|
||||
$dip = MYDB_fetch_array($result);
|
||||
$nation1 = getNationStaticInfo($dip['me']);
|
||||
$name1 = $nation1['name'];
|
||||
@@ -427,13 +438,13 @@ function postUpdateMonthly() {
|
||||
}
|
||||
//휴전국 로그
|
||||
$query = "select A.me as me,A.you as you,A.term as term1,B.term as term2 from diplomacy A, diplomacy B where A.me=B.you and A.you=B.me and A.state='0' and A.me<A.you";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$dipCount = MYDB_num_rows($result);
|
||||
for($i=0; $i < $dipCount; $i++) {
|
||||
for ($i = 0; $i < $dipCount; $i++) {
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
//양측 기간 모두 0이 되는 상황이면 휴전
|
||||
if($dip['term1'] <= 1 && $dip['term2'] <= 1) {
|
||||
if ($dip['term1'] <= 1 && $dip['term2'] <= 1) {
|
||||
$nation1 = getNationStaticInfo($dip['me']);
|
||||
$name1 = $nation1['name'];
|
||||
$nation2 = getNationStaticInfo($dip['you']);
|
||||
@@ -444,28 +455,28 @@ function postUpdateMonthly() {
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<R><b>【휴전】</b></><D><b>$name1</b></>{$josaWa} <D><b>$name2</b></>{$josaYi} <S>휴전</>합니다.";
|
||||
//기한 되면 휴전으로
|
||||
$query = "update diplomacy set state='2',term='0' where (me='{$dip['me']}' and you='{$dip['you']}') or (me='{$dip['you']}' and you='{$dip['me']}')";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
}
|
||||
}
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
//사상자 초기화
|
||||
$query = "update diplomacy set dead=0 WHERE state != 0";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//외교 기한-1
|
||||
$query = "update diplomacy set term=term-1 where term!=0";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//불가침 끝나면 통상으로
|
||||
$query = "update diplomacy set state='2' where state='7' and term='0'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//선포 끝나면 교전으로
|
||||
$query = "update diplomacy set state='0',term='6' where state='1' and term='0'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//3,4 기간 끝나면 통합
|
||||
checkMerge();
|
||||
//5,6 기간 끝나면 합병
|
||||
checkSurrender();
|
||||
//초반이후 방랑군 자동 해체
|
||||
if($admin['year'] >= $admin['startyear']+2) {
|
||||
if ($admin['year'] >= $admin['startyear'] + 2) {
|
||||
checkWander();
|
||||
}
|
||||
// 작위 업데이트
|
||||
@@ -478,8 +489,8 @@ function postUpdateMonthly() {
|
||||
// 시스템 거래건 등록
|
||||
registerAuction();
|
||||
//전방설정
|
||||
foreach(getAllNationStaticInfo() as $nation){
|
||||
if($nation['level'] <= 0){
|
||||
foreach (getAllNationStaticInfo() as $nation) {
|
||||
if ($nation['level'] <= 0) {
|
||||
continue;
|
||||
}
|
||||
SetNationFront($nation['nation']);
|
||||
@@ -487,7 +498,8 @@ function postUpdateMonthly() {
|
||||
}
|
||||
|
||||
|
||||
function checkWander() {
|
||||
function checkWander()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -495,24 +507,25 @@ function checkWander() {
|
||||
|
||||
$wanderers = $db->queryFirstColumn('SELECT general.`no` FROM general LEFT JOIN nation ON general.nation = nation.nation WHERE nation.`level` = 0 AND general.`officer_level` = 12');
|
||||
|
||||
foreach(General::createGeneralObjListFromDB($wanderers) as $wanderer){
|
||||
foreach (General::createGeneralObjListFromDB($wanderers) as $wanderer) {
|
||||
$wanderCmd = buildGeneralCommandClass('che_해산', $wanderer, $admin);
|
||||
if($wanderCmd->hasFullConditionMet()){
|
||||
if ($wanderCmd->hasFullConditionMet()) {
|
||||
$logger = $wanderer->getLogger();
|
||||
$logger->pushGeneralActionLog('초반 제한후 방랑군은 자동 해산됩니다.', ActionLogger::PLAIN);
|
||||
$wanderCmd->run();
|
||||
}
|
||||
}
|
||||
|
||||
if($wanderers){
|
||||
if ($wanderers) {
|
||||
refreshNationStaticInfo();
|
||||
}
|
||||
}
|
||||
|
||||
function checkMerge() {
|
||||
function checkMerge()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
@@ -521,56 +534,56 @@ function checkMerge() {
|
||||
$admin = $gameStor->getValues(['year', 'month']);
|
||||
|
||||
$query = "select * from diplomacy where state='3' and term='0'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$dipcount = MYDB_num_rows($dipresult);
|
||||
|
||||
for($i=0; $i < $dipcount; $i++) {
|
||||
for ($i = 0; $i < $dipcount; $i++) {
|
||||
$dip = MYDB_fetch_array($dipresult);
|
||||
|
||||
// 아국군주
|
||||
$query = "select no,name,nation from general where nation='{$dip['me']}' and officer_level='12'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
// 상대군주
|
||||
$query = "select no,name,nation,makenation from general where nation='{$dip['you']}' and officer_level='12'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$you = MYDB_fetch_array($result);
|
||||
// 모국
|
||||
$query = "select nation,name,surlimit,tech from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
// 아국
|
||||
$query = "select nation,name,gold,rice,surlimit,tech from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
//양국 NPC수
|
||||
$query = "select no from general where nation='{$you['nation']}' and npc>=2";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$npccount = MYDB_num_rows($result);
|
||||
//양국 NPC수
|
||||
$query = "select no from general where nation='{$me['nation']}' and npc>=2";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$npccount2 = MYDB_num_rows($result);
|
||||
|
||||
//TODO: 로그 기록에 대한 쿼리는 한번만 할 수 있다.
|
||||
//피항복국 장수들 역사 기록 및 로그 전달
|
||||
$query = "select no,name,nation from general where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
$josaWa = JosaUtil::pick($mynation['name'], '와');
|
||||
$genlog = ["<C>●</><D><b>{$mynation['name']}</b></>{$josaWa} 통합에 성공했습니다."];
|
||||
for($i=0; $i < $gencount; $i++) {
|
||||
for ($i = 0; $i < $gencount; $i++) {
|
||||
$gen = MYDB_fetch_array($result);
|
||||
pushGenLog($gen['no'], $genlog);
|
||||
pushGeneralHistory($gen['no'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>{$josaWa} <D><b>{$you['makenation']}</b></>로 통합에 성공"]);
|
||||
}
|
||||
//항복국 장수들 역사 기록 및 로그 전달
|
||||
$query = "select no,name,nation from general where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount2 = MYDB_num_rows($result);
|
||||
$josaWa = JosaUtil::pick($younation['name'], '와');
|
||||
$genlog[0] = "<C>●</><D><b>{$younation['name']}</b></>{$josaWa} 통합에 성공했습니다.";
|
||||
for($i=0; $i < $gencount2; $i++) {
|
||||
for ($i = 0; $i < $gencount2; $i++) {
|
||||
$gen = MYDB_fetch_array($result);
|
||||
pushGenLog($gen['no'], $genlog);
|
||||
pushGeneralHistory($gen['no'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$younation['name']}</b></>{$josaWa} <D><b>{$you['makenation']}</b></>로 통합에 성공"]);
|
||||
@@ -584,7 +597,7 @@ function checkMerge() {
|
||||
pushNationHistory($younation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>과 <D><b>{$you['makenation']}</b></>로 통합"]);
|
||||
|
||||
$newGenCount = $gencount + $gencount2;
|
||||
$newTech = ($younation['tech']*$gencount + $mynation['tech']*$gencount2)/$newGenCount;
|
||||
$newTech = ($younation['tech'] * $gencount + $mynation['tech'] * $gencount2) / $newGenCount;
|
||||
|
||||
// 국가 백업
|
||||
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $me['nation']);
|
||||
@@ -595,65 +608,65 @@ function checkMerge() {
|
||||
|
||||
// 자금 통합, 외교제한 5년, 기술유지
|
||||
$db->update('nation', [
|
||||
'name'=>$you['makenation'],
|
||||
'gold'=>$db->sqleval('gold+%i',$mynation['gold']),
|
||||
'rice'=>$db->sqleval('rice+%i',$mynation['rice']),
|
||||
'surlimit'=>24,
|
||||
'tech'=>$newTech,
|
||||
'gennum'=>$newGenCount
|
||||
], 'nation=%i',$younation['nation']);
|
||||
'name' => $you['makenation'],
|
||||
'gold' => $db->sqleval('gold+%i', $mynation['gold']),
|
||||
'rice' => $db->sqleval('rice+%i', $mynation['rice']),
|
||||
'surlimit' => 24,
|
||||
'tech' => $newTech,
|
||||
'gennum' => $newGenCount
|
||||
], 'nation=%i', $younation['nation']);
|
||||
//국가 삭제
|
||||
$db->insert('ng_old_nations', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation'=>$me['nation'],
|
||||
'data'=>Json::encode($oldNation)
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation' => $me['nation'],
|
||||
'data' => Json::encode($oldNation)
|
||||
]);
|
||||
|
||||
$db->update('general', [
|
||||
'nation'=>0,
|
||||
'permission'=>'normal',
|
||||
'nation' => 0,
|
||||
'permission' => 'normal',
|
||||
], 'nation=%i AND npc = 5', $me['nation']);
|
||||
|
||||
$query = "delete from nation where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$db->delete('nation_turn', 'nation_id=%i', $me['nation']);
|
||||
// 아국 모든 도시들 상대국 소속으로
|
||||
$query = "update city set nation='{$you['nation']}',conflict='{}' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 아국 모든 장수들 일반으로 하고 상대국 소속으로, 수도로 이동
|
||||
$query = "update general set belong=1,officer_level=1,officer_city=0,nation='{$you['nation']}' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 공헌도0.9, 명성0.9
|
||||
//TODO:experience General 객체로 이동
|
||||
$query = "update general set dedication=dedication*0.9,experience=experience*0.9 where nation='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 부대도 모두 국가 소속 변경
|
||||
$query = "update troop set nation='{$you['nation']}' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 통합국 모든 도시 5% 감소
|
||||
$query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,trust=trust*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 외교 삭제
|
||||
$query = "delete from diplomacy where me='{$me['nation']}' or you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
|
||||
// NPC들 일부 하야 (양국중 큰쪽 장수수의 90~110%만큼)
|
||||
$resignCount = 0;
|
||||
if($npccount >= $npccount2) {
|
||||
$resignCount = Util::round($npccount*(rand()%21+90)/100);
|
||||
if ($npccount >= $npccount2) {
|
||||
$resignCount = Util::round($npccount * (rand() % 21 + 90) / 100);
|
||||
} else {
|
||||
$resignCount = Util::round($npccount2*(rand()%21+90)/100);
|
||||
$resignCount = Util::round($npccount2 * (rand() % 21 + 90) / 100);
|
||||
}
|
||||
|
||||
$npcList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND npc>=2 AND npc != 5 ORDER BY rand() LIMIT %i', $you['nation'], $resignCount);
|
||||
if($npcList){
|
||||
if ($npcList) {
|
||||
$db->update('general_turn', [
|
||||
'action'=>'che_하야',
|
||||
'arg'=>null,
|
||||
'brief'=>'하야',
|
||||
'action' => 'che_하야',
|
||||
'arg' => null,
|
||||
'brief' => '하야',
|
||||
], 'general_id IN %li AND turn_idx = 0');
|
||||
}
|
||||
|
||||
|
||||
pushGenLog($me['no'], $mylog);
|
||||
pushGenLog($you['no'], $youlog);
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
@@ -666,18 +679,19 @@ function checkMerge() {
|
||||
}
|
||||
}
|
||||
|
||||
function checkSurrender() {
|
||||
function checkSurrender()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
|
||||
$admin = $gameStor->getValues(['year', 'month']);
|
||||
|
||||
$query = "select * from diplomacy where state='5' and term='0'";
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dipresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$dipcount = MYDB_num_rows($dipresult);
|
||||
|
||||
for($i=0; $i < $dipcount; $i++) {
|
||||
for ($i = 0; $i < $dipcount; $i++) {
|
||||
$mylog = [];
|
||||
$youlog = [];
|
||||
$history = [];
|
||||
@@ -686,35 +700,35 @@ function checkSurrender() {
|
||||
|
||||
// 아국군주
|
||||
$query = "select no,name,nation from general where nation='{$dip['me']}' and officer_level='12'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$me = MYDB_fetch_array($result);
|
||||
// 상대군주
|
||||
$query = "select no,name,nation,makenation from general where nation='{$dip['you']}' and officer_level='12'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$you = MYDB_fetch_array($result);
|
||||
// 모국
|
||||
$query = "select nation,name,surlimit,tech from nation where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$younation = MYDB_fetch_array($result);
|
||||
// 아국
|
||||
$query = "select nation,name,gold,rice,surlimit,tech from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$mynation = MYDB_fetch_array($result);
|
||||
//양국 NPC수
|
||||
$query = "select no from general where nation='{$you['nation']}' and npc>=2 and npc != 5";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$npccount = MYDB_num_rows($result);
|
||||
//양국 NPC수
|
||||
$query = "select no from general where nation='{$me['nation']}' and npc>=2 and npc != 5";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$npccount2 = MYDB_num_rows($result);
|
||||
|
||||
//피항복국 장수들 역사 기록 및 로그 전달
|
||||
$query = "select no,name,nation from general where nation='{$you['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
$genlog = ["<C>●</><D><b>{$mynation['name']}</b></> 합병에 성공했습니다."];
|
||||
for($i=0; $i < $gencount; $i++) {
|
||||
for ($i = 0; $i < $gencount; $i++) {
|
||||
$gen = MYDB_fetch_array($result);
|
||||
pushGenLog($gen['no'], $genlog);
|
||||
pushGeneralHistory($gen['no'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></> 합병에 성공"]);
|
||||
@@ -722,10 +736,10 @@ function checkSurrender() {
|
||||
$josaRo = JosaUtil::pick($younation['name'], '로');
|
||||
//항복국 장수들 역사 기록 및 로그 전달
|
||||
$query = "select no,name,nation from general where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount2 = MYDB_num_rows($result);
|
||||
$genlog[0] = "<C>●</><D><b>{$younation['name']}</b></>{$josaRo} 항복하여 수도로 이동합니다.";
|
||||
for($i=0; $i < $gencount2; $i++) {
|
||||
for ($i = 0; $i < $gencount2; $i++) {
|
||||
$gen = MYDB_fetch_array($result);
|
||||
pushGenLog($gen['no'], $genlog);
|
||||
pushGeneralHistory($gen['no'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$mynation['name']}</b></>가 <D><b>{$younation['name']}</b></>{$josaRo} 항복"]);
|
||||
@@ -748,69 +762,69 @@ function checkSurrender() {
|
||||
$newTech = ($younation['tech'] * $gencount + $mynation['tech'] * $gencount2) / $newGenCount;
|
||||
// 자금 통합, 외교제한 5년, 기술유지
|
||||
$db->update('nation', [
|
||||
'gold'=>$db->sqleval('gold+%i',$mynation['gold']),
|
||||
'rice'=>$db->sqleval('rice+%i',$mynation['rice']),
|
||||
'surlimit'=>24,
|
||||
'tech'=>$newTech,
|
||||
'gennum'=>$newGenCount
|
||||
'gold' => $db->sqleval('gold+%i', $mynation['gold']),
|
||||
'rice' => $db->sqleval('rice+%i', $mynation['rice']),
|
||||
'surlimit' => 24,
|
||||
'tech' => $newTech,
|
||||
'gennum' => $newGenCount
|
||||
], 'nation=%i', $younation['nation']);
|
||||
|
||||
//합병 당한국 모든 도시 10%감소
|
||||
$query = "update city set pop=pop*0.9,agri=agri*0.9,comm=comm*0.9,secu=secu*0.9,trust=trust*0.9,def=def*0.9,wall=wall*0.9 where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//합병 시도국 모든 도시 5%감소
|
||||
$query = "update city set pop=pop*0.95,agri=agri*0.95,comm=comm*0.95,secu=secu*0.95,trust=trust*0.95,def=def*0.95,wall=wall*0.95 where nation='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
//국가 삭제
|
||||
|
||||
$db->insert('ng_old_nations', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation'=>$me['nation'],
|
||||
'data'=>Json::encode($oldNation)
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation' => $me['nation'],
|
||||
'data' => Json::encode($oldNation)
|
||||
]);
|
||||
|
||||
$db->update('general', [
|
||||
'nation'=>0,
|
||||
'permission'=>'normal',
|
||||
'nation' => 0,
|
||||
'permission' => 'normal',
|
||||
], 'nation=%i AND npc = 5', $me['nation']);
|
||||
|
||||
$query = "delete from nation where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$db->delete('nation_turn', 'nation_id=%i', $me['nation']);
|
||||
// 군주가 있는 위치 구함
|
||||
$query = "select city from general where nation='{$you['nation']}' and officer_level='12'";
|
||||
$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);
|
||||
// 아국 모든 도시들 상대국 소속으로
|
||||
$query = "update city set nation='{$you['nation']}',conflict='{}' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 제의국 모든 장수들 공헌도0.95, 명성0.95
|
||||
//TODO: experience를 General로
|
||||
$query = "update general set dedication=dedication*0.95,experience=experience*0.95 where nation='{$you['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 아국 모든 장수들 일반으로 하고 상대국 소속으로, 수도로 이동, 공헌도1.1, 명성0.9
|
||||
$query = "update general set belong=1,officer_level=1,officer_city=0,nation='{$you['nation']}',city='{$king['city']}',dedication=dedication*1.1,experience=experience*0.9 where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 부대도 모두 국가 소속 변경
|
||||
$query = "update troop set nation='{$you['nation']}' where nation='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
// 외교 삭제
|
||||
$query = "delete from diplomacy where me='{$me['nation']}' or you='{$me['nation']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
|
||||
// NPC들 일부 하야 (양국중 큰쪽 장수수의 90~110%만큼)
|
||||
$resignCount = 0;
|
||||
if($npccount >= $npccount2) {
|
||||
$resignCount = Util::round($npccount*(rand()%21+90)/100);
|
||||
if ($npccount >= $npccount2) {
|
||||
$resignCount = Util::round($npccount * (rand() % 21 + 90) / 100);
|
||||
} else {
|
||||
$resignCount = Util::round($npccount2*(rand()%21+90)/100);
|
||||
$resignCount = Util::round($npccount2 * (rand() % 21 + 90) / 100);
|
||||
}
|
||||
$npcList = $db->queryFirstColumn('SELECT no FROM general WHERE nation=%i AND npc>=2 AND npc != 5 ORDER BY rand() LIMIT %i', $you['nation'], $resignCount);
|
||||
if($npcList){
|
||||
if ($npcList) {
|
||||
$db->update('general_turn', [
|
||||
'action'=>'che_하야',
|
||||
'arg'=>null,
|
||||
'brief'=>'하야',
|
||||
'action' => 'che_하야',
|
||||
'arg' => null,
|
||||
'brief' => '하야',
|
||||
], 'general_id IN %li AND turn_idx = 0');
|
||||
}
|
||||
|
||||
@@ -822,133 +836,202 @@ function checkSurrender() {
|
||||
}
|
||||
}
|
||||
|
||||
function updateNationState() {
|
||||
function updateNationState()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
$history = array();
|
||||
$admin = $gameStor->getValues(['year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
|
||||
$admin = $gameStor->getValues(['killturn', 'year', 'month', 'fiction', 'startyear', 'show_img_level', 'turnterm', 'turntime']);
|
||||
|
||||
$assemblerCnts = [];
|
||||
foreach($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]){
|
||||
foreach ($db->queryAllLists('SELECT nation,count(no) FROM general WHERE npc = 5 GROUP BY nation') as [$nationID, $assemblerCnt]) {
|
||||
$assemblerCnts[$nationID] = $assemblerCnt;
|
||||
};
|
||||
|
||||
foreach($db->query('SELECT nation,name,level,tech FROM nation') as $nation) {
|
||||
foreach ($db->query('SELECT nation,name,level,tech,aux FROM nation') as $nation) {
|
||||
//TODO: level이 진관수이소중대특 체계를 벗어날 수 있음
|
||||
$citycount = $db->queryFirstField('SELECT count(*) FROM city WHERE nation=%i AND level>=4', $nation['nation']);
|
||||
|
||||
if($citycount == 0) {
|
||||
if ($citycount == 0) {
|
||||
$nationlevel = 0; // 방랑군
|
||||
} elseif($citycount == 1) {
|
||||
} elseif ($citycount == 1) {
|
||||
$nationlevel = 1; // 호족
|
||||
} elseif($citycount <= 4) {
|
||||
} elseif ($citycount <= 4) {
|
||||
$nationlevel = 2; // 군벌
|
||||
} elseif($citycount <= 7) {
|
||||
} elseif ($citycount <= 7) {
|
||||
$nationlevel = 3; // 주자사
|
||||
} elseif($citycount <= 10) {
|
||||
} elseif ($citycount <= 10) {
|
||||
$nationlevel = 4; // 주목
|
||||
} elseif($citycount <= 15) {
|
||||
} elseif ($citycount <= 15) {
|
||||
$nationlevel = 5; // 공
|
||||
} elseif($citycount <= 20) {
|
||||
} elseif ($citycount <= 20) {
|
||||
$nationlevel = 6; // 왕
|
||||
} else {
|
||||
$nationlevel = 7; // 황제
|
||||
}
|
||||
|
||||
if ($nationlevel > $nation['level']) {
|
||||
$levelDiff = $nationlevel - $nation['level'];
|
||||
$oldLevel = $nation['level'];
|
||||
$nation['level'] = $nationlevel;
|
||||
|
||||
$updateVals = [
|
||||
'level' => $nationlevel
|
||||
];
|
||||
|
||||
switch ($nationlevel) {
|
||||
case 7:
|
||||
$josaUl = JosaUtil::pick(getNationLevel($nationlevel), '을');
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>{$josaUl} 자칭하였습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>{$josaUl} 자칭"]);
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭하였습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>{$josaUl} 자칭"]);
|
||||
$auxVal = Json::decode($nation['aux']);
|
||||
$auxVal['can_국기변경'] = 1;
|
||||
$auxVal['can_국호변경'] = 1;
|
||||
$updateVals['aux'] = Json::encode($auxVal);
|
||||
break;
|
||||
case 6:
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>에 등극하였습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>에 등극"]);
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극하였습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 등극"]);
|
||||
break;
|
||||
case 5:
|
||||
case 4:
|
||||
case 3:
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>에 임명되었습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>에 임명됨"]);
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명되었습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>에 임명됨"]);
|
||||
break;
|
||||
case 2:
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 독립하여 <Y>".getNationLevel($nationlevel)."</>로 나섰습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>".getNationLevel($nationlevel)."</>로 나서다"]);
|
||||
$history[] = "<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【작위】</b></><D><b>{$nation['name']}</b></>의 군주가 독립하여 <Y>" . getNationLevel($nationlevel) . "</>로 나섰습니다.";
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>의 군주가 <Y>" . getNationLevel($nationlevel) . "</>로 나서다"]);
|
||||
break;
|
||||
}
|
||||
|
||||
$db->update('nation', [
|
||||
'level'=>$nation['level']
|
||||
], 'nation=%i', $nation['nation']);
|
||||
$db->update('nation', $updateVals, 'nation=%i', $nation['nation']);
|
||||
|
||||
$turnRows = [];
|
||||
foreach(Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel){
|
||||
foreach(Util::range(GameConst::$maxChiefTurn) as $turnIdx){
|
||||
foreach (Util::range(getNationChiefLevel($nation['level']), 12) as $chiefLevel) {
|
||||
foreach (Util::range(GameConst::$maxChiefTurn) as $turnIdx) {
|
||||
$turnRows[] = [
|
||||
'nation_id'=>$nation['nation'],
|
||||
'officer_level'=>$chiefLevel,
|
||||
'turn_idx'=>$turnIdx,
|
||||
'action'=>'휴식',
|
||||
'arg'=>null,
|
||||
'brief'=>'휴식'
|
||||
'nation_id' => $nation['nation'],
|
||||
'officer_level' => $chiefLevel,
|
||||
'turn_idx' => $turnIdx,
|
||||
'action' => '휴식',
|
||||
'arg' => null,
|
||||
'brief' => '휴식'
|
||||
];
|
||||
}
|
||||
}
|
||||
$db->insertIgnore('nation_turn', $turnRows);
|
||||
|
||||
if ($levelDiff) {
|
||||
//유니크 아이템 하나 돌리자
|
||||
$targetKillTurn = $admin['killturn'];
|
||||
$targetKillTurn -= 24 * 60 / $admin['turnterm'];
|
||||
$nationGenIDList = $db->queryFirstColumn(
|
||||
'SELECT no FROM general WHERE nation = %i AND killturn >= %i AND npc < 2',
|
||||
$nation['nation'],
|
||||
$targetKillTurn
|
||||
);
|
||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong'], 2);
|
||||
|
||||
$uniqueLotteryWeightList = [];
|
||||
foreach ($nationGenList as $nationGen) {
|
||||
$hasUnique = false;
|
||||
foreach ($nationGen->getItems() as $item) {
|
||||
if (!$item->isBuyable()) {
|
||||
$hasUnique = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasUnique) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$score = $nationGen->getVar('belong') + 5;
|
||||
|
||||
if ($nationGen->getVar('officer_level') == 12) {
|
||||
$score += 200; //NOTE: 꼬우면 군주하세요.
|
||||
} else if ($nationGen->getVar('officer_level') == 11) {
|
||||
$score += 70;
|
||||
} else if ($nationGen->getVar('officer_level') > 4) {
|
||||
$score += 35;
|
||||
}
|
||||
$uniqueLotteryWeightList[$nationGen->getID()] = [$nationGen, $score];
|
||||
}
|
||||
|
||||
foreach (Util::range($levelDiff) as $idx) {
|
||||
if(!$uniqueLotteryWeightList){
|
||||
break;
|
||||
}
|
||||
|
||||
/** @var General */
|
||||
$winnerObj = Util::choiceRandomUsingWeightPair($uniqueLotteryWeightList);
|
||||
unset($uniqueLotteryWeightList[$winnerObj->getID()]);
|
||||
giveRandomUniqueItem($winnerObj, '작위보상');
|
||||
$winnerObj->applyDB($db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$assemblerCnt = $assemblerCnts[$nation['nation']]??0;
|
||||
$assemblerCnt = $assemblerCnts[$nation['nation']] ?? 0;
|
||||
$maxAssemblerCnt = [
|
||||
1=>0,
|
||||
2=>1,
|
||||
3=>3,
|
||||
4=>4,
|
||||
5=>6,
|
||||
6=>7,
|
||||
7=>9
|
||||
][$nationlevel]??0;
|
||||
1 => 0,
|
||||
2 => 1,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
5 => 6,
|
||||
6 => 7,
|
||||
7 => 9
|
||||
][$nationlevel] ?? 0;
|
||||
|
||||
if($assemblerCnt < $maxAssemblerCnt){
|
||||
$lastAssemblerID = $gameStor->assembler_id??0;
|
||||
if ($assemblerCnt < $maxAssemblerCnt) {
|
||||
$lastAssemblerID = $gameStor->assembler_id ?? 0;
|
||||
|
||||
while($assemblerCnt < $maxAssemblerCnt){
|
||||
while ($assemblerCnt < $maxAssemblerCnt) {
|
||||
$lastAssemblerID += 1;
|
||||
$npcObj = new Scenario\NPC(
|
||||
999, sprintf('부대장%4d',$lastAssemblerID), null, $nation['nation'], null,
|
||||
10, 10, 10, 1, $admin['year'] - 15, $admin['year'] + 15, '은둔', '척사'
|
||||
999,
|
||||
sprintf('부대장%4d', $lastAssemblerID),
|
||||
null,
|
||||
$nation['nation'],
|
||||
null,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
1,
|
||||
$admin['year'] - 15,
|
||||
$admin['year'] + 15,
|
||||
'은둔',
|
||||
'척사'
|
||||
);
|
||||
$npcObj->killturn = 70;
|
||||
$npcObj->gold=0;
|
||||
$npcObj->rice=0;
|
||||
$npcObj->gold = 0;
|
||||
$npcObj->rice = 0;
|
||||
$npcObj->npc = 5;
|
||||
$npcObj->build($admin);
|
||||
$npcID = $npcObj->generalID;
|
||||
|
||||
|
||||
$db->insert('troop', [
|
||||
'troop_leader'=>$npcID,
|
||||
'name'=>$npcObj->realName,
|
||||
'nation'=>$nation['nation'],
|
||||
'troop_leader' => $npcID,
|
||||
'name' => $npcObj->realName,
|
||||
'nation' => $nation['nation'],
|
||||
]);
|
||||
$db->update('general', [
|
||||
'troop'=>$npcID
|
||||
'troop' => $npcID
|
||||
], 'no=%i', $npcID);
|
||||
|
||||
|
||||
//TODO: 5턴간 집합턴 입력
|
||||
$assemblerCnt += 1;
|
||||
$gameStor->assembler_id = $lastAssemblerID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
pushWorldHistory($history, $admin['year'], $admin['month']);
|
||||
}
|
||||
|
||||
function checkStatistic() {
|
||||
function checkStatistic()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
@@ -963,8 +1046,8 @@ function checkStatistic() {
|
||||
$etc = '';
|
||||
|
||||
$auxData = [
|
||||
'generals'=>[],
|
||||
'nations'=>[],
|
||||
'generals' => [],
|
||||
'nations' => [],
|
||||
];
|
||||
|
||||
$avgGeneral = $db->queryFirstRow(
|
||||
@@ -982,7 +1065,8 @@ function checkStatistic() {
|
||||
|
||||
$avgNation = $db->queryFirstRow(
|
||||
'SELECT min(tech) as mintech, max(tech) as maxtech, avg(tech) as avgtech,
|
||||
min(power) as minpower, max(power) as maxpower, avg(power) as avgpower from nation where level>0');
|
||||
min(power) as minpower, max(power) as maxpower, avg(power) as avgpower from nation where level>0'
|
||||
);
|
||||
$auxData['nations']['avg'] = $avgNation;
|
||||
|
||||
$avgNation['mintech'] = floor($avgNation['mintech']);
|
||||
@@ -991,13 +1075,14 @@ function checkStatistic() {
|
||||
$avgNation['avgpower'] = Util::round($avgNation['avgpower']);
|
||||
$etc .= "최저/평균/최고 기술({$avgNation['mintech']}/{$avgNation['avgtech']}/{$avgNation['maxtech']}), ";
|
||||
$etc .= "최저/평균/최고 국력({$avgNation['minpower']}/{$avgNation['avgpower']}/{$avgNation['maxpower']}), ";
|
||||
|
||||
|
||||
$nationName = '';
|
||||
$powerHist = '';
|
||||
|
||||
$nations = Util::convertArrayToDict(
|
||||
$db->query(
|
||||
'SELECT nation,name,type,power,gennum,gold+rice as goldrice from nation where level>0 order by power desc', 'nation'
|
||||
'SELECT nation,name,type,power,gennum,gold+rice as goldrice from nation where level>0 order by power desc',
|
||||
'nation'
|
||||
),
|
||||
'nation'
|
||||
);
|
||||
@@ -1017,17 +1102,17 @@ function checkStatistic() {
|
||||
'nation'
|
||||
);
|
||||
|
||||
foreach($nations as $nationNo=>&$nation) {
|
||||
foreach ($nations as $nationNo => &$nation) {
|
||||
$general = $nationGeneralInfos[$nationNo];
|
||||
$city = $nationCityInfos[$nationNo];
|
||||
|
||||
|
||||
$nation['generalInfo'] = $general;
|
||||
$nation['cityInfo'] = $city;
|
||||
|
||||
$nationName .= $nation['name'].'('.getNationType($nation['type']).'), ';
|
||||
$nationName .= $nation['name'] . '(' . getNationType($nation['type']) . '), ';
|
||||
$powerHist .= "{$nation['name']}({$nation['power']}/{$nation['gennum']}/{$city['cnt']}/{$city['pop']}/{$city['pop_max']}/{$nation['goldrice']}/{$general['goldrice']}/{$general['abil']}/{$general['dex']}/{$general['expded']}), ";
|
||||
|
||||
if(!isset($nationHists[$nation['type']])){
|
||||
if (!isset($nationHists[$nation['type']])) {
|
||||
$nationHists[$nation['type']] = 0;
|
||||
}
|
||||
$nationHists[$nation['type']]++;
|
||||
@@ -1037,9 +1122,11 @@ function checkStatistic() {
|
||||
$auxData['nations']['all'] = $nations;
|
||||
|
||||
$nationHist = '';
|
||||
foreach(GameConst::$availableNationType as $nationType){
|
||||
if(!Util::array_get($nationHists[$nationType])) { $nationHists[$nationType] = '-'; }
|
||||
$nationHist .= getNationType($nationType)."({$nationHists[$nationType]}), ";
|
||||
foreach (GameConst::$availableNationType as $nationType) {
|
||||
if (!Util::array_get($nationHists[$nationType])) {
|
||||
$nationHists[$nationType] = '-';
|
||||
}
|
||||
$nationHist .= getNationType($nationType) . "({$nationHists[$nationType]}), ";
|
||||
}
|
||||
|
||||
$generals = $db->query('SELECT `no`,npc,personal,special,special2,crewtype FROM general');
|
||||
@@ -1048,24 +1135,23 @@ function checkStatistic() {
|
||||
$npcCount = 0;
|
||||
$generalCount = count($generals);
|
||||
|
||||
foreach($generals as $general) {
|
||||
if(!isset($personalHists[$general['personal']])){
|
||||
foreach ($generals as $general) {
|
||||
if (!isset($personalHists[$general['personal']])) {
|
||||
$personalHists[$general['personal']] = 0;
|
||||
}
|
||||
|
||||
if(!isset($specialHists[$general['special']])){
|
||||
if (!isset($specialHists[$general['special']])) {
|
||||
$specialHists[$general['special']] = 0;
|
||||
}
|
||||
|
||||
if(!isset($specialHists2[$general['special2']])){
|
||||
if (!isset($specialHists2[$general['special2']])) {
|
||||
$specialHists2[$general['special2']] = 0;
|
||||
}
|
||||
|
||||
if($general['npc'] < 2){
|
||||
$genCount+=1;
|
||||
}
|
||||
else{
|
||||
$npcCount+=1;
|
||||
if ($general['npc'] < 2) {
|
||||
$genCount += 1;
|
||||
} else {
|
||||
$npcCount += 1;
|
||||
}
|
||||
|
||||
$personalHists[$general['personal']]++;
|
||||
@@ -1073,10 +1159,9 @@ function checkStatistic() {
|
||||
$specialHists2[$general['special2']]++;
|
||||
}
|
||||
|
||||
foreach($db->queryAllLists(
|
||||
foreach ($db->queryAllLists(
|
||||
'SELECT crewtype, count(crewtype) AS cnt FROM general WHERE recent_war != NULL GROUP BY crewtype'
|
||||
) as [$crewtype, $cnt]
|
||||
){
|
||||
) as [$crewtype, $cnt]) {
|
||||
$crewtypeHists[$crewtype] = $cnt;
|
||||
}
|
||||
|
||||
@@ -1091,63 +1176,64 @@ function checkStatistic() {
|
||||
|
||||
$generalCountStr = "{$generalCount}({$genCount}+{$npcCount})";
|
||||
|
||||
$personalHistStr = join(', ', array_map(function($histPair){
|
||||
$personalHistStr = join(', ', array_map(function ($histPair) {
|
||||
[$histKey, $cnt] = $histPair;
|
||||
return getGenChar($histKey).'('.$cnt.')';
|
||||
return getGenChar($histKey) . '(' . $cnt . ')';
|
||||
}, Util::convertDictToArray($personalHists)));
|
||||
|
||||
$specialHistsStr = join(', ', array_map(function($histPair){
|
||||
$specialHistsStr = join(', ', array_map(function ($histPair) {
|
||||
[$histKey, $cnt] = $histPair;
|
||||
return getGeneralSpecialDomesticName($histKey).'('.$cnt.')';
|
||||
return getGeneralSpecialDomesticName($histKey) . '(' . $cnt . ')';
|
||||
}, Util::convertDictToArray($specialHists)));
|
||||
|
||||
$specialHists2Str = join(', ', array_map(function($histPair){
|
||||
$specialHists2Str = join(', ', array_map(function ($histPair) {
|
||||
[$histKey, $cnt] = $histPair;
|
||||
return getGeneralSpecialWarName($histKey).'('.$cnt.')';
|
||||
return getGeneralSpecialWarName($histKey) . '(' . $cnt . ')';
|
||||
}, Util::convertDictToArray($specialHists2)));
|
||||
|
||||
$specialHistsAllStr = "$specialHistsStr // $specialHists2Str";
|
||||
|
||||
$crewtypeHistsStr = join(', ', array_map(function($histPair){
|
||||
$crewtypeHistsStr = join(', ', array_map(function ($histPair) {
|
||||
[$histKey, $cnt] = $histPair;
|
||||
return GameUnitConst::byID($histKey)->getShortName().'('.$cnt.')';
|
||||
return GameUnitConst::byID($histKey)->getShortName() . '(' . $cnt . ')';
|
||||
}, Util::convertDictToArray($crewtypeHists)));
|
||||
|
||||
$db->insert('statistic', [
|
||||
'year'=>$admin['year'],
|
||||
'month'=>$admin['month'],
|
||||
'nation_count'=>$nationCount,
|
||||
'nation_name'=>$nationName,
|
||||
'nation_hist'=>$nationHist,
|
||||
'gen_count'=>$generalCountStr,
|
||||
'personal_hist'=>$personalHistStr,
|
||||
'special_hist'=>$specialHistsAllStr,
|
||||
'power_hist'=>$powerHist,
|
||||
'crewtype'=>$crewtypeHistsStr,
|
||||
'etc'=>$etc,
|
||||
'aux'=>Json::encode($auxData)
|
||||
]);
|
||||
|
||||
$db->insert('statistic', [
|
||||
'year' => $admin['year'],
|
||||
'month' => $admin['month'],
|
||||
'nation_count' => $nationCount,
|
||||
'nation_name' => $nationName,
|
||||
'nation_hist' => $nationHist,
|
||||
'gen_count' => $generalCountStr,
|
||||
'personal_hist' => $personalHistStr,
|
||||
'special_hist' => $specialHistsAllStr,
|
||||
'power_hist' => $powerHist,
|
||||
'crewtype' => $crewtypeHistsStr,
|
||||
'etc' => $etc,
|
||||
'aux' => Json::encode($auxData)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
function convForOldGeneral(array $general, int $year, int $month){
|
||||
function convForOldGeneral(array $general, int $year, int $month)
|
||||
{
|
||||
$general['history'] = getGeneralHistoryAll($general['no']);
|
||||
return [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'general_no'=>$general['no'],
|
||||
'owner'=>$general['owner'],
|
||||
'name'=>$general['name'],
|
||||
'last_yearmonth'=>$year*100+$month,
|
||||
'turntime'=>$general['turntime'],
|
||||
'data'=>Json::encode($general)
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'general_no' => $general['no'],
|
||||
'owner' => $general['owner'],
|
||||
'name' => $general['name'],
|
||||
'last_yearmonth' => $year * 100 + $month,
|
||||
'turntime' => $general['turntime'],
|
||||
'data' => Json::encode($general)
|
||||
];
|
||||
}
|
||||
|
||||
function storeOldGeneral(int $no, int $year, int $month){
|
||||
function storeOldGeneral(int $no, int $year, int $month)
|
||||
{
|
||||
$db = DB::db();
|
||||
$general = $db->queryFirstRow('SELECT * FROM general WHERE `no` = %i', $no);
|
||||
if(!$general){
|
||||
if (!$general) {
|
||||
return;
|
||||
}
|
||||
$data = convForOldGeneral($general, $year, $month);
|
||||
@@ -1158,9 +1244,10 @@ function storeOldGeneral(int $no, int $year, int $month){
|
||||
);
|
||||
}
|
||||
|
||||
function storeOldGenerals(int $nation, int $year, int $month){
|
||||
function storeOldGenerals(int $nation, int $year, int $month)
|
||||
{
|
||||
$db = DB::db();
|
||||
foreach($db->query('SELECT * FROM general WHERE nation = %i',$nation) as $general){
|
||||
foreach ($db->query('SELECT * FROM general WHERE nation = %i', $nation) as $general) {
|
||||
$data = convForOldGeneral($general, $year, $month);
|
||||
$db->insertUpdate(
|
||||
'ng_old_generals',
|
||||
@@ -1170,25 +1257,26 @@ function storeOldGenerals(int $nation, int $year, int $month){
|
||||
}
|
||||
}
|
||||
|
||||
function checkEmperior() {
|
||||
function checkEmperior()
|
||||
{
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$connect=$db->get();
|
||||
$connect = $db->get();
|
||||
|
||||
$admin = $gameStor->getValues(['year', 'month', 'isunited']);
|
||||
|
||||
$query = "select nation,name from nation where level>0";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$count = MYDB_num_rows($result);
|
||||
|
||||
if ($count != 1 || $admin['isunited'] != 0) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
$count = $db->queryFirstField('SELECT count(city) FROM city WHERE nation=%i', $nation['nation']);
|
||||
if(!$count){
|
||||
if (!$count) {
|
||||
return;
|
||||
}
|
||||
$allcount = $db->queryFirstField('SELECT count(city) FROM city');
|
||||
@@ -1204,21 +1292,21 @@ function checkEmperior() {
|
||||
pushNationHistory($nation['nation'], ["<C>●</>{$admin['year']}년 {$admin['month']}월:<D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일"]);
|
||||
|
||||
$gameStor->isunited = 2;
|
||||
$gameStor->conlimit = $gameStor->conlimit*100;
|
||||
$gameStor->conlimit = $gameStor->conlimit * 100;
|
||||
|
||||
foreach($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo){
|
||||
foreach ($db->queryFirstColumn('SELECT no FROM general WHERE npc<2 AND age>=%i', GameConst::$minPushHallAge) as $hallGeneralNo) {
|
||||
CheckHall($hallGeneralNo);
|
||||
}
|
||||
|
||||
$query = "select nation,name,type,color,gold,rice,power,gennum from nation where nation='{$nation['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select SUM(pop) as totalpop,SUM(pop_max) as maxpop from city where nation='{$nation['nation']}'"; // 도시 이름 목록
|
||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$cityresult = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$city = MYDB_fetch_array($cityresult);
|
||||
$pop = "{$city['totalpop']} / {$city['maxpop']}";
|
||||
$poprate = round($city['totalpop']/$city['maxpop']*100, 2);
|
||||
$poprate = round($city['totalpop'] / $city['maxpop'] * 100, 2);
|
||||
$poprate .= " %";
|
||||
|
||||
$chiefs = Util::convertArrayToDict(
|
||||
@@ -1233,24 +1321,26 @@ function checkEmperior() {
|
||||
$oldNationGenerals = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=%i', $nation['nation']);
|
||||
$oldNation['generals'] = $oldNationGenerals;
|
||||
|
||||
$tigers = $db->query('SELECT value, name
|
||||
$tigers = $db->query(
|
||||
'SELECT value, name
|
||||
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
||||
WHERE rank_data.nation_id = %i AND rank_data.type = "warnum" AND value > 0 ORDER BY value DESC LIMIT 5',
|
||||
$nation['nation']
|
||||
);// 오호장군
|
||||
); // 오호장군
|
||||
|
||||
$tigerstr = join(', ', array_map(function($arr){
|
||||
$tigerstr = join(', ', array_map(function ($arr) {
|
||||
$number = number_format($arr['value']);
|
||||
return "{$arr['name']}【{$number}】";
|
||||
}, $tigers));
|
||||
|
||||
$eagles = $db->query('SELECT value, name
|
||||
$eagles = $db->query(
|
||||
'SELECT value, name
|
||||
FROM rank_data LEFT JOIN general ON rank_data.general_id = general.no
|
||||
WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7',
|
||||
WHERE rank_data.nation_id = %i AND rank_data.type = "firenum" AND value > 0 ORDER BY value DESC LIMIT 7',
|
||||
$nation['nation']
|
||||
);// 건안칠자
|
||||
); // 건안칠자
|
||||
|
||||
$eaglestr = join(', ', array_map(function($arr){
|
||||
$eaglestr = join(', ', array_map(function ($arr) {
|
||||
$number = number_format($arr['value']);
|
||||
return "{$arr['name']}【{$number}】";
|
||||
}, $eagles));
|
||||
@@ -1258,10 +1348,10 @@ function checkEmperior() {
|
||||
$log = ["<C>●</>{$admin['year']}년 {$admin['month']}월: <D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일하였습니다."];
|
||||
|
||||
$query = "select no,name from general where nation='{$nation['nation']}' order by dedication desc";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
$gen = '';
|
||||
for($i=0; $i < $gencount; $i++) {
|
||||
for ($i = 0; $i < $gencount; $i++) {
|
||||
$general = MYDB_fetch_array($result);
|
||||
$gen .= "{$general['name']}, ";
|
||||
|
||||
@@ -1271,22 +1361,22 @@ function checkEmperior() {
|
||||
$nation['type'] = getNationType($nation['type']);
|
||||
|
||||
$query = "select MAX(nation_count) as nc,MAX(gen_count) as gc from statistic";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$stat = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select count(*) as cnt from general";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$gencount = MYDB_fetch_array($result);
|
||||
|
||||
$statNC = "1 / {$stat['nc']}";
|
||||
$statGC = "{$gencount['cnt']} / {$stat['gc']}";
|
||||
|
||||
$query = "select nation_count,nation_name,nation_hist from statistic where nation_count='{$stat['nc']}' limit 0,1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$statNation = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select gen_count,personal_hist,special_hist,aux from statistic order by no desc limit 0,1";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__ . MYDB_error($connect), "");
|
||||
$statGeneral = MYDB_fetch_array($result);
|
||||
|
||||
$oldNation = $db->queryFirstRow('SELECT * FROM nation WHERE nation=%i', $nation['nation']);
|
||||
@@ -1298,19 +1388,19 @@ function checkEmperior() {
|
||||
storeOldGenerals($nation['nation'], $admin['year'], $admin['month']);
|
||||
|
||||
$db->insert('ng_old_nations', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation'=>$nation['nation'],
|
||||
'data'=>Json::encode($oldNation)
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation' => $nation['nation'],
|
||||
'data' => Json::encode($oldNation)
|
||||
]);
|
||||
|
||||
$noNationGeneral = $db->queryFirstColumn('SELECT `no` FROM general WHERE nation=0');
|
||||
$db->insert('ng_old_nations', [
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation'=>0,
|
||||
'data'=>Json::encode([
|
||||
'nation'=>0,
|
||||
'name'=>'재야',
|
||||
'generals'=>$noNationGeneral
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation' => 0,
|
||||
'data' => Json::encode([
|
||||
'nation' => 0,
|
||||
'name' => '재야',
|
||||
'generals' => $noNationGeneral
|
||||
])
|
||||
]);
|
||||
|
||||
@@ -1320,51 +1410,51 @@ function checkEmperior() {
|
||||
$serverName = UniqueConst::$serverName;
|
||||
|
||||
$db->update('ng_games', [
|
||||
'winner_nation'=>$nation['nation']
|
||||
'winner_nation' => $nation['nation']
|
||||
], 'server_id=%s', UniqueConst::$serverID);
|
||||
|
||||
$db->insert('emperior', [
|
||||
'phase'=>$serverName.$serverCnt.'기',
|
||||
'server_id'=>UniqueConst::$serverID,
|
||||
'nation_count'=>$statNC,
|
||||
'nation_name'=>$statNation['nation_name'],
|
||||
'nation_hist'=>$statNation['nation_hist'],
|
||||
'gen_count'=>$statGC,
|
||||
'personal_hist'=>$statGeneral['personal_hist'],
|
||||
'special_hist'=>$statGeneral['special_hist'],
|
||||
'name'=>$nation['name'],
|
||||
'type'=>$nation['type'],
|
||||
'color'=>$nation['color'],
|
||||
'year'=>$admin['year'],
|
||||
'month'=>$admin['month'],
|
||||
'power'=>$nation['power'],
|
||||
'gennum'=>$nation['gennum'],
|
||||
'citynum'=>$allcount,
|
||||
'pop'=>$pop,
|
||||
'poprate'=>$poprate,
|
||||
'gold'=>$nation['gold'],
|
||||
'rice'=>$nation['rice'],
|
||||
'l12name'=>$chiefs[12]['name'],
|
||||
'l12pic'=>$chiefs[12]['picture'],
|
||||
'l11name'=>$chiefs[11]['name'],
|
||||
'l11pic'=>$chiefs[11]['picture'],
|
||||
'l10name'=>$chiefs[10]['name'],
|
||||
'l10pic'=>$chiefs[10]['picture'],
|
||||
'l9name'=>$chiefs[9]['name'],
|
||||
'l9pic'=>$chiefs[9]['picture'],
|
||||
'l8name'=>$chiefs[8]['name'],
|
||||
'l8pic'=>$chiefs[8]['picture'],
|
||||
'l7name'=>$chiefs[7]['name'],
|
||||
'l7pic'=>$chiefs[7]['picture'],
|
||||
'l6name'=>$chiefs[6]['name'],
|
||||
'l6pic'=>$chiefs[6]['picture'],
|
||||
'l5name'=>$chiefs[5]['name'],
|
||||
'l5pic'=>$chiefs[5]['picture'],
|
||||
'tiger'=>$tigerstr,
|
||||
'eagle'=>$eaglestr,
|
||||
'gen'=>$gen,
|
||||
'history'=>$nationHistory,
|
||||
'aux'=>$statGeneral['aux']
|
||||
'phase' => $serverName . $serverCnt . '기',
|
||||
'server_id' => UniqueConst::$serverID,
|
||||
'nation_count' => $statNC,
|
||||
'nation_name' => $statNation['nation_name'],
|
||||
'nation_hist' => $statNation['nation_hist'],
|
||||
'gen_count' => $statGC,
|
||||
'personal_hist' => $statGeneral['personal_hist'],
|
||||
'special_hist' => $statGeneral['special_hist'],
|
||||
'name' => $nation['name'],
|
||||
'type' => $nation['type'],
|
||||
'color' => $nation['color'],
|
||||
'year' => $admin['year'],
|
||||
'month' => $admin['month'],
|
||||
'power' => $nation['power'],
|
||||
'gennum' => $nation['gennum'],
|
||||
'citynum' => $allcount,
|
||||
'pop' => $pop,
|
||||
'poprate' => $poprate,
|
||||
'gold' => $nation['gold'],
|
||||
'rice' => $nation['rice'],
|
||||
'l12name' => $chiefs[12]['name'],
|
||||
'l12pic' => $chiefs[12]['picture'],
|
||||
'l11name' => $chiefs[11]['name'],
|
||||
'l11pic' => $chiefs[11]['picture'],
|
||||
'l10name' => $chiefs[10]['name'],
|
||||
'l10pic' => $chiefs[10]['picture'],
|
||||
'l9name' => $chiefs[9]['name'],
|
||||
'l9pic' => $chiefs[9]['picture'],
|
||||
'l8name' => $chiefs[8]['name'],
|
||||
'l8pic' => $chiefs[8]['picture'],
|
||||
'l7name' => $chiefs[7]['name'],
|
||||
'l7pic' => $chiefs[7]['picture'],
|
||||
'l6name' => $chiefs[6]['name'],
|
||||
'l6pic' => $chiefs[6]['picture'],
|
||||
'l5name' => $chiefs[5]['name'],
|
||||
'l5pic' => $chiefs[5]['picture'],
|
||||
'tiger' => $tigerstr,
|
||||
'eagle' => $eaglestr,
|
||||
'gen' => $gen,
|
||||
'history' => $nationHistory,
|
||||
'aux' => $statGeneral['aux']
|
||||
]);
|
||||
|
||||
$history = ["<C>●</>{$admin['year']}년 {$admin['month']}월:<Y><b>【통일】</b></><D><b>{$nation['name']}</b></>{$josaYi} 전토를 통일하였습니다."];
|
||||
|
||||
@@ -11,7 +11,8 @@ use\sammo\{
|
||||
GameConst,
|
||||
GameUnitConst,
|
||||
LastTurn,
|
||||
Command
|
||||
Command,
|
||||
Json
|
||||
};
|
||||
|
||||
|
||||
@@ -79,7 +80,7 @@ class che_건국 extends Command\GeneralCommand
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['gennum']);
|
||||
$this->setNation(['gennum', 'aux']);
|
||||
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
@@ -173,6 +174,9 @@ class che_건국 extends Command\GeneralCommand
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
|
||||
$aux = Json::decode($this->nation['aux'])??[];
|
||||
$aux['can_국기변경'] = 1;
|
||||
|
||||
$db->update('city', [
|
||||
'nation' => $general->getNationID(),
|
||||
'conflict' => '{}'
|
||||
@@ -183,7 +187,8 @@ class che_건국 extends Command\GeneralCommand
|
||||
'color' => $colorType,
|
||||
'level' => 1,
|
||||
'type' => $nationType,
|
||||
'capital' => $general->getCityID()
|
||||
'capital' => $general->getCityID(),
|
||||
'aux' => Json::encode($aux)
|
||||
], 'nation=%i', $general->getNationID());
|
||||
|
||||
refreshNationStaticInfo();
|
||||
|
||||
@@ -15,7 +15,8 @@ use\sammo\{
|
||||
Command,
|
||||
MessageTarget,
|
||||
Message,
|
||||
CityConst
|
||||
CityConst,
|
||||
Json,
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
@@ -64,23 +65,27 @@ class che_국기변경 extends Command\NationCommand
|
||||
$env = $this->env;
|
||||
|
||||
$this->setCity();
|
||||
$this->setNation(['can_change_flag']);
|
||||
$this->setNation(['aux']);
|
||||
|
||||
$actionName = $this->getName();
|
||||
|
||||
$this->minConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqNationValue('can_change_flag', '국기색', '>', 0, '더이상 변경이 불가능합니다.')
|
||||
ConstraintHelper::ReqNationAuxValue("can_{$actionName}", null, '>', 0, '더이상 변경이 불가능합니다.')
|
||||
];
|
||||
}
|
||||
|
||||
protected function initWithArg()
|
||||
{
|
||||
$actionName = $this->getName();
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::OccupiedCity(),
|
||||
ConstraintHelper::BeChief(),
|
||||
ConstraintHelper::SuppliedCity(),
|
||||
ConstraintHelper::ReqNationValue('can_change_flag', '국기색', '>', 0, '더이상 변경이 불가능합니다.')
|
||||
ConstraintHelper::ReqNationAuxValue("can_{$actionName}", null, '>', 0, '더이상 변경이 불가능합니다.')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -113,6 +118,7 @@ class che_국기변경 extends Command\NationCommand
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$actionName = $this->getName();
|
||||
|
||||
$general = $this->generalObj;
|
||||
$generalID = $general->getID();
|
||||
@@ -135,9 +141,12 @@ class che_국기변경 extends Command\NationCommand
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
$josaYiNation = JosaUtil::pick($nationName, '이');
|
||||
|
||||
$aux = Json::decode($this->nation['aux']);
|
||||
$aux["can_{$actionName}"] = 0;
|
||||
|
||||
$db->update('nation', [
|
||||
'color'=>$color,
|
||||
'can_change_flag' => $db->sqleval('can_change_flag - 1'),
|
||||
'aux'=>Json::encode($aux)
|
||||
], 'nation=%i', $nationID);
|
||||
|
||||
$logger->pushGeneralActionLog("<span style='color:{$color};'><b>국기</b></span>를 변경하였습니다 <1>$date</>");
|
||||
|
||||
@@ -158,6 +158,7 @@ class General implements iAction{
|
||||
return $this->itemObjs[$itemKey];
|
||||
}
|
||||
|
||||
/** @return BaseItem[] */
|
||||
function getItems():array{
|
||||
return $this->itemObjs;
|
||||
}
|
||||
@@ -512,7 +513,7 @@ class General implements iAction{
|
||||
}
|
||||
|
||||
function updateVar(string $key, $value){
|
||||
if($this->raw[$key] === $value){
|
||||
if(($this->raw[$key]??null) === $value){
|
||||
return;
|
||||
}
|
||||
if(!key_exists($key, $this->updatedVar)){
|
||||
|
||||
@@ -67,7 +67,7 @@ trait LazyVarUpdater{
|
||||
}
|
||||
|
||||
function updateVar(string $key, $value){
|
||||
if($this->raw[$key] === $value){
|
||||
if(($this->raw[$key]??null) === $value){
|
||||
return;
|
||||
}
|
||||
if(!key_exists($key, $this->updatedVar)){
|
||||
|
||||
@@ -116,7 +116,6 @@ CREATE TABLE `nation` (
|
||||
`nation` INT(6) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(64) NOT NULL COLLATE 'utf8mb4_bin',
|
||||
`color` CHAR(10) NOT NULL,
|
||||
`can_change_flag` INT(1) NULL DEFAULT '1',
|
||||
`onlinegen` TEXT NULL DEFAULT '',
|
||||
`msg` TEXT NULL DEFAULT '',
|
||||
`capital` INT(1) NULL DEFAULT '0',
|
||||
|
||||
Reference in New Issue
Block a user