From 18429d52d463ce21a01f7caa8823b9d83824b183 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 26 Jun 2018 00:32:43 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=85=EC=9E=A5=20=EC=9D=BC=EB=9E=8C,=20?= =?UTF-8?q?=EB=AA=85=EC=98=88=EC=9D=98=20=EC=A0=84=EB=8B=B9=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9E=AC=EA=B5=AC=ED=98=84.=20=EC=97=B0=EA=B0=90?= =?UTF-8?q?=20=EB=93=B1=EC=97=90=20=EC=9D=B4=EC=A0=84=20=EA=B5=AD=EA=B0=80?= =?UTF-8?q?=20=EA=B8=B0=EB=A1=9D=20=EB=82=A8=EA=B8=B0=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_bestGeneral.php | 418 +++++++++++----------------------- hwe/a_hallOfFame.php | 95 +++----- hwe/a_history.php | 31 +-- hwe/css/hallOfFrame.css | 76 +++++++ hwe/func.php | 87 +++---- hwe/func_history.php | 1 + hwe/func_map.php | 14 +- hwe/func_message.php | 12 - hwe/j_map_history.php | 7 +- hwe/sammo/ResetHelper.php | 13 +- hwe/sql/reset.sql | 3 - hwe/sql/schema.sql | 77 ++----- hwe/templates/hallOfFrame.php | 21 ++ i_entrance/entrance.php | 12 +- 14 files changed, 378 insertions(+), 489 deletions(-) create mode 100644 hwe/css/hallOfFrame.css create mode 100644 hwe/templates/hallOfFrame.php diff --git a/hwe/a_bestGeneral.php b/hwe/a_bestGeneral.php index 19459516..76c4b99a 100644 --- a/hwe/a_bestGeneral.php +++ b/hwe/a_bestGeneral.php @@ -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(); -} ?> @@ -36,14 +26,14 @@ if ($con >= 2) { <?=UniqueConst::$serverName?>: 명장일람 - + - +
명 장 일 람
- +
@@ -51,294 +41,156 @@ if ($con >= 2) {
- +
=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 " -
- - "; - - 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] = " "; - } - if ($pic[$k] == "") { - echo ""; - } else { - $imageTemp = GetImageURL($gen['imgsvr']); - echo ""; - } + else{ + $general['pictureFullPath'] = GetImageURL(0)."/default.jpg"; } - echo ""; + 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 ""; - } - echo ""; +$templates = new \League\Plates\Engine('templates'); - for ($k=0; $k < 10; $k++) { - echo ""; - } +foreach($types as $idx=>[$typeName, $typeValue, $typeFunc]){ + $typeGenerals = array_map(function($general) use($typeValue, $typeFunc){ + $general = ($typeFunc)($general); + $value = $general['value']; - echo ""; - - 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 ""; - } - echo ""; + 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 " -
$type[$i]
1위2위3위4위5위6위7위8위9위10위
 
{$nation[$k]}
{$name[$k]}
{$data[$k]}
-
- -"; - -$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 " - - "; - for ($k=26; $k > 16; $k--) { - $str = $func[$i]($k); - echo ""; - } - - echo ""; - - 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] = " "; - } - if ($pic[$k] == "") { - echo ""; - } else { - $imageTemp = GetImageURL($gen['imgsvr']??0); - echo ""; - } - } - - echo ""; - - for ($k=26; $k > 16; $k--) { - echo ""; - } - - echo ""; - - for ($k=26; $k > 16; $k--) { - echo ""; - } - - echo ""; - - echo " - "; - for ($k=16; $k > 6; $k--) { - $str = $func[$i]($k); - echo ""; - } - - echo ""; - - 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] = " "; - } - if ($pic[$k] == "") { - echo ""; - } else { - $imageTemp = GetImageURL($gen['imgsvr']??0); - echo ""; - } - } - - echo ""; - - for ($k=16; $k > 6; $k--) { - echo ""; - } - - echo ""; - - for ($k=16; $k > 6; $k--) { - echo ""; - } - - echo ""; -} - ?> -
$type[$i]
".$str."
 
{$nation[$k]}
{$name[$k]}
".$str."
 
{$nation[$k]}
{$name[$k]}
- + +
+[,$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 + ]); +} +?> +
+
diff --git a/hwe/a_hallOfFame.php b/hwe/a_hallOfFame.php index 3e46207e..1ef2d2c2 100644 --- a/hwe/a_hallOfFame.php +++ b/hwe/a_hallOfFame.php @@ -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); ?> @@ -17,16 +19,16 @@ increaseRefresh("명예의전당", 2); <?=UniqueConst::$serverName?>: 명예의 전당 - + - +
명 예 의 전 당
- +
- - "; +$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] = " "; + if(key_exists('picture', $general)){ + $imageTemp = GetImageURL($general['imgsvr']); + $general['pictureFullPath'] = "$imageTemp/{$general['picture']}"; } - /* - if($pic[$k] == "") { - echo ""; - } else { - $imageTemp = GetImageURL($gen['imgsvr']); - echo ""; - } - */ - } - -// echo ""; - - for ($k=0; $k < 10; $k++) { - echo ""; - } - - echo ""; - - for ($k=0; $k < 10; $k++) { - echo ""; - } - - echo ""; - - 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 ""; - } - echo ""; + return $general; + }, $hallResult); + + echo $templates->render('hallOfFrame', [ + 'typeName'=>$typeName, + 'generals'=>$hallResult + ]); } ?> -
$type[$i]
1위2위3위4위5위6위7위8위9위10위
 
{$nation[$k]}
{$name[$k]}
{$data[$k]}
- + +
diff --git a/hwe/a_history.php b/hwe/a_history.php index 739658c3..72e127ba 100644 --- a/hwe/a_history.php +++ b/hwe/a_history.php @@ -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) { diff --git a/hwe/css/hallOfFrame.css b/hwe/css/hallOfFrame.css new file mode 100644 index 00000000..3df9e35c --- /dev/null +++ b/hwe/css/hallOfFrame.css @@ -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; +} \ No newline at end of file diff --git a/hwe/func.php b/hwe/func.php index 53e44080..54539d0b 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -1916,10 +1916,6 @@ function updateTurntime($no) { $josaYi = JosaUtil::pick($general['name2'], '이'); $alllog[0] = "●{$admin['month']}월:{$general['name2']}{$josaYi} {$general['name']}의 육체에서 유체이탈합니다!"; 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 + ]); } } diff --git a/hwe/func_history.php b/hwe/func_history.php index 813916ec..0f6952bf 100644 --- a/hwe/func_history.php +++ b/hwe/func_history.php @@ -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, diff --git a/hwe/func_map.php b/hwe/func_map.php index 74593e51..6fbdc56a 100644 --- a/hwe/func_map.php +++ b/hwe/func_map.php @@ -1,12 +1,14 @@ 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(); diff --git a/hwe/func_message.php b/hwe/func_message.php index 3f512278..f00def43 100644 --- a/hwe/func_message.php +++ b/hwe/func_message.php @@ -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),""); -} diff --git a/hwe/j_map_history.php b/hwe/j_map_history.php index 688cec7c..a9664449 100644 --- a/hwe/j_map_history.php +++ b/hwe/j_map_history.php @@ -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([ diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php index 90a8f2d8..3c546b44 100644 --- a/hwe/sammo/ResetHelper.php +++ b/hwe/sammo/ResetHelper.php @@ -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', [ diff --git a/hwe/sql/reset.sql b/hwe/sql/reset.sql index 83bc8cef..3b3174f0 100644 --- a/hwe/sql/reset.sql +++ b/hwe/sql/reset.sql @@ -31,9 +31,6 @@ DROP TABLE IF EXISTS auction; # 통계 테이블 삭제 DROP TABLE IF EXISTS statistic; -# 연감 테이블 삭제 -DROP TABLE IF EXISTS history; - # 이벤트 테이블 삭제 DROP TABLE IF EXISTS event; diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index 1bf3bffb..c7739da7 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -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; ########################################################################### ## 이벤트 핸들러 테이블 diff --git a/hwe/templates/hallOfFrame.php b/hwe/templates/hallOfFrame.php new file mode 100644 index 00000000..bde96ea1 --- /dev/null +++ b/hwe/templates/hallOfFrame.php @@ -0,0 +1,21 @@ +
+

+
    +$general): ?>
  • > +
    + +
    +
    + +
    + +
    +

    + +

    ()
    + +

    +
    +
  • +
+
\ No newline at end of file diff --git a/i_entrance/entrance.php b/i_entrance/entrance.php index 59b972fc..182c8500 100644 --- a/i_entrance/entrance.php +++ b/i_entrance/entrance.php @@ -92,12 +92,12 @@ if ($userGrade >= 5) { 계정은 한번 등록으로 계속 사용합니다. 각 서버 리셋시 캐릭터만 새로 생성하면 됩니다.

체섭 : 메인서버입니다. 천하통일에 도전하여 왕조일람과 명예의전당에 올라봅시다! (주로 1턴=60분)
-퀘섭 : 실제 장수가 되어 가상의 역사를 만들어 봅시다!
-풰섭 : 실제 장수들과 어울려 사실적 역사를 체험해 봅시다!
-퉤섭 : 주로 패치사항 미리보기 테스트 서버입니다.
-냐섭 : 신 서버.
-퍄섭 : 신 서버2.
-훼섭 : 1일천하 서버. 또는 운영자 테스트용 서버입니다.
+퀘섭 : 마이너 서버 그룹1. 비교적 느린 시간으로 운영됩니다.
+풰섭 : 마이너 서버 그룹1. 비교적 느린 시간으로 운영됩니다.
+퉤섭 : 마이너 서버 그룹2. 비교적 빠른 시간으로 운영됩니다.
+냐섭 : 마이너 서버 그룹3. 독특한 컨셉 위주로 운영됩니다.
+퍄섭 : 마이너 서버 그룹3. 독특한 컨셉 위주로 운영됩니다.
+훼섭 : 운영자 테스트 서버입니다. 기습적으로 열리고, 닫힐 수 있습니다.