명장 일람, 명예의 전당 코드 재구현. 연감 등에 이전 국가 기록 남기도록 설정

This commit is contained in:
2018-06-26 00:32:43 +09:00
parent 58cc90083b
commit 18429d52d4
14 changed files with 378 additions and 489 deletions
+135 -283
View File
@@ -14,19 +14,9 @@ $userID = Session::getUserID();
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
increaseRefresh("명장일람", 2);
increaseRefresh("명장일람", 1);
$query = "select con,turntime from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$me = MYDB_fetch_array($result);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
}
?>
<!DOCTYPE html>
<html>
@@ -36,14 +26,14 @@ if ($con >= 2) {
<title><?=UniqueConst::$serverName?>: 명장일람</title>
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('css/common.css')?>
<?=WebUtil::printCSS('css/hallOfFrame.css')?>
</head>
<body>
<table align=center width=1000 class='tb_layout bg0'>
<table align=center width=1100 class='tb_layout bg0'>
<tr><td>명 장 일 람<br><?=closeButton()?></td></tr>
</table>
<table align=center width=1000 class='tb_layout bg0'>
<table align=center width=1100 class='tb_layout bg0'>
<form name=form1 action=a_bestGeneral.php method=post>
<tr><td align=center>
<input type=submit name=btn value='유저 보기'>
@@ -51,294 +41,156 @@ if ($con >= 2) {
</td></tr>
</form>
</table>
<table align=center width=1000 class='tb_layout bg0'>
<div style="margin:auto;width=1000px;">
<?php
if (isset($btn) && $btn == "NPC 보기") {
//FIXME: query가 너무 적나라.
$sel = "npc>=2";
} else {
$sel = "npc<2";
}
$nationName = ['재야'];
$nationColor = ['#000000'];
$nationName = [0=>'재야'];
$nationColor = [0=>'#000000'];
foreach (getAllNationStaticInfo() as $nation) {
$nationName[$nation['nation']] = $nation['name'];
$nationColor[$nation['nation']] = $nation['color'];
}
$type = array(
"명 성",
"계 급",
"계 략 성 공",
"전 투 횟 수",
"승 리",
"승 률",
"사 살",
"살 상 률",
"보 병 숙 련 도",
"궁 병 숙 련 도",
"기 병 숙 련 도",
"귀 병 숙 련 도",
"차 병 숙 련 도",
"전 력 전 승 률",
"통 솔 전 승 률",
"일 기 토 승 률",
"설 전 승 률",
"베 팅 투 자 액",
"베 팅 당 첨",
"베 팅 수 익 금",
"베 팅 수 익 률"
);
$types = [
["명 성", "int", function($v){$v['value'] = $v['experience']; return $v; }],
["계 급", "int", function($v){$v['value'] = $v['dedication']; return $v; }],
["계 략 성 공", "int", function($v){
$v['value'] = $v['firenum'];
$v['nationName'] = '???';
$v['pictureFullPath'] = GetImageURL(0)."/default.jpg";
$v['name'] = '???';
$v['owner_name'] = null;
$v['bgColor'] = GameConst::$basecolor4;
$v['fgColor'] = newColor($v['bgColor']);
return $v;
}],
["전 투 횟 수", "int", function($v){$v['value'] = $v['warnum']; return $v; }],
["승 리", "int", function($v){$v['value'] = $v['killnum']; return $v; }],
["승 률", "percent", function($v){$v['value'] = $v['killnum'] / max(1, $v['warnum']); return $v; }],
["사 살", "int", function($v){$v['value'] = $v['killcrew']; return $v; }],
["살 상 률", "percent", function($v){$v['value'] = $v['killcrew'] / max(1, $v['deathcrew']); return $v; }],
["보 병 숙 련 도", "int", function($v){$v['value'] = $v['dex0']; return $v; }],
["궁 병 숙 련 도", "int", function($v){$v['value'] = $v['dex10']; return $v; }],
["기 병 숙 련 도", "int", function($v){$v['value'] = $v['dex20']; return $v; }],
["귀 병 숙 련 도", "int", function($v){$v['value'] = $v['dex30']; return $v; }],
["차 병 숙 련 도", "int", function($v){$v['value'] = $v['dex40']; return $v; }],
["전 력 전 승 률", "percent", function($v){$v['value'] = $v['ttw']/max(1, $v['ttw']+$v['ttd']+$v['ttl']); return $v; }],
["통 솔 전 승 률", "percent", function($v){$v['value'] = $v['tlw']/max(1, $v['tlw']+$v['tld']+$v['tll']); return $v; }],
["일 기 토 승 률", "percent", function($v){$v['value'] = $v['tpw']/max(1, $v['tpw']+$v['tpd']+$v['tpl']); return $v; }],
["설 전 승 률", "percent", function($v){$v['value'] = $v['ttw']/max(1, $v['tiw']+$v['tid']+$v['til']); return $v; }],
["베 팅 투 자 액", "int", function($v){$v['value'] = $v['betgold']; return $v; }],
["베 팅 당 첨", "int", function($v){$v['value'] = $v['betwin']; return $v; }],
["베 팅 수 익 금", "int", function($v){$v['value'] = $v['betwingold']; return $v; }],
["베 팅 수 익 률", "percent", function($v){$v['value'] = $v['betwingold']/max(1, $v['betgold']); return $v; }],
];
for ($i=0; $i < 21; $i++) {
$name = [];
$data = [];
$color = [];
$pic = [];
//FIXME: 쿼리에 index를 사용할 수 없는 녀석들이 있다. 그냥 모두 받아서 일괄 처리하는게 더 나을 수도 있음.
switch ($i) {
case 0: $query = "select nation,no,name,picture,imgsvr,experience as data from general where $sel order by data desc limit 0,10"; break;
case 1: $query = "select nation,no,name,picture,imgsvr,dedication as data from general where $sel order by data desc limit 0,10"; break;
case 2: $query = "select nation,no,name,picture,imgsvr,firenum as data from general where $sel order by data desc limit 0,10"; break;
case 3: $query = "select nation,no,name,picture,imgsvr,warnum as data from general where $sel order by data desc limit 0,10"; break;
case 4: $query = "select nation,no,name,picture,imgsvr,killnum as data from general where $sel order by data desc limit 0,10"; break;
case 5: $query = "select nation,no,name,picture,imgsvr,killnum/warnum*10000 as data from general where warnum>=10 and $sel order by data desc limit 0,10"; break;
case 6: $query = "select nation,no,name,picture,imgsvr,killcrew as data from general where $sel order by data desc limit 0,10"; break;
case 7: $query = "select nation,no,name,picture,imgsvr,killcrew/deathcrew*10000 as data from general where warnum>=10 and $sel order by data desc limit 0,10"; break;
case 8: $query = "select nation,no,name,picture,imgsvr,dex0 as data from general where $sel order by data desc limit 0,10"; break;
case 9: $query = "select nation,no,name,picture,imgsvr,dex10 as data from general where $sel order by data desc limit 0,10"; break;
case 10: $query = "select nation,no,name,picture,imgsvr,dex20 as data from general where $sel order by data desc limit 0,10"; break;
case 11: $query = "select nation,no,name,picture,imgsvr,dex30 as data from general where $sel order by data desc limit 0,10"; break;
case 12: $query = "select nation,no,name,picture,imgsvr,dex40 as data from general where $sel order by data desc limit 0,10"; break;
case 13: $query = "select nation,no,name,picture,imgsvr,ttw/(ttw+ttd+ttl)*10000 as data from general where $sel and (ttw+ttd+ttl)>=50 order by data desc limit 0,10"; break;
case 14: $query = "select nation,no,name,picture,imgsvr,tlw/(tlw+tld+tll)*10000 as data from general where $sel and (tlw+tld+tll)>=50 order by data desc limit 0,10"; break;
case 15: $query = "select nation,no,name,picture,imgsvr,tpw/(tpw+tpd+tpl)*10000 as data from general where $sel and (tpw+tpd+tpl)>=50 order by data desc limit 0,10"; break;
case 16: $query = "select nation,no,name,picture,imgsvr,tiw/(tiw+tid+til)*10000 as data from general where $sel and (tiw+tid+til)>=50 order by data desc limit 0,10"; break;
case 17: $query = "select nation,no,name,picture,imgsvr,betgold as data from general where $sel order by data desc limit 0,10"; break;
case 18: $query = "select nation,no,name,picture,imgsvr,betwin as data from general where $sel order by data desc limit 0,10"; break;
case 19: $query = "select nation,no,name,picture,imgsvr,betwingold as data from general where $sel order by data desc limit 0,10"; break;
case 20: $query = "select nation,no,name,picture,imgsvr,betwingold/betgold*10000 as data from general where $sel and betgold >= 1000 order by data desc limit 0,10"; break;
$generals = array_map(function($general) use($nationColor, $nationName) {
$general['bgColor'] = $nationColor[$general['nation']]??GameConst::$basecolor4;
$general['fgColor'] = newColor($general['bgColor']);
$general['nationName'] = $nationName[$general['nation']];
if(key_exists('picture', $general)){
$imageTemp = GetImageURL($general['imgsvr']);
$general['pictureFullPath'] = "$imageTemp/{$general['picture']}";
}
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
echo "
<tr><td align=center colspan=10 id=bg1><font size=4>$type[$i]</font></td></tr>
<tr align=center id=bg2><td>1위</td><td>2위</td><td>3위</td><td>4위</td><td>5위</td><td>6위</td><td>7위</td><td>8위</td><td>9위</td><td>10위</td></tr>
<tr>";
for ($k=0; $k < 10; $k++) {
$gen = MYDB_fetch_array($result);
if ($i != 2) {
if (isset($gen)) {
$name[$k] = $gen['name'];
$nation[$k] = $nationName[$gen['nation']];
$data[$k] = $gen['data'];
$color[$k] = $nationColor[$gen['nation']];
$pic[$k] = $gen['picture'];
} else {
$name[$k] = "-";
$nation[$k] = "-";
$data[$k] = "-";
$color[$k] = GameConst::$basecolor4;
$pic[$k] = "";
}
} else {
$name[$k] = "???";
$nation[$k] = "???";
$data[$k] = $gen['data'];
$color[$k] = GameConst::$basecolor4;
$gen['imgsvr'] = 0;
$pic[$k] = "9999.jpg";
}
if ($color[$k] == "") {
$color[$k] = GameConst::$basecolor4;
}
if ($nation[$k] == "") {
$nation[$k] = "&nbsp;";
}
if ($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']);
echo "<td align=center><img width='64' height='64' src={$imageTemp}/{$pic[$k]}></td>";
}
else{
$general['pictureFullPath'] = GetImageURL(0)."/default.jpg";
}
echo "</tr><tr>";
return $general;
}, $db->query(
"SELECT nation,no,name,name2 as owner_name, picture, imgsvr,
experience, dedication, firenum, warnum, killnum, killcrew, deathcrew,
dex0, dex10, dex20, dex30, dex40,
ttw, ttd, ttl, tlw, tld, tll, tpw, tpd, tpl, tiw, tid, til,
betgold, betwin, betwingold,
horse, weap, book, item
FROM general WHERE %l", $btn == "NPC 보기"?"npc>=2":"npc<2"));
for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$nation[$k]}</td>";
}
echo "</tr><tr>";
$templates = new \League\Plates\Engine('templates');
for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$name[$k]}</td>";
}
foreach($types as $idx=>[$typeName, $typeValue, $typeFunc]){
$typeGenerals = array_map(function($general) use($typeValue, $typeFunc){
$general = ($typeFunc)($general);
$value = $general['value'];
echo "</tr><tr>";
for ($k=0; $k < 10; $k++) {
if($data[$k] === '-'){
//do Nothing
if($typeValue == 'percent'){
$general['printValue'] = number_format($value*100, 2).'%';
}
else if ($i == 5 || $i == 7 || $i == 20) {
$data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
else {
$general['printValue'] = number_format($value);
}
else if ($i >= 13 && $i <= 16) {
$data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
}
echo "<td align=center>{$data[$k]}</td>";
}
echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>";
return $general;
}, $generals);
usort($typeGenerals, function($lhs, $rhs){
//내림차순
return -($lhs['value'] - $rhs['value']);
});
echo $templates->render('hallOfFrame', [
'typeName'=>$typeName,
'generals'=>array_slice($typeGenerals, 0, 10, true)
]);
}
echo "
</table>
<br>
<table align=center width=1000 class='tb_layout bg0'>
";
$type = array(
"명 마",
"명 검",
"명 서",
"도 구"
);
$call = array(
"horse",
"weap",
"book",
"item"
);
$func = array(
"\\sammo\\getHorseName",
"\\sammo\\getWeapName",
"\\sammo\\getBookName",
"\\sammo\\getItemName"
);
for ($i=0; $i < 4; $i++) {
$name = [];
$data = [];
$color = [];
$pic = [];
echo "
<tr><td align=center colspan=10 id=bg1><font size=4>$type[$i]</font></td></tr>
<tr align=center id=bg2>";
for ($k=26; $k > 16; $k--) {
$str = $func[$i]($k);
echo "<td>".$str."</td>";
}
echo "</tr><tr>";
for ($k=26; $k > 16; $k--) {
$query = "select nation,no,name,picture,imgsvr from general where {$call[$i]}={$k}";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gen = MYDB_fetch_array($result);
if (isset($gen)) {
$name[$k] = $gen['name'];
$nation[$k] = $nationName[$gen['nation']];
$color[$k] = $nationColor[$gen['nation']];
$pic[$k] = $gen['picture'];
} else {
$name[$k] = "미발견";
$nation[$k] = "-";
$color[$k] = "";
$pic[$k] = "";
}
if ($color[$k] == "") {
$color[$k] = GameConst::$basecolor4;
}
if ($nation[$k] == "") {
$nation[$k] = "&nbsp;";
}
if ($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']??0);
echo "<td align=center><img width='64' height='64' src={$imageTemp}/{$pic[$k]}></img></td>";
}
}
echo "</tr><tr>";
for ($k=26; $k > 16; $k--) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$nation[$k]}</td>";
}
echo "</tr><tr>";
for ($k=26; $k > 16; $k--) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$name[$k]}</td>";
}
echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>";
echo "
<tr align=center id=bg2>";
for ($k=16; $k > 6; $k--) {
$str = $func[$i]($k);
echo "<td>".$str."</td>";
}
echo "</tr><tr>";
for ($k=16; $k > 6; $k--) {
$query = "select nation,no,name,picture,imgsvr from general where {$call[$i]}={$k}";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gen = MYDB_fetch_array($result);
if (isset($gen)) {
$name[$k] = $gen['name'];
$nation[$k] = $nationName[$gen['nation']];
$color[$k] = $nationColor[$gen['nation']];
$pic[$k] = $gen['picture'];
} else {
$name[$k] = "미발견";
$nation[$k] = "-";
$color[$k] = "";
$pic[$k] = "";
}
if ($color[$k] == "") {
$color[$k] = GameConst::$basecolor4;
}
if ($nation[$k] == "") {
$nation[$k] = "&nbsp;";
}
if ($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']??0);
echo "<td align=center><img width='64' height='64' src={$imageTemp}/{$pic[$k]}></img></td>";
}
}
echo "</tr><tr>";
for ($k=16; $k > 6; $k--) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$nation[$k]}</td>";
}
echo "</tr><tr>";
for ($k=16; $k > 6; $k--) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$name[$k]}</td>";
}
echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>";
}
?>
</table>
<table align=center width=1000 class='tb_layout bg0'>
</div>
<div style="margin:auto;width=1000px;margin-top:5px;">
<?php
//유니크 아이템 소유자
$itemTypes = [
["명 마", 'horse', function($v){return getHorseName($v);}, 7, 26, []],
["명 검", 'weap', function($v){return getWeapName($v);}, 7, 26, []],
["명 서", 'book', function($v){return getBookName($v);}, 7, 26, []],
["도 구", 'item', function($v){return getItemName($v);}, 7, 26, []],
];
$simpleItemTypes = array_map(function($itemType){return $itemType[1];}, $itemTypes);
foreach($generals as $general){
foreach($itemTypes as $itemIdx=>[,$itemType, $itemFunc,,,]){
$itemCode = $general[$itemType];
if($itemCode <= 6){
continue;
}
$itemName = ($itemFunc)($itemCode);
$general['rankName'] = $itemName;
$general['value'] = $itemCode;
$itemTypes[$itemIdx][5][$itemCode] = $general;
}
}
foreach($itemTypes as [$itemNameType, $itemType, $itemFunc, $itemMinCode, $itemMaxCode, $itemOwners]){
$itemRanker = [];
for($itemCode = $itemMaxCode; $itemCode >= $itemMinCode; $itemCode--){
if(!key_exists($itemCode, $itemOwners)){
$emptyCard = [
'rankName' => ($itemFunc)($itemCode),
'pictureFullPath' => GetImageURL(0)."/default.jpg",
'value'=>$itemCode,
'name'=>'미발견',
'bgColor'=>GameConst::$basecolor4,
'fgColor'=>newColor(GameConst::$basecolor4),
];
$itemRanker[$itemCode] = $emptyCard;
continue;
}
$general = $itemOwners[$itemCode];
$itemRanker[$itemCode] = $general;
}
echo $templates->render('hallOfFrame', [
'typeName'=>$itemNameType,
'generals'=>$itemRanker
]);
}
?>
</div>
<table align=center width=1100 class='tb_layout bg0'>
<tr><td><?=closeButton()?></td></tr>
<tr><td><?=banner()?> </td></tr>
</table>
+31 -64
View File
@@ -4,10 +4,12 @@ namespace sammo;
include "lib.php";
include "func.php";
$session = Session::getInstance()->setReadOnly();
$db = DB::db();
$connect=$db->get();
increaseRefresh("명예의전당", 2);
increaseRefresh("명예의전당", 1);
?>
<!DOCTYPE html>
<html>
@@ -17,16 +19,16 @@ increaseRefresh("명예의전당", 2);
<title><?=UniqueConst::$serverName?>: 명예의 전당</title>
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('css/common.css')?>
<?=WebUtil::printCSS('css/hallOfFrame.css')?>
</head>
<body>
<table align=center width=1000 class='tb_layout bg0'>
<table align=center width=1100 class='tb_layout bg0'>
<tr><td>명 예 의 전 당<br><?=closeButton()?></td></tr>
</table>
<table align=center width=1000 class='tb_layout bg0'>
<div style="margin:auto;width=1100px;">
<?php
$type = array(
$types = array(
"명 성",
"계 급",
"계 략 성 공",
@@ -49,72 +51,37 @@ $type = array(
"베 팅 수 익 금",
"베 팅 수 익 률"
);
for ($i=0; $i < 21; $i++) {
$name = [];
$nation = [];
$data = [];
$color = [];
$pic = [];
$query = "select * from hall where type={$i} order by rank";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
echo "
<tr><td align=center colspan=10 id=bg1><font size=4>$type[$i]</font></td></tr>
<tr align=center id=bg2><td>1위</td><td>2위</td><td>3위</td><td>4위</td><td>5위</td><td>6위</td><td>7위</td><td>8위</td><td>9위</td><td>10위</td></tr>
<tr>";
$templates = new \League\Plates\Engine('templates');
for ($k=0; $k < 10; $k++) {
$gen = MYDB_fetch_array($result);
$name[$k] = $gen['name'];
$nation[$k] = $gen['nation'];
$data[$k] = $gen['data'];
$color[$k] = $gen['color'];
$pic[$k] = $gen['picture'];
if ($color[$k] == "") {
$color[$k] = GameConst::$basecolor4;
foreach($types as $idx=>$typeName) {
$hallResult = $db->query('SELECT * FROM ng_hall WHERE server_id = %s AND `type`=%i ORDER BY `value` DESC LIMIT 10', UniqueConst::$serverID, $idx);
$hallResult = array_map(function($general){
$aux = Json::decode($general['aux']);
$general += $aux;
if(!key_exists('color', $general)){
$general['color'] = GameConst::$basecolor4;
$general['fgColor'] = newColor($general['color']);
}
if ($nation[$k] == "") {
$nation[$k] = "&nbsp;";
if(key_exists('picture', $general)){
$imageTemp = GetImageURL($general['imgsvr']);
$general['pictureFullPath'] = "$imageTemp/{$general['picture']}";
}
/*
if($pic[$k] == "") {
echo "<td align=center>&nbsp;</td>";
} else {
$imageTemp = GetImageURL($gen['imgsvr']);
echo "<td align=center><img width='64' height='64' src={$imageTemp}/{$pic[$k]}></img></td>";
}
*/
}
// echo "</tr><tr>";
for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$nation[$k]}</td>";
}
echo "</tr><tr>";
for ($k=0; $k < 10; $k++) {
echo "<td align=center style=background-color:{$color[$k]};font-size:80%;color:".newColor($color[$k]).">{$name[$k]}</td>";
}
echo "</tr><tr>";
for ($k=0; $k < 10; $k++) {
if ($i == 5 || $i == 7 || $i == 20) {
$data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
else{
$general['pictureFullPath'] = GetImageURL(0)."/default.jpg";
}
if ($i >= 13 && $i <= 16) {
$data[$k] = intdiv($data[$k], 100).".".($data[$k]%100)." %";
}
echo "<td align=center>{$data[$k]}</td>";
}
echo "</tr><tr><td colspan=10 height=5 id=bg1></td></tr>";
return $general;
}, $hallResult);
echo $templates->render('hallOfFrame', [
'typeName'=>$typeName,
'generals'=>$hallResult
]);
}
?>
</table>
<table align=center width=1000 class='tb_layout bg0'>
</div>
<table align=center width=1100 class='tb_layout bg0'>
<tr><td><?=closeButton()?></td></tr>
<tr><td><?=banner()?> </td></tr>
</table>
+11 -20
View File
@@ -30,15 +30,11 @@ if ($con >= 2) {
exit();
}
$query = "select year,month from history order by no limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result);
$s = ($history['year']*12) + $history['month'];
[$s_year, $s_month] = $db->queryFirstList('SELECT year, month FROM history WHERE server_id = %s ORDER BY year ASC, month ASC LIMIT 1', UniqueConst::$serverID);
$s = $s_year * 12 + $s_month;
$query = "select year,month from history order by no desc limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result);
$e = ($history['year']*12) + $history['month'];
[$e_year, $e_month] = $db->queryFirstList('SELECT year, month FROM history WHERE server_id = %s ORDER BY year DESC, month DESC LIMIT 1', UniqueConst::$serverID);
$e = $e_year * 12 + $e_month;
//FIXME: $yearmonth가 올바르지 않을 경우에 처리가 필요.
if (!$yearmonth) {
@@ -98,24 +94,19 @@ if ($month <= 0) {
<input type=submit name=btn value="◀◀ 이전달">
<select name=yearmonth size=1>
<?php
$query = "select year,month from history";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$histCount = MYDB_num_rows($result);
for ($i=0; $i < $histCount; $i++) {
$history = MYDB_fetch_array($result);
$value = "".$history['year'].StringUtil::padStringAlignRight($history['month'], 2, "0");
if ($history['year'] == $year && $history['month'] == $month) {
$dates = $db->queryAllLists('SELECT year, month FROM history WHERE server_id = %s ORDER BY year ASC, month DESC', UniqueConst::$serverID);
foreach($dates as [$hYear, $hMonth]){
$value = "".$hYear.StringUtil::padStringAlignRight($hMonth, 2, "0");
if ($hYear == $year && $hMonth == $month) {
echo "
<option selected value={$value}>{$history['year']}년 {$history['month']}월</option>";
<option selected value={$value}>{$hYear}년 {$hMonth}월</option>";
} else {
echo "
<option value={$value}>{$history['year']}년 {$history['month']}월</option>";
<option value={$value}>{$hYear}년 {$hMonth}월</option>";
}
}
$query = "select log,genlog,nation,power,gen,city from history where year='$year' and month='$month'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$history = MYDB_fetch_array($result);
$history = $db->queryFirstRow('SELECT log,genlog,nation,power,gen,city FROM history WHERE server_id = %s AND year = %i AND month = %i', UniqueConst::$serverID, $year, $month);
?>
</select>
<input type=submit name=btn value='조회하기'>
+76
View File
@@ -0,0 +1,76 @@
.rankView {
width:1100px;
margin:auto;
position:relative;
font-size:13px;
}
.rankView h3{
text-align:center;
margin:0;
padding:2px;
border-bottom:1px solid gray;
}
.rankView ul{
list-style:none;
margin:0;
padding:0;
overflow:hidden;
box-sizing: border-box;
margin-top:-1px;
margin-bottom:-1px;
}
.rankView li{
display:inline-block;
vertical-align: top;
width:110px;
height:149px;
text-align:center;
border-right:1px solid gray;
border-top:1px solid gray;
margin:0;
box-sizing: border-box;
}
.rankView li.no_value{
height:128px;
}
.rankView .no_value .hall_value{
display:none;
}
.rankView .hall_nation{
font-size:11px;
border-top:1px solid gray;
border-bottom:1px solid gray;
}
.rankView .hall_name{
display: flex;
justify-content: center;
flex-direction: column;
resize: vertical;
font-size:11px;
height:28px;
}
.rankView .hall_name p{
padding:0;
margin:0;
}
.rankView .hall_owner{
font-size:95%;
}
.rankView .hall_value{
line-height:13px;
box-sizing: border-box;
border-top:1px solid gray;
padding-top:3px;
padding-bottom:3px;
}
+46 -41
View File
@@ -1916,10 +1916,6 @@ function updateTurntime($no) {
$josaYi = JosaUtil::pick($general['name2'], '이');
$alllog[0] = "<C>●</>{$admin['month']}월:<Y>{$general['name2']}</>{$josaYi} <Y>{$general['name']}</>의 육체에서 <S>유체이탈</>합니다!";
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
if($admin['isunited'] == 0) {
CheckHall($no);
}
} else {
// 군주였으면 유지 이음
if($general['level'] == 12) {
@@ -2060,9 +2056,10 @@ function updateTurntime($no) {
function CheckHall($no) {
$db = DB::db();
$connect=$db->get();
$type = array(
$types = array(
"experience",
"dedication",
"firenum",
@@ -2086,25 +2083,27 @@ function CheckHall($no) {
"betrate"
);
$query = "select name,nation,picture,
experience,dedication,warnum,firenum,killnum,
killnum/warnum*10000 as winrate,killcrew,killcrew/deathcrew*10000 as killrate,
dex0,dex10,dex20,dex30,dex40,
ttw/(ttw+ttd+ttl)*10000 as ttrate, ttw+ttd+ttl as tt,
tlw/(tlw+tld+tll)*10000 as tlrate, tlw+tld+tll as tl,
tpw/(tpw+tpd+tpl)*10000 as tprate, tpw+tpd+tpl as tp,
tiw/(tiw+tid+til)*10000 as tirate, tiw+tid+til as ti,
betgold, betwin, betwingold, betwingold/betgold*10000 as betrate
from general where no='$no'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general = MYDB_fetch_array($result);
$general = $db->queryFirstRow('SELECT name,name2,owner,nation,picture,imgsvr,
experience,dedication,warnum,firenum,killnum,
killnum/warnum*10000 as winrate,killcrew,killcrew/deathcrew*10000 as killrate,
dex0,dex10,dex20,dex30,dex40,
ttw/(ttw+ttd+ttl)*10000 as ttrate, ttw+ttd+ttl as tt,
tlw/(tlw+tld+tll)*10000 as tlrate, tlw+tld+tll as tl,
tpw/(tpw+tpd+tpl)*10000 as tprate, tpw+tpd+tpl as tp,
tiw/(tiw+tid+til)*10000 as tirate, tiw+tid+til as ti,
betgold, betwin, betwingold, betwingold/betgold*10000 as betrate
from general where no=%i', $no);
if(!$general){
return;
}
$nation = getNationStaticInfo($general['nation']);
for($k=0; $k < 21; $k++) {
$query = "select * from hall where type='$k' order by data desc";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$count = MYDB_num_rows($result);
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games');
foreach($types as $idx=>$typeName) {
//승률,살상률인데 10회 미만 전투시 스킵
if(($k == 5 || $k == 7) && $general['warnum']<10) { continue; }
@@ -2119,26 +2118,32 @@ function CheckHall($no) {
//수익률인데 1000미만시 스킵
if($k == 20 && $general['betgold'] < 1000) { continue; }
$rank = 10;
for($i=0; $i < $count; $i++) {
$ranker = MYDB_fetch_array($result);
$aux = [
'nationName'=>$nation['name'],
'bgColor'=>$nation['color'],
'fgColor'=>newColor($nation['color']),
'picture'=>$general['picture'],
'imgsvr'=>$general['imgsvr'],
'date'=>date('Y-m-d H:i:s'),
'owner_name'=>$general['name2'],
'server_id'=>UniqueConst::$serverID,
'printValue'=>$general['value']
];
$jsonAux = Json::encode($aux);
if($general[$type[$k]] >= $ranker['data']) {
$rank = $i;
break;
}
}
for($i=8; $i >= $rank; $i--) {
$j = $i + 1;
$query = "select * from hall where type='$k' and rank='$i'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$ranker = MYDB_fetch_array($result);
$query = "update hall set name='{$ranker['name']}', nation='{$ranker['nation']}', data='{$ranker['data']}', color='{$ranker['color']}', picture='{$ranker['picture']}' where type='$k' and rank='$j'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
$query = "update hall set name='{$general['name']}', nation='{$nation['name']}', data='{$general[$type[$k]]}', color='{$nation['color']}', picture='{$general['picture']}' where type='$k' and rank='$rank'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$db->insertUpdate('ng_hall', [
'server_id'=>UniqueConst::$serverID,
'type'=>$idx,
'general_no'=>$no,
'value'=>$general[$typeName],
'owner'=>$general['owner']??null,
'serverIdx'=>$serverCnt,
'serverName'=>UniqueConst::$serverName,
'aux'=>$jsonAux
],[
'value'=>$general[$typeName],
'aux'=>$jsonAux
]);
}
}
+1
View File
@@ -298,6 +298,7 @@ function LogHistory($isFirst=0) {
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', contents collected');
$db->insert('history', [
'server_id' => UniqueConst::$serverID,
'year' => $year,
'month' => $month,
'map' => $map_json,
+11 -3
View File
@@ -1,12 +1,14 @@
<?php
namespace sammo;
class MapRequest{
public $serverID;
public $year;
public $month;
public $aux;
public $neutralView;
public $showMe;
function __construct($obj){
$this->serverID = Util::array_get($obj['serverID'], null);
$this->year = Util::array_get($obj['year']);
$this->month = Util::array_get($obj['month']);
$this->aux = Util::array_get($obj['aux'],[]);
@@ -19,14 +21,20 @@ class MapRequest{
/**
* @param int $year
* @param int $month
* @param string|null $serverID
* @return mixed
*/
function getHistoryMap($year, $month){
function getHistoryMap($year, $month, ?string $serverID=null){
if(!$year || !$month){
return ['result'=>false, 'reason'=>'연 월이 지정되지 않음'];
}
$map = DB::db()->queryFirstField('select map from history where year=%i and month=%i',
if($serverID === null){
$serverID = UniqueConst::$serverID;
}
$map = DB::db()->queryFirstField('SELECT map FROM history WHERE server_id = %s AND year=%i and month=%i',
$serverID,
$year,
$month);
@@ -47,7 +55,7 @@ function getWorldMap($req){
}
if($req->year && $req->month){
return getHistoryMap($req->year, $req->month);
return getHistoryMap($req->year, $req->month, $req->serverID??null);
}
$session = Session::getInstance();
-12
View File
@@ -44,15 +44,3 @@ function getMailboxList(){
return $result;
}
//Legacy
function moveMsg($table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $value) {
$db = DB::db();
$connect=$db->get();
//TODO: moveMsg 쓰는 곳 모두 고쳐!!!
$query = "update {$table} set {$msgtype}{$msgnum}='$msg',{$msgtype}{$msgnum}_type='$type',{$msgtype}{$msgnum}_who='$who',{$msgtype}{$msgnum}_when='$when' where {$column}='$value'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
+6 -1
View File
@@ -6,6 +6,7 @@ include "func.php";
$year = Util::getReq('year', 'int');
$month = Util::getReq('month', 'int');
$serverID = Util::getReq('server_id', 'string', null);
extractMissingPostToGlobals();
@@ -26,13 +27,17 @@ if(!$year || !$month) {
}
if(!$serverID){
$serverID = UniqueConst::$serverID;
}
//로그인 검사
$session = Session::requireGameLogin([])->setReadOnly();
$db = DB::db();
$connect=$db->get();
$map = $db->queryFirstField('SELECT map FROM history WHERE year=%i AND month=%i', $year, $month);
$map = $db->queryFirstField('SELECT map FROM history WHERE server_id=%s AND year=%i AND month=%i', $serverID, $year, $month);
if(!$map){
Json::die([
+12 -1
View File
@@ -94,7 +94,8 @@ class ResetHelper{
(KVStorage::getStorage($db, 'game_env'))->resetValues();
return [
'result'=>true
'result'=>true,
'serverID'=>$serverID
];
}
@@ -128,6 +129,8 @@ class ResetHelper{
return $clearResult;
}
$serverID = $clearResult['serverID'];
$scenarioObj = new Scenario($scenario, false);
$scenarioObj->buildConf();
@@ -205,6 +208,14 @@ class ResetHelper{
$gameStor->$key = $value;
}
$db->insert('ng_games', [
'server_id'=>$serverID,
'date'=>$turntime,
'winner_nation'=>null,
'scenario'=>$scenario,
'env'=>Json::encode($env)
]);
$scenarioObj->build($env);
$db->update('plock', [
-3
View File
@@ -31,9 +31,6 @@ DROP TABLE IF EXISTS auction;
#
DROP TABLE IF EXISTS statistic;
#
DROP TABLE IF EXISTS history;
#
DROP TABLE IF EXISTS event;
+22 -55
View File
@@ -362,19 +362,6 @@ ENGINE=InnoDB;
###########################################################################
##
###########################################################################
create table if not exists hall (
no int(6) not null auto_increment,
type int(2) default 0,
rank int(2) default 0,
name char(64) default '',
nation char(12) default '',
data int(5) default 0,
color char(12) default '',
picture varchar(40) default '',
PRIMARY KEY (no),
UNIQUE INDEX `type` (`type`, `rank`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
CREATE TABLE if not exists `ng_hall` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
@@ -382,12 +369,12 @@ CREATE TABLE if not exists `ng_hall` (
`scenario` INT(11) NOT NULL,
`general_no` INT(11) NOT NULL,
`type` INT(11) NOT NULL,
`value` INT(11) NOT NULL,
`value` DOUBLE NOT NULL,
`owner` INT(11) NULL DEFAULT NULL,
`aux` TEXT NOT NULL DEFAULT '{}',
PRIMARY KEY (`id`),
UNIQUE INDEX `server_general` (`server_id`, `type`, `general_no`),
UNIQUE INDEX `owner` (`owner`, `server_id`),
UNIQUE INDEX `owner` (`owner`, `server_id`, `type`),
INDEX `server_show` (`server_id`, `type`, `value`),
INDEX `scenario` (`scenario`, `type`, `value`)
)
@@ -398,19 +385,20 @@ ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
##
###########################################################################
CREATE TABLE `ng_games` (
CREATE TABLE if not exists `ng_games` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`server_id` CHAR(20) NOT NULL,
`date` DATETIME NOT NULL,
`winner_nation` INT(11) NULL DEFAULT NULL,
`aux` TEXT NOT NULL COMMENT 'json',
`scenario` INT(11) NOT NULL,
`env` TEXT NOT NULL COMMENT 'json',
PRIMARY KEY (`id`),
UNIQUE INDEX `server_id` (`server_id`),
INDEX `date` (`date`)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
CREATE TABLE `ng_old_nations` (
CREATE TABLE if not exists `ng_old_nations` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`server_id` CHAR(20) NOT NULL DEFAULT '0',
`nation` INT(11) NOT NULL DEFAULT '0',
@@ -457,29 +445,6 @@ create table if not exists emperior (
PRIMARY KEY (no)
) ENGINE=INNODB ROW_FORMAT=COMPRESSED DEFAULT CHARSET=utf8mb4;
INSERT IGNORE INTO `hall` (`type`, `rank`) VALUES
( 0, 0), ( 0, 1), ( 0, 2), ( 0, 3), ( 0, 4), ( 0, 5), ( 0, 6), ( 0, 7), ( 0, 8), ( 0, 9),
( 1, 0), ( 1, 1), ( 1, 2), ( 1, 3), ( 1, 4), ( 1, 5), ( 1, 6), ( 1, 7), ( 1, 8), ( 1, 9),
( 2, 0), ( 2, 1), ( 2, 2), ( 2, 3), ( 2, 4), ( 2, 5), ( 2, 6), ( 2, 7), ( 2, 8), ( 2, 9),
( 3, 0), ( 3, 1), ( 3, 2), ( 3, 3), ( 3, 4), ( 3, 5), ( 3, 6), ( 3, 7), ( 3, 8), ( 3, 9),
( 4, 0), ( 4, 1), ( 4, 2), ( 4, 3), ( 4, 4), ( 4, 5), ( 4, 6), ( 4, 7), ( 4, 8), ( 4, 9),
( 5, 0), ( 5, 1), ( 5, 2), ( 5, 3), ( 5, 4), ( 5, 5), ( 5, 6), ( 5, 7), ( 5, 8), ( 5, 9),
( 6, 0), ( 6, 1), ( 6, 2), ( 6, 3), ( 6, 4), ( 6, 5), ( 6, 6), ( 6, 7), ( 6, 8), ( 6, 9),
( 7, 0), ( 7, 1), ( 7, 2), ( 7, 3), ( 7, 4), ( 7, 5), ( 7, 6), ( 7, 7), ( 7, 8), ( 7, 9),
( 8, 0), ( 8, 1), ( 8, 2), ( 8, 3), ( 8, 4), ( 8, 5), ( 8, 6), ( 8, 7), ( 8, 8), ( 8, 9),
( 9, 0), ( 9, 1), ( 9, 2), ( 9, 3), ( 9, 4), ( 9, 5), ( 9, 6), ( 9, 7), ( 9, 8), ( 9, 9),
(10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9),
(11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (11, 8), (11, 9),
(12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7), (12, 8), (12, 9),
(13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (13, 5), (13, 6), (13, 7), (13, 8), (13, 9),
(14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (14, 5), (14, 6), (14, 7), (14, 8), (14, 9),
(15, 0), (15, 1), (15, 2), (15, 3), (15, 4), (15, 5), (15, 6), (15, 7), (15, 8), (15, 9),
(16, 0), (16, 1), (16, 2), (16, 3), (16, 4), (16, 5), (16, 6), (16, 7), (16, 8), (16, 9),
(17, 0), (17, 1), (17, 2), (17, 3), (17, 4), (17, 5), (17, 6), (17, 7), (17, 8), (17, 9),
(18, 0), (18, 1), (18, 2), (18, 3), (18, 4), (18, 5), (18, 6), (18, 7), (18, 8), (18, 9),
(19, 0), (19, 1), (19, 2), (19, 3), (19, 4), (19, 5), (19, 6), (19, 7), (19, 8), (19, 9),
(20, 0), (20, 1), (20, 2), (20, 3), (20, 4), (20, 5), (20, 6), (20, 7), (20, 8), (20, 9);
###########################################################################
##
###########################################################################
@@ -566,20 +531,22 @@ create table statistic (
###########################################################################
##
###########################################################################
create table history (
no int(6) not null auto_increment,
year int(4) default 0,
month int(2) default 0,
map mediumtext default '',
log text default '',
genlog mediumtext default '',
nation text default '',
power text default '',
gen text default '',
city text default '',
PRIMARY KEY (no)
) ENGINE=INNODB ROW_FORMAT=COMPRESSED DEFAULT CHARSET=utf8mb4;
CREATE TABLE if not exists `history` (
`no` INT(6) NOT NULL AUTO_INCREMENT,
`server_id` CHAR(20) NOT NULL DEFAULT '',
`year` INT(4) NULL DEFAULT '0',
`month` INT(2) NULL DEFAULT '0',
`map` MEDIUMTEXT NULL DEFAULT '',
`log` TEXT NULL DEFAULT '',
`genlog` MEDIUMTEXT NULL DEFAULT '',
`nation` TEXT NULL DEFAULT '',
`power` TEXT NULL DEFAULT '',
`gen` TEXT NULL DEFAULT '',
`city` TEXT NULL DEFAULT '',
PRIMARY KEY (`no`),
INDEX `server_id` (`server_id`, `year`, `month`)
)
ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
###########################################################################
##
+21
View File
@@ -0,0 +1,21 @@
<div class="rankView bg0" style="border:1px solid gray;">
<h3 class="rankType bg1"><?=$typeName?></h3>
<ul>
<?php foreach($generals as $rank=>$general): ?><li <?=(key_exists("rankName", $general))?"class='no_value'":''?>>
<div class="hall_rank bg2 with_border">
<?=$general['rankName']??(($rank+1).'위')?>
</div>
<div class="hall_img"><img width="64" height="64" src="<?=$general['pictureFullPath']?>"></div>
<?php if(key_exists("serverName")): ?>
<div class="hall_server"><?=$general['serverName']?><?=$general['serverIdx']?>기</div>
<?php endif;?>
<div class="hall_nation" style="background-color:<?=$general['bgColor']?>;color:<?=$general['fgColor']?>;"><?=$general['nationName']??'-'?></div>
<div class="hall_name" style="background-color:<?=$general['bgColor']?>;color:<?=$general['fgColor']?>;"><p><?=$general['name']??'-'?>
<?php if($general["owner_name"]??null): ?>
<div class="hall_owner">(<?=$general['owner_name']?>)</div>
<?php endif;?>
</p></div>
<div class="hall_value"><?=$general['printValue']??$general['value']?></div>
</li><?php endforeach; ?>
</ul>
</div>
+6 -6
View File
@@ -92,12 +92,12 @@ if ($userGrade >= 5) {
계정은 한번 등록으로 계속 사용합니다. 각 서버 리셋시 캐릭터만 새로 생성하면 됩니다.<br>
<br>
<span class="Entrance_Che">체섭</span> : 메인서버입니다. 천하통일에 도전하여 왕조일람과 명예의전당에 올라봅시다! (주로 1턴=60분)<br>
<span class="Entrance_Kwe">퀘섭</span> : 실제 장수가 되어 가상의 역사를 만들어 봅시다!<br>
<span class="Entrance_Pwe">풰섭</span> : 실제 장수들과 어울려 사실적 역사를 체험해 봅시다!<br>
<span class="Entrance_Twe">퉤섭</span> : 주로 패치사항 미리보기 테스트 서버입니다.<br>
<span class="Entrance_Nya">냐섭</span> : 신 서버.<br>
<span class="Entrance_Pya">퍄섭</span> : 신 서버2.<br>
<span class="Entrance_Hwe">훼섭</span> : 1일천하 서버. 또는 운영자 테스트 서버입니다.<br>
<span class="Entrance_Kwe">퀘섭</span> : 마이너 서버 그룹1. 비교적 느린 시간으로 운영됩니다.<br>
<span class="Entrance_Pwe">풰섭</span> : 마이너 서버 그룹1. 비교적 느린 시간으로 운영됩니다.<br>
<span class="Entrance_Twe">퉤섭</span> : 마이너 서버 그룹2. 비교적 빠른 시간으로 운영됩니다.<br>
<span class="Entrance_Nya">냐섭</span> : 마이너 서버 그룹3. 독특한 컨셉 위주로 운영됩니다.<br>
<span class="Entrance_Pya">퍄섭</span> : 마이너 서버 그룹3. 독특한 컨셉 위주로 운영됩니다.<br>
<span class="Entrance_Hwe">훼섭</span> : 운영자 테스트 서버입니다. 기습적으로 열리고, 닫힐 수 있습니다.<br>
</td>
</tr>
</tfoot>