feat: 세력도시에서 수입 정보 표기, NPC 색 누락분 수정

This commit is contained in:
2022-03-23 23:13:28 +09:00
parent 48af7e5e76
commit b08a2681a2
10 changed files with 132 additions and 126 deletions
+2 -2
View File
@@ -111,7 +111,7 @@ if ($con >= 2) {
}
$chief = $chiefs[$chiefLevel] ?? ['name' => '-', 'npc' => 0];
$officerLevelText = getOfficerLevelText($chiefLevel, $nation['level']);
$chiefText = getColoredName($chief['name'], $chief['npc']);
$chiefText = formatName($chief['name'], $chief['npc']);
echo "<td class='center bg1'>{$officerLevelText}</td>
<td class='center'>{$chiefText}</td>";
}
@@ -178,7 +178,7 @@ if ($con >= 2) {
<tr>
<td colspan=5> 장수 일람 : ";
foreach ($nations[0]['generals'] as $general) {
$generalText = getColoredName($general['name'], $general['npc']);
$generalText = formatName($general['name'], $general['npc']);
echo "{$generalText}, ";
}
echo "
+1 -1
View File
@@ -111,7 +111,7 @@ $sel[$type] = "selected";
</tr>
<?php foreach ($generalList as $general) : ?>
<tr>
<td align=center><?= getColoredName($general['name'], $general['npc']) ?></td>
<td align=center><?= formatName($general['name'], $general['npc']) ?></td>
<td align=center><?= $general['owner_name'] ?></td>
<td align=center>Lv <?= $general['explevel'] ?></td>
<td align=center><?= $nationName[$general['nation']] ?></td>
+1 -1
View File
@@ -364,7 +364,7 @@ $templates = new \League\Plates\Engine('templates');
}
$generalsName = array_map(function ($gen) {
return getColoredName($gen['name'], $gen['npc']);
return formatName($gen['name'], $gen['npc']);
}, $generals);
$enemyCrew = 0;
+1 -1
View File
@@ -172,7 +172,7 @@ $templates = new \League\Plates\Engine('templates');
$general['expLevelText'] = getExpLevel($general['experience']);
$general['nameText'] = getColoredName($general['name'], $general['npc']);
$general['nameText'] = formatName($general['name'], $general['npc']);
$general['modeText'] = formatDefenceTrain($general['defence_train']);
$general['crewtypeText'] = GameUnitConst::byId($general['crewtype'])->name ?? '-';
+72 -58
View File
@@ -71,7 +71,8 @@ $sel = [$type => "selected"];
</table>
<?php
$nation = getNationStaticInfo($me['nation']); //국가정보
$nation = $db->queryFirstRow('SELECT nation, name, color, type, level, capital, gennum, `power`, `rate` from nation WHERE nation = %i', $nationID); //국가정보
$nationTypeObj = buildNationTypeClass($nation['type']);
$officerList = [];
foreach ($db->query('SELECT no,name,npc,city,officer_level,officer_city,belong FROM general WHERE nation = %i AND 2 <= officer_level AND officer_level <= 4', $nationID) as $officer) {
@@ -82,6 +83,17 @@ $sel = [$type => "selected"];
$officerList[$officerCityID][$officer['officer_level']] = $officer;
}
$generalList = $db->query('SELECT npc, name, city FROM general WHERE nation = %i', $me['nation']);
$cityGeneralList = [];
foreach ($generalList as $general) {
$cityID = $general['city'];
if (!key_exists($cityID, $cityGeneralList)) {
$cityGeneralList[$cityID] = [];
}
$cityGeneralList[$cityID][] = formatName($general['name'], $general['npc']);
}
$cityList = $db->query('SELECT *,pop/pop_max as poprate from city where nation=%i', $nationID);
@@ -171,8 +183,12 @@ $sel = [$type => "selected"];
];
$cityOfficerList = $officerList[$cityID] ?? [];
$effectiveOfficerCnt = 0;
foreach ($cityOfficerList as $cityOfficer) {
$officerName[$cityOfficer['officer_level']] = getColoredName($cityOfficer['name'], $cityOfficer['npc']);
if ($cityOfficer['city'] == $cityID) {
$effectiveOfficerCnt += 1;
}
$officerName[$cityOfficer['officer_level']] = formatName($cityOfficer['name'], $cityOfficer['npc']);
}
if ($type == 10 && $city['region'] != $region) {
@@ -187,62 +203,60 @@ $sel = [$type => "selected"];
$city['trade'] = "- ";
}
echo "
<table align=center width=1000 class='tb_layout bg2'>
<tr>
<td colspan=12 style=color:" . newColor($nation['color']) . "; bgcolor={$nation['color']}><font size=2>【 " . CityConst::$regionMap[$city['region']] . " | " . CityConst::$levelMap[$city['level']] . " 】 {$city['name']}</font></td>
</tr>
<tr>
<td align=center width=46 class='bg1'>주민</td>
<td align=center width=140>{$city['pop']}/{$city['pop_max']}</td>
<td align=center width=46 class='bg1'>농업</td>
<td align=center width=140>{$city['agri']}/{$city['agri_max']}</td>
<td align=center width=46 class='bg1'>상업</td>
<td align=center width=140>{$city['comm']}/{$city['comm_max']}</td>
<td align=center width=46 class='bg1'>치안</td>
<td align=center width=140>{$city['secu']}/{$city['secu_max']}</td>
<td align=center width=46 class='bg1'>수비</td>
<td align=center width=140>{$city['def']}/{$city['def_max']}</td>
<td align=center width=46 class='bg1'>성벽</td>
<td align=center width=140>{$city['wall']}/{$city['wall_max']}</td>
</tr>
<tr>
<td align=center class='bg1'>민심</td>
<td align=center>" . round($city['trust'], 1) . "</td>
<td align=center class='bg1'>시세</td>
<td align=center>{$city['trade']}%</td>
<td align=center class='bg1'>인구</td>
<td align=center>" . round($city['pop'] / $city['pop_max'] * 100, 2) . " %</td>
<td align=center class='bg1'>태수</td>
<td align=center>";
echo $officerName[4];
echo "</td>
<td align=center class='bg1'>군사</td>
<td align=center>";
echo $officerName[3];
echo "</td>
<td align=center class='bg1'>종사</td>
<td align=center>";
echo $officerName[2];
echo "</td>
</tr>
<tr>
<td align=center class='bg1'>장수</td>
<td colspan=11>";
$generalList = $db->query('SELECT npc, name FROM general WHERE city = %i AND nation = %i', $city['city'], $me['nation']);
if (!$generalList) {
echo "-";
}
foreach ($generalList as $general) {
echo getColoredName($general['name'], $general['npc']) . ', ';
}
echo "
</td>
</tr>
</table>
";
}
$cityGoldIncome = $nation['rate'] / 20 * calcCityGoldIncome($city, $effectiveOfficerCnt, $nation['capital'] == $cityID, $nation['level'], $nationTypeObj);
$cityRiceIncome = $nation['rate'] / 20 * calcCityRiceIncome($city, $effectiveOfficerCnt, $nation['capital'] == $cityID, $nation['level'], $nationTypeObj);
$cityWallIncome = $nation['rate'] / 20 * calcCityWallRiceIncome($city, $effectiveOfficerCnt, $nation['capital'] == $cityID, $nation['level'], $nationTypeObj);
?>
<table align=center width=1000 class='tb_layout bg2'>
<tr>
<td colspan=10 style="color:<?= newColor($nation['color']) ?>; bgcolor=<?= $nation['color'] ?>;">
<font size=2>【 <?= CityConst::$regionMap[$city['region']] ?> | <?= CityConst::$levelMap[$city['level']] ?> 】 <?= $city['name'] ?></font>
</td>
</tr>
<tr style='text-align:center;'>
<td width=60 class='bg1'>주민</td>
<td width=140 class='pop-value'><?= $city['pop'] ?>/<?= $city['pop_max'] ?></td>
<td width=60 class='bg1'>인구율</td>
<td width=140 class='pop-prop-value'><?= round($city['pop'] / $city['pop_max'] * 100, 2) ?>%</td>
<td width=60 class='bg1'>자금 수입</td>
<td width=140 class='gold-income'><?= number_format($cityGoldIncome) ?></td>
<td width=60 class='bg1'>군량 수입</td>
<td width=140 class='rice-income'><?= number_format($cityRiceIncome) ?></td>
<td width=60 class='bg1'>둔전 수입</td>
<td width=140 class='wall-income'><?= number_format($cityWallIncome) ?></td>
</tr>
<tr style='text-align:center;'>
<td class='bg1'>농업</td>
<td class='agri-value'><?= $city['agri'] ?>/<?= $city['agri_max'] ?></td>
<td class='bg1'>상업</td>
<td class='comm-value'><?= $city['comm'] ?>/<?= $city['comm_max'] ?></td>
<td class='bg1'>치안</td>
<td class='secu-value'><?= $city['secu'] ?>/<?= $city['secu_max'] ?></td>
<td class='bg1'>수비</td>
<td class='def-value'><?= $city['def'] ?>/<?= $city['def_max'] ?></td>
<td class='bg1'>성벽</td>
<td class='wall-value'><?= $city['wall'] ?>/<?= $city['wall_max'] ?></td>
</tr>
<tr style='text-align:center;'>
<td class='bg1'>민심</td>
<td class='trust-value'><?= round($city['trust'], 1) ?></td>
<td class='bg1'>시세</td>
<td class='trade-value'><?= $city['trade'] ?>%</td>
<td class='bg1'>태수</td>
<td class='officer-4-value'><?= $officerName[4] ?></td>
<td class='bg1'>군사</td>
<td class='officer-3-value'><?= $officerName[3] ?></td>
<td class='bg1'>종사</td>
<td class='officer-2-value'><?= $officerName[2] ?></td>
</tr>
<tr>
<td style='text-align:center;' class='bg1'>장수</td>
<td colspan=9 class='city-generals'><?= key_exists($cityID, $cityGeneralList) ? join(', ', $cityGeneralList[$cityID]) : '-' ?></td>
</tr>
</table>
<?php } ?>
<table align=center width=1000 class='tb_layout bg0 anchor'>
<tr>
@@ -252,7 +266,7 @@ $sel = [$type => "selected"];
<td><?= banner() ?></td>
</tr>
</table>
<div id="helper_genlist" style="display:none;"></div>
</body>
<div id="helper_genlist" style="display:none;"></div>
</html>
+3 -3
View File
@@ -171,7 +171,7 @@ function cityInfo(General $generalObj)
];
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']);
$officerName[$officer['officer_level']] = formatName($officer['name'], $officer['npc']);
}
$city['officerName'] = $officerName;
@@ -199,8 +199,8 @@ function myNationInfo(General $generalObj)
$topChiefs = Util::convertArrayToDict($db->query('SELECT officer_level, no, name, npc FROM general WHERE nation = %i AND officer_level >= 11', $nationID), 'officer_level');
$level12Name = key_exists(12, $topChiefs) ? getColoredName($topChiefs[12]['name'], $topChiefs[12]['npc']) : '-';
$level11Name = key_exists(11, $topChiefs) ? getColoredName($topChiefs[11]['name'], $topChiefs[11]['npc']) : '-';
$level12Name = key_exists(12, $topChiefs) ? formatName($topChiefs[12]['name'], $topChiefs[12]['npc']) : '-';
$level11Name = key_exists(11, $topChiefs) ? formatName($topChiefs[11]['name'], $topChiefs[11]['npc']) : '-';
$impossibleStrategicCommandLists = [];
$strategicCommandLists = GameConst::$availableChiefCommand['전략'];
+22 -8
View File
@@ -692,21 +692,35 @@ function isConsumable(?string $item) : bool{
return $itemClass->isConsumable();
}
function getNameColor(int $npcType):?string{
if($npcType >= 2){
return 'cyan';
}
if($npcType == 1){
function getNPCColor(int $npc): ?string{
if ($npc == 1) {
return 'skyblue';
}
if ($npc == 4){
return 'deepskyblue';
}
if ($npc == 5){
return 'darkcyan';
}
if ($npc == 6){
return 'mediumaquamarine';
}
if ($npc > 1) {
return 'cyan';
}
return null;
}
function getColoredName(string $name, int $npcType):string{
$color = getNameColor($npcType);
function formatName(string $name, int $npc): string
{
$color = getNPCColor($npc);
if($color === null){
return $name;
}
return "<span style='color:{$color}'>{$name}</span>";
return "<span style='color:{$color}'>$name</span>";
}
function ConvertLog(?string $str, $type=1) : string {
-29
View File
@@ -231,36 +231,7 @@ function formatLeadershipBonus(int $value): string
return "<font color=cyan>+{$value}</font>";
}
function getNPCColor(int $npc): ?string{
if ($npc == 1) {
return 'skyblue';
}
if ($npc == 4){
return 'deepskyblue';
}
if ($npc == 5){
return 'darkcyan';
}
if ($npc == 6){
return 'mediumaquamarine';
}
if ($npc > 1) {
return 'cyan';
}
return null;
}
function formatName(string $name, int $npc): string
{
$color = getNPCColor($npc);
if($color === null){
return $name;
}
return "<span style='color:{$color}'>$name</span>";
}
function getMapTheme(): string
{
@@ -13,7 +13,7 @@ use \sammo\{
};
use function sammo\getAllNationStaticInfo;
use function \sammo\getColoredName;
use function \sammo\formatName;
use function \sammo\tryUniqueItemLottery;
use function \sammo\getInvitationList;
use function \sammo\getNationStaticInfo;
+29 -22
View File
@@ -45,6 +45,7 @@ type CityItem = {
warn성벽: boolean,
$주민: JQuery<HTMLElement>,
$인구율: JQuery<HTMLElement>,
$농업: JQuery<HTMLElement>,
$상업: JQuery<HTMLElement>,
$치안: JQuery<HTMLElement>,
@@ -294,7 +295,7 @@ $(function () {
const loadUser = function () {
$.each(cityList, function (idx, val) {
if (typeof val.users == "undefined") {
val.obj.append('<tr><td colspan="12"><table align="center" class="tb_layout cityUser bg0">' +
val.obj.append('<tr><td colspan="10"><table align="center" class="tb_layout cityUser bg0">' +
'<thead><tr>' +
'<td width="100" align="center" class="bg1">이 름</td><td width="100" align="center" class="bg1">통무지</td><td width="100" align="center" class="bg1">부 대</td><td width="60" align="center" class="bg1">자 금</td>' +
'<td width="60" align="center" class="bg1">군 량</td><td width="30" align="center" class="bg1">守</td><td width="60" align="center" class="bg1">병 종</td>' +
@@ -342,8 +343,6 @@ $(function () {
if (cityInfo.warn수비) $work.html($work.html().split('수비 강화').join('<span style="color:yellow;">수비 강화</span>'));
if (cityInfo.warn성벽) $work.html($work.html().split('성벽 보수').join('<span style="color:yellow;">성벽 보수</span>'));
const $stat = $this.children('.i_stat');
const stat = $stat.text();
@@ -414,9 +413,9 @@ $(function () {
}
const cityInfo: CityItem = {
:{},
:{},
:{},
: {},
: {},
: {},
} as CityItem;
//이름 추출
@@ -450,13 +449,13 @@ $(function () {
{
const $baseTr = $this.find('tr:eq(1)');
cityInfo.$주민 = $baseTr.find('td:eq(1)');
cityInfo.$농업 = $baseTr.find('td:eq(3)');
cityInfo.$상업 = $baseTr.find('td:eq(5)');
cityInfo.$치안 = $baseTr.find('td:eq(7)');
cityInfo.$수비 = $baseTr.find('td:eq(9)');
cityInfo.$성벽 = $baseTr.find('td:eq(11)');
cityInfo.$주민 = $this.find('.pop-value');
cityInfo.$인구율 = $this.find('.pop-prop-value');
cityInfo.$농업 = $this.find('.agri-value');
cityInfo.$상업 = $this.find('.comm-value');
cityInfo.$치안 = $this.find('.secu-value');
cityInfo.$수비 = $this.find('.def-value');
cityInfo.$성벽 = $this.find('.wall-value');
let tmpVal;
@@ -484,9 +483,18 @@ $(function () {
cityInfo. = parseInt(tmpVal[0]);
cityInfo.max성벽 = parseInt(tmpVal[1]);
if (cityInfo. > cityInfo.max주민 * 0.9) { cityInfo.$주민.css('color', 'lightgreen'); }
else if (cityInfo. > cityInfo.max주민 * 0.7) { cityInfo.$주민.css('color', 'yellow'); }
else { cityInfo.$주민.css('color', 'orangered'); }
if (cityInfo. > cityInfo.max주민 * 0.9) {
cityInfo.$주민.css('color', 'lightgreen');
cityInfo.$인구율.css('color', 'lightgreen');
}
else if (cityInfo. > cityInfo.max주민 * 0.7) {
cityInfo.$주민.css('color', 'yellow');
cityInfo.$인구율.css('color', 'yellow');
}
else {
cityInfo.$주민.css('color', 'orangered');
cityInfo.$인구율.css('color', 'orangered');
}
if (cityInfo. > cityInfo.max농업 * 0.8) { cityInfo.$농업.css('color', 'lightgreen'); }
else if (cityInfo. > cityInfo.max농업 * 0.4) { cityInfo.$농업.css('color', 'yellow'); }
@@ -541,16 +549,15 @@ $(function () {
//태수,군사,종사
{
const $baseTr = $this.find('tr:eq(2)');
cityInfo..$obj = $baseTr.find('td:eq(7)');
cityInfo..$obj = $baseTr.find('td:eq(9)');
cityInfo..$obj = $baseTr.find('td:eq(11)');
cityInfo..$obj = $this.find('.officer-4-value');
cityInfo..$obj = $this.find('.officer-3-value');
cityInfo..$obj = $this.find('.officer-2-valuet');
}
//기타
{
cityInfo.userCnt = $this.find('tr:eq(3) td:eq(1)').text().split(',').length - 1;
cityInfo.userCnt = $this.find('.city-generals').text().split(',').length - 1;
}
cityInfo.obj = $this;
@@ -572,7 +579,7 @@ $(function () {
const $sort_more = $('#sort_more');
$sort_more.html('재 정렬 순서 :');
const sortIt = function(callback: (lhs:CityItem, rhs:CityItem)=>number) {
const sortIt = function (callback: (lhs: CityItem, rhs: CityItem) => number) {
let arCity: CityItem[] = [];
$('.cityInfo').each(function () {
const $this = $(this);