game table을 KVStorage로 일부 대체

This commit is contained in:
2018-05-13 00:52:16 +09:00
parent 67ecd514a4
commit 9d6181ede1
36 changed files with 196 additions and 308 deletions
+3 -5
View File
@@ -28,9 +28,7 @@ $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select turntime,tnmt_time from game";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
list($turntime, $tnmt_time) = $gameStor->getValuesAsArray(['turntime','tnmt_time']);
$query = "select plock from plock";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -46,8 +44,8 @@ $plock = MYDB_fetch_array($result);
</head>
<body>
<form action=_119_b.php method=post>
시간조정 : <input type=text size=3 name=minute><input type=submit name=btn value='분당김'><input type=submit name=btn value='분지연'> 최종갱신 : <?=$admin['turntime']?><br>
시간조정 : <input type=text size=3 name=minute2><input type=submit name=btn value='토너분당김'><input type=submit name=btn value='토너분지연'> 토너먼트 : <?=$admin['tnmt_time']?><br>
시간조정 : <input type=text size=3 name=minute><input type=submit name=btn value='분당김'><input type=submit name=btn value='분지연'> 최종갱신 : <?=$turntime?><br>
시간조정 : <input type=text size=3 name=minute2><input type=submit name=btn value='토너분당김'><input type=submit name=btn value='토너분지연'> 토너먼트 : <?=$tnmt_time?><br>
봉급지급 : <input type=submit name=btn value='금지급'><input type=submit name=btn value='쌀지급'><br>
락 풀 기 : <input type=submit name=btn value='락걸기'><input type=submit name=btn value='락풀기'> 현재 : <?=$plock['plock']>0?"동결중":"가동중"?><br>
</form>
+38 -22
View File
@@ -28,32 +28,50 @@ extractMissingPostToGlobals();
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
switch($btn) {
case "분당김":
$query = "update game set turntime=DATE_SUB(turntime, INTERVAL $minute MINUTE),starttime=DATE_SUB(starttime, INTERVAL $minute MINUTE),tnmt_time=DATE_SUB(tnmt_time, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update general set turntime=DATE_SUB(turntime, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update auction set expire=DATE_SUB(expire, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->cacheValues('turntime', 'starttime', 'tnmt_time');
$turntime = (new \DateTimeImmutable($gameStor->turntime))->sub(new \DateInterval("PT{$minute}M"));
$starttime = (new \DateTimeImmutable($gameStor->starttime))->sub(new \DateInterval("PT{$minute}M"));
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->sub(new \DateInterval("PT{$minute}M"));
$gameStor->turntime = $turntime->format('Y-m-d H:i:s');
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
$db->update('general', [
'turntime'=>$db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
], true);
$db->update('auction', [
'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
], true);
break;
case "분지연":
$query = "update game set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE),starttime=DATE_ADD(starttime, INTERVAL $minute MINUTE),tnmt_time=DATE_ADD(tnmt_time, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update general set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update auction set expire=DATE_ADD(expire, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->cacheValues('turntime', 'starttime', 'tnmt_time');
$turntime = (new \DateTimeImmutable($gameStor->turntime))->add(new \DateInterval("PT{$minute}M"));
$starttime = (new \DateTimeImmutable($gameStor->starttime))->add(new \DateInterval("PT{$minute}M"));
$tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->add(new \DateInterval("PT{$minute}M"));
$gameStor->turntime = $turntime->format('Y-m-d H:i:s');
$gameStor->starttime = $starttime->format('Y-m-d H:i:s');
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
$db->update('general', [
'turntime'=>$db->sqleval('DATE_ADD(turntime, INTERVAL %i MINUTE)', $minute)
], true);
$db->update('auction', [
'expire'=>$db->sqleval('DATE_ADD(expire, INTERVAL %i MINUTE)', $minute)
], true);
break;
case "토너분당김":
$query = "update game set tnmt_time=DATE_SUB(tnmt_time, INTERVAL $minute2 MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$tnmt_time = new \DateTime($gameStor->tnmt_time);
$tnmt_time->sub(new \DateInterval("PT{$minute2}M"));
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
break;
case "토너분지연":
$query = "update game set tnmt_time=DATE_ADD(tnmt_time, INTERVAL $minute2 MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$tnmt_time = new \DateTimeImmutable($gameStor->tnmt_time);
$tnmt_time->add(new \DateInterval("PT{$minute2}M"));
$gameStor->tnmt_time = $tnmt_time->format('Y-m-d H:i:s');
break;
case "금지급":
processGoldIncome();
@@ -62,12 +80,10 @@ case "쌀지급":
processRiceIncome();
break;
case "락걸기":
$query = "update plock set plock=1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$db->update('plock', ['plock'=>1], true);
break;
case "락풀기":
$query = "update plock set plock=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$db->update('plock', ['plock'=>0], true);
break;
}
+7 -13
View File
@@ -40,9 +40,7 @@ $admin = getAdmin();
switch ($btn) {
case "변경":
$msg = addslashes(SQ2DQ($msg));
$query = "update game set msg='$msg'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->msg = $msg;
break;
case "로그쓰기":
$lognum = $admin['historyindex'] + 1;
@@ -52,20 +50,16 @@ switch ($btn) {
pushWorldHistory(["<R>★</><S>{$log}</>"]);
break;
case "변경1":
$query = "update game set starttime='$starttime'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->starttime = (new \DateTime($starttime))->format('Y-m-d H:i:s');
break;
case "변경2":
$query = "update game set maxgeneral='$maxgeneral'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->maxgeneral = $maxgeneral;
break;
case "변경3":
$query = "update game set maxnation='$maxnation'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->maxnation = $maxnation;
break;
case "변경4":
$query = "update game set startyear='$startyear'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->startyear = $startyear;
break;
case "1분턴":
case "2분턴":
@@ -89,8 +83,8 @@ switch ($btn) {
$turn = ($admin['year'] - $admin['startyear']) * 12 + $admin['month'] - 1;
$starttime = date("Y-m-d H:i:s", strtotime($admin['turntime']) - $turn * $unit);
$starttime = cutTurn($starttime, $turnterm);
$query = "update game set turnterm='$turnterm',starttime='$starttime'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$gameStor->turnterm = $turnterm;
$gameStor->starttime = $starttime;
// 턴시간이 길어지는 경우 랜덤턴 배정
if ($turnterm < $admin['turnterm']) {
$query = "select no from general";
+2 -11
View File
@@ -26,12 +26,7 @@ if($session->userGrade < 5) {
}
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
?>
<!DOCTYPE html>
<html>
@@ -60,13 +55,9 @@ $admin = MYDB_fetch_array($result);
echo "
<select name=genlist[] size=20 multiple style=color:white;background-color:black;font-size:13>";
$generalList = $db->query('SELECT `no`, `name`, npc, `block` FROM general ORDER BY npc, binary(`name`)');
$query = "select no,name,npc,block from general order by npc,binary(name)";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gencount = MYDB_num_rows($result);
for($i=0; $i < $gencount; $i++) {
$general = MYDB_fetch_array($result);
foreach($generalList as $general){
$style = "style=;";
if($general['block'] > 0) { $style .= "background-color:red;"; }
if($general['npc'] >= 2) { $style .= "color:cyan;"; }
+2 -2
View File
@@ -98,7 +98,7 @@ switch($btn) {
], '`no` IN %li', $genlist);
break;
case "특기 부여":
list($year, $month) = $db->queryFirstList('select `year`, `month` from `game` where `no`=1');
list($year, $month) = $gameStor->getValuesAsArray(['year', 'month']);
$text = "특기 부여!";
foreach($db->query("SELECT `no`,leader,power,intel,dex0,dex10,dex20,dex30,dex40 FROM general WHERE `no` IN %li", $genlist) as $general){
@@ -327,7 +327,7 @@ switch($btn) {
], '`no` IN %li', $genlist);
break;
case "00턴":
$turnterm = $db->queryFirstField('SELECT turnterm FROM game LIMIT 1');
$turnterm = $gameStor->turnterm;
foreach($genlist as $generalID){
$turntime = getRandTurn($turnterm);
+2 -4
View File
@@ -29,9 +29,7 @@ $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$conlimit = $gameStor->conlimit;
?>
<!DOCTYPE html>
<html>
@@ -65,7 +63,7 @@ for($i=0; $i < $gencount; $i++) {
if($general['block'] > 0) { $style .= "background-color:red;"; }
if($general['npc'] >= 2) { $style .= "color:cyan;"; }
elseif($general['npc'] == 1) { $style .= "color:skyblue;"; }
if($general['con'] > $admin['conlimit']) { $style .= "color:red;"; }
if($general['con'] > $conlimit) { $style .= "color:red;"; }
echo "
<option value={$general['no']} $style>{$general['name']}</option>";
-4
View File
@@ -39,7 +39,6 @@ if($session->userGrade < 5) {
}
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$sel = [];
@@ -47,9 +46,6 @@ $sel2 = [];
$sel[$type] = "selected";
$sel2[$type2] = "selected";
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
?>
<!DOCTYPE html>
<html>
+20 -22
View File
@@ -82,11 +82,9 @@ $query = "select no,tournament,con,turntime from general where owner='{$userID}'
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
$query = "select * from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$game = MYDB_fetch_array($result);
$game_env = $gameStor->getAll();
$con = checkLimit($me['con'], $game['conlimit']);
$con = checkLimit($me['con']);
if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
if($session->userGrade < 3) {
@@ -174,7 +172,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
$opposecount = 0;
}
$warphase = getRate($game, $general['crewtype'], "spd"); //병종간 페이즈 수 얻기
$warphase = getRate($game_env, $general['crewtype'], "spd"); //병종간 페이즈 수 얻기
// 우선 스케일링
$city['def'] *= 10;
@@ -302,7 +300,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
}
//회피
$ratio = rand() % 100; // 0 ~ 99
$ratio2 = getRate($game, $general['crewtype'], "avd"); //회피율
$ratio2 = getRate($game_env, $general['crewtype'], "avd"); //회피율
if($ratio < $ratio2 && $avoid == 1) {
$msg .= "<C>●</><C>회피</>했다!</><br>";
$myCrew /= 10; // 10%만 소모
@@ -666,7 +664,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
}
//회피
$ratio = rand() % 100; // 0 ~ 99
$ratio2 = getRate($game, $general['crewtype'], "avd"); //회피율
$ratio2 = getRate($game_env, $general['crewtype'], "avd"); //회피율
if($ratio < $ratio2 && $myAvoid == 1) {
$msg .= "<C>●</><C>회피</>했다!</><br>";
$myCrew /= 10; // 10%만 소모
@@ -674,7 +672,7 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
}
//회피
$ratio = rand() % 100; // 0 ~ 99
$ratio2 = getRate($game, $oppose['crewtype'], "avd"); //회피율
$ratio2 = getRate($game_env, $oppose['crewtype'], "avd"); //회피율
if($ratio < $ratio2 && $opAvoid == 1) {
$msg .= "<C>●</>상대가 <R>회피</>했다!</><br>";
$opCrew /= 10; // 10%만 소모
@@ -803,8 +801,8 @@ if($isgen == "장수공격" || $isgen == "성벽공격" || $isgen == "장수평
$def = 7000;
$wall = 7000;
$train3 = $game['city_rate'];
$atmos3 = $game['city_rate'];
$train3 = $game_env['city_rate'];
$atmos3 = $game_env['city_rate'];
}
switch($level1) {
@@ -1599,31 +1597,31 @@ if($isgen == "장수공격" || $isgen == "성벽공격") {
<?php
for($i=0; $i <= 5; $i++) {
printSimul($game, $i);
printSimul($game_env, $i);
}
echo "
<tr><td height=5 colspan=8 id=bg1></td></tr>";
for($i=10; $i <= 14; $i++) {
printSimul($game, $i);
printSimul($game_env, $i);
}
echo "
<tr><td height=5 colspan=8 id=bg1></td></tr>";
for($i=20; $i <= 27; $i++) {
printSimul($game, $i);
printSimul($game_env, $i);
}
echo "
<tr><td height=5 colspan=8 id=bg1></td></tr>";
for($i=30; $i <= 38; $i++) {
printSimul($game, $i);
printSimul($game_env, $i);
}
echo "
<tr><td height=5 colspan=8 id=bg1></td></tr>";
for($i=40; $i <= 43; $i++) {
printSimul($game, $i);
printSimul($game_env, $i);
}
echo "
<tr><td height=5 colspan=8 id=bg1></td></tr>";
@@ -1634,13 +1632,13 @@ if($isgen == "장수공격" || $isgen == "성벽공격") {
</html>
<?php
function printSimul($game, $i) {
$att = $game["att{$i}"];
$def = $game["def{$i}"];
$spd = $game["spd{$i}"];
$avd = $game["avd{$i}"];
$cst = $game["cst{$i}"];
$ric = $game["ric{$i}"];
function printSimul($game_env, $i) {
$att = $game_env["att{$i}"];
$def = $game_env["def{$i}"];
$spd = $game_env["spd{$i}"];
$avd = $game_env["avd{$i}"];
$cst = $game_env["cst{$i}"];
$ric = $game_env["ric{$i}"];
echo "
<tr>
<td align=right>".GameUnitConst::byId($i)->name."</td>
+2 -5
View File
@@ -18,15 +18,11 @@ $connect=$db->get();
increaseRefresh("명장일람", 2);
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$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'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
@@ -102,6 +98,7 @@ for ($i=0; $i < 21; $i++) {
$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;
+1 -5
View File
@@ -18,15 +18,11 @@ $connect=$db->get();
increaseRefresh("장수일람", 2);
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$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'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+2 -4
View File
@@ -18,15 +18,13 @@ $connect=$db->get();
increaseRefresh("연감", 2);
$query = "select startyear,year,month,conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['startyear','year','month','conlimit']);
$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'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -5
View File
@@ -13,15 +13,11 @@ $connect=$db->get();
increaseRefresh("세력일람", 2);
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$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'], $admin['conlimit']);
$con = checkLimit($me['con']);
if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
?>
<!DOCTYPE html>
+1 -6
View File
@@ -13,17 +13,12 @@ $connect=$db->get();
increaseRefresh("세력도", 2);
checkTurn();
$gameStor->resetCache();
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$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'], $admin['conlimit']);
$con = checkLimit($me['con']);
if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
?>
<!DOCTYPE html>
+16 -18
View File
@@ -10,9 +10,7 @@ $connect=$db->get();
increaseRefresh("갱신정보", 2);
$query = "select year,month,refresh,maxrefresh,maxonline from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$game = MYDB_fetch_array($result);
$game_env = $gameStor->getValues(['year','month','refresh','maxrefresh','maxonline']);
$log = getRawFileLogRecent(__dir__.'/logs/_traffic.txt', 11, 100);
@@ -31,21 +29,21 @@ foreach($log as $i=>$value){
$refresh[$i] = $parse[3];
$online[$i] = $parse[4];
}
$year[] = $game['year'];
$month[] = $game['month'];
$year[] = $game_env['year'];
$month[] = $game_env['month'];
$date[] = date('Y-m-d H:i:s');
if ($game['maxrefresh'] == 0) {
$game['maxrefresh'] = 1;
if ($game_env['maxrefresh'] == 0) {
$game_env['maxrefresh'] = 1;
}
if ($game['maxrefresh'] < $game['refresh']) {
$game['maxrefresh'] = $game['refresh'];
if ($game_env['maxrefresh'] < $game_env['refresh']) {
$game_env['maxrefresh'] = $game_env['refresh'];
}
if ($game['maxonline'] == 0) {
$game['maxonline'] = 1;
if ($game_env['maxonline'] == 0) {
$game_env['maxonline'] = 1;
}
if ($game['maxonline'] < $curonline) {
$game['maxonline'] = $curonline;
if ($game_env['maxonline'] < $curonline) {
$game_env['maxonline'] = $curonline;
}
?>
<!DOCTYPE html>
@@ -91,9 +89,9 @@ span.out_bar{
<table align=center class='tb_layout bg0'>
<tr><td colspan=4 align=center id=bg2><font size=5>접 속 량</font></td></tr>
<?php
$refresh[] = $game['refresh'];
$refresh[] = $game_env['refresh'];
foreach($refresh as $i=>$value){
$w = round($value / $game['maxrefresh'] * 100, 1);
$w = round($value / $game_env['maxrefresh'] * 100, 1);
$color = getTrafficColor($w);
$dt = substr($date[$i], 11, 5); ?>
<tr height=30>
@@ -116,7 +114,7 @@ foreach($refresh as $i=>$value){
?>
<tr><td colspan=4 height=5 align=center id=bg1></td></tr>
<tr>
<td colspan=4 height=30 align=center id=bg0>최고기록: <?=$game['maxrefresh']?></td>
<td colspan=4 height=30 align=center id=bg0>최고기록: <?=$game_env['maxrefresh']?></td>
</tr>
@@ -128,7 +126,7 @@ foreach($refresh as $i=>$value){
<?php
$online[] = $curonline;
foreach($online as $i=>$value){
$w = round($value / $game['maxonline'] * 100, 1);
$w = round($value / $game_env['maxonline'] * 100, 1);
$color = getTrafficColor($w);
$dt = substr($date[$i], 11, 5); ?>
<tr height=30>
@@ -151,7 +149,7 @@ foreach($online as $i=>$value){
?>
<tr><td colspan=4 height=5 align=center id=bg1></td></tr>
<tr>
<td colspan=4 height=30 align=center id=bg0>최고기록: <?=$game['maxonline']?></td>
<td colspan=4 height=30 align=center id=bg0>최고기록: <?=$game_env['maxonline']?></td>
</tr>
</table>
</td></tr>
+1 -3
View File
@@ -16,9 +16,7 @@ $query = "select no,vote from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$me = MYDB_fetch_array($result);
$query = "select develcost,voteopen,vote,votecomment from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['develcost','voteopen','vote','votecomment']);
$vote = explode("|", $admin['vote']);
if ($vote[0] == "") {
+1 -5
View File
@@ -23,11 +23,7 @@ $query = "select no,special,con,turntime from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$me = MYDB_fetch_array($result);
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -5
View File
@@ -31,10 +31,6 @@ increaseRefresh("감찰부", 2);
checkTurn();
$gameStor->resetCache();
$query = "select conlimit from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$query = "select nation from general where no='$gen'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$general = MYDB_fetch_array($result);
@@ -47,7 +43,7 @@ $query = "select secretlimit from nation where nation='{$me['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$nation = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -1
View File
@@ -22,7 +22,7 @@ $query = "select conlimit,tournament,phase,tnmt_type,develcost,bet0,bet1,bet2,be
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -1
View File
@@ -25,7 +25,7 @@ $query = "select secretlimit from nation where nation='{$me['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$nation = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if($con >= 2) { printLimitMsg($me['turntime']); exit(); }
if($me['level'] == 0 || ($me['level'] == 1 && $me['belong'] < $nation['secretlimit'])) {
+1 -1
View File
@@ -25,7 +25,7 @@ $query = "select secretlimit from nation where nation='{$me['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$nation = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -1
View File
@@ -33,7 +33,7 @@ $query = "select level,secretlimit from nation where nation='{$me['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$nation = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+1 -1
View File
@@ -22,7 +22,7 @@ $query = "select conlimit,tournament,phase,tnmt_msg,tnmt_type,develcost,tnmt_tri
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$admin = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+2 -3
View File
@@ -60,9 +60,8 @@ if($betGold + 500 <= $myGold && $betGold + $oldBet <= 1000 && $betGold + $totalB
"bet{$betTarget}"=>$db->sqleval("bet{$betTarget} + %i", $betGold),
'betgold'=>$db->sqleval('betgold + %i', $betGold)
], 'owner = %i', $userID);
$db->update('game', [
"bet{$betTarget}"=>$db->sqleval("bet{$betTarget} + %i", $betGold)
], true);
$gameStor->setValue("bet{$betTarget}", $gameStor->getValue("bet{$betTarget}") + $betGold);//TODO: +로 증가하는 storage값은 별도로 분리
}
header('location: b_betting.php');
+5 -9
View File
@@ -24,9 +24,7 @@ $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select tournament,phase,tnmt_type,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['tournament','phase','tnmt_type','develcost']);
$query = "select no,name,tournament from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -94,15 +92,13 @@ if($session->userGrade < 5) {
}
if($btn == "자동개최설정") {
$db->update('game', ['tnmt_trig'=>$trig], true);
$gameStor->tnmt_trig = $trig;
} elseif($btn == "개최") {
startTournament($auto, $type);
} elseif($btn == "중단") {
$db->update('game', [
'tnmt_auto'=>0,
'tournament'=>0,
'phase'=>0
], true);
$gameStor->tnmt_auto = 0;
$gameStor->tournament = 0;
$gameStor->phase = 0;
} elseif($btn == "투입" || $btn == "무명투입" || $btn == "쪼렙투입" || $btn == "일반투입" || $btn == "굇수투입" || $btn == "랜덤투입") {
if($btn == "투입") {
$query = "select no,name,npc,leader,power,intel,explevel,gold,horse,weap,book from general where no='$gen'";
+39 -49
View File
@@ -89,7 +89,7 @@ function GetImageURL($imgsvr, $filepath='') {
* @param null|int $con 장수의 벌점
* @param null|int $conlimit 최대 벌점
*/
function checkLimit($con = null, $conlimit = null) {
function checkLimit($con = null) {
$session = Session::getInstance();
if($session->userGrade>=4){
return 0;
@@ -101,9 +101,7 @@ function checkLimit($con = null, $conlimit = null) {
if($con === null){
$con = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', Session::getUserID());
}
if($conlimit === null){
$conlimit = $db->queryFirstField('SELECT conlimit FROM game LIMIT 1');
}
$conlimit = $gameStor->conlimit;
if($con > $conlimit) {
return 2;
@@ -1101,7 +1099,7 @@ function adminMsg() {
}
function getOnlineNum() {
return DB::db()->queryFirstField('select `online` from `game` where `no`=1');
return KVStorage::getStorage(DB::db(), 'game_env')->online;
}
function onlinegen() {
@@ -1277,9 +1275,7 @@ function increaseRefresh($type="", $cnt=1) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$db->update('game', [
'refresh'=>$db->sqleval('refresh+%i', $cnt)
], true);
$gameStor->refresh = $gameStor->refresh+$cnt; //TODO: +로 증가하는 값은 별도로 분리
if($generalID) {
$db->update('general', [
@@ -1348,7 +1344,7 @@ function updateTraffic() {
$online = getOnlineNum();
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$game = $db->queryFirstRow('SELECT year,month,refresh,maxonline,maxrefresh from game limit 1');
$game = $gameStor->getValues(['year','month','refresh','maxonline','maxrefresh']);
//최다갱신자
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
@@ -1359,11 +1355,9 @@ function updateTraffic() {
if($game['maxonline'] < $online) {
$game['maxonline'] = $online;
}
$db->update('game',[
'refresh'=>0,
'maxrefresh'=>$game['maxrefresh'],
'maxonline'=>$game['maxonline']
], true);
$gameStor->refresh = 0;
$gameStor->maxrefresh = $game['maxrefresh'];
$gameStor->maxonline = $game['maxonline'];
$db->update('general', ['refresh'=>0], true);
@@ -1447,14 +1441,14 @@ function timeover() {
function checkDelay() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
//서버정보
$query = "select turnterm,now() as now,TIMESTAMPDIFF(MINUTE,turntime,now()) as offset from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$now = new \DateTimeImmutable();
$turntime = new \DateTimeImmutable($gameStor->turntime);
$timeMinDiff = intdiv($now->getTimestamp() - $turntime->getTimestamp(), 60);
// 1턴이상 갱신 없었으면 서버 지연
$term = $admin['turnterm'];
$term = $gameStor->turnterm;
if($term >= 20){
$threshold = 1;
}
@@ -1465,15 +1459,19 @@ function checkDelay() {
$threshold = 3;
}
//지연 해야할 밀린 턴 횟수
$iter = intdiv($admin['offset'], $term);
$iter = intdiv($timeMinDiff, $term);
if($iter > $threshold) {
$minute = $iter * $term;
$query = "update game set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE),starttime=DATE_ADD(starttime, INTERVAL $minute MINUTE),tnmt_time=DATE_ADD(tnmt_time, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update general set turntime=DATE_ADD(turntime, INTERVAL $minute MINUTE) where turntime<=DATE_ADD(turntime, INTERVAL $term MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update auction set expire=DATE_ADD(expire, INTERVAL $minute MINUTE)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$newTurntime = $turntime->add(new DateInterval("PT{$minute}M"));
$newNextTurntime = $turntime->add(new DateInterval("PT{$term}M"));
$gameStor->turntime = $newTurntime;
$db->update('general', [
'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)
], true);
}
}
@@ -1583,14 +1581,11 @@ function checkTurn() {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', CheckOverhead');
CheckOverhead();
//서버정보
$query = "select * from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$date = date('Y-m-d H:i:s');
// 최종 처리 월턴의 다음 월턴시간 구함
$prevTurn = cutTurn($admin['turntime'], $admin['turnterm']);
$nextTurn = addTurn($prevTurn, $admin['turnterm']);
$prevTurn = cutTurn($gameStor->turntime, $gameStor->turnterm);
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
// 현재 턴 이전 월턴까지 모두처리.
//최종 처리 이후 다음 월턴이 현재 시간보다 전이라면
while($nextTurn <= $date) {
@@ -1634,10 +1629,9 @@ function checkTurn() {
}
// 그 시각 년도,월 저장
$dt = turnDate($nextTurn);
$admin['year'] = $dt[0]; $admin['month'] = $dt[1];
list($gameStor->year, $gameStor->month) = turnDate($nextTurn);
pushLockLog(["-- checkTurn() ".$admin['month']."월 : ".date('Y-m-d H:i:s')." : ".$session->userName]);
pushLockLog(["-- checkTurn() ".$gameStor->month."월 : ".date('Y-m-d H:i:s')." : ".$session->userName]);
// 이벤트 핸들러 동작
foreach (DB::db()->query('SELECT * from event') as $rawEvent) {
@@ -1646,13 +1640,12 @@ function checkTurn() {
$action = Json::decode($rawEvent['action']);
$event = new Event\EventHandler($cond, $action);
$event->tryRunEvent(['currentEventID'=>$eventID] + $admin);
$event->tryRunEvent(['currentEventID'=>$eventID] + $gameStor->getAll(true));
}
// 분기계산. 장수들 턴보다 먼저 있다면 먼저처리
if($admin['month'] == 1) {
if($gameStor->month == 1) {
// NPC 등장
//if($admin['scenario'] > 0 && $admin['scenario'] < 20) { RegNPC(); }
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', processGoldIncome');
processGoldIncome();
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', processSpring');
@@ -1668,14 +1661,14 @@ function checkTurn() {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', addAge');
addAge();
// 새해 알림
$alllog[] = "<C>◆</>{$admin['month']}월:<C>{$admin['year']}</>년이 되었습니다.";
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
} elseif($admin['month'] == 4) {
$alllog[] = "<C>◆</>{$gameStor->month}월:<C>{$gameStor->year}</>년이 되었습니다.";
pushGeneralPublicRecord($alllog, $gameStor->year, $gameStor->month);
} elseif($gameStor->month == 4) {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', updateQuaterly');
updateQuaterly();
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', disaster');
disaster();
} elseif($admin['month'] == 7) {
} elseif($gameStor->month == 7) {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', processRiceIncome');
processRiceIncome();
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', processFall');
@@ -1686,7 +1679,7 @@ function checkTurn() {
disaster();
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', tradeRate');
tradeRate();
} elseif($admin['month'] == 10) {
} elseif($gameStor->month == 10) {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', updateQuaterly');
updateQuaterly();
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', disaster');
@@ -1697,18 +1690,16 @@ function checkTurn() {
// 다음달로 넘김
$prevTurn = $nextTurn;
$nextTurn = addTurn($prevTurn, $admin['turnterm']);
$nextTurn = addTurn($prevTurn, $gameStor->turnterm);
}
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', '.__LINE__);
// 이시각 정각 시까지 업데이트 완료했음
$query = "update game set turntime='$prevTurn'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->turntime = $prevTurn;
// 그 시각 년도,월 저장
$dt = turnDate($prevTurn);
$admin['year'] = $dt[0]; $admin['month'] = $dt[1];
list($gameStor->year, $gameStor->month) = turnDate($prevTurn);
// 현재시간의 월턴시간 이후 분단위 장수 처리
do {
$query = "select no,name,turntime,turn0,npc from general where turntime<='$date' order by turntime";
@@ -1736,8 +1727,7 @@ function checkTurn() {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', '.__LINE__);
$query = "update game set turntime='$date'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->turntime = $date;
// 부상 과도 제한
$query = "update general set injury='80' where injury>'80'";
+4 -4
View File
@@ -56,10 +56,10 @@ function getWorldMap($req){
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$game = $db->queryFirstRow('select `startyear`, `year`, `month` from `game` where `no` = 1');
$startYear = Util::toInt($game['startyear']);
$year = Util::toInt($game['year']);
$month = Util::toInt($game['month']);
list($startYear, $year, $month) = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
$startYear = Util::toInt($startYear);
$year = Util::toInt($year);
$month = Util::toInt($month);
$general = $db->queryFirstRow(
'select `no`, `city`, `nation` from `general` where `owner`=%i',
+22 -58
View File
@@ -13,9 +13,7 @@ function process_23(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -115,9 +113,7 @@ function process_24(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select year,month,scenario,startyear from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','scenario','startyear']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -252,9 +248,7 @@ function process_27(&$general) {
$who = $command[2];
$where = $command[1];
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -315,7 +309,7 @@ function process_51(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$date = substr($general['turntime'],11,5);
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
list($year, $month, $turnterm) = $gameStor->getValuesAsArray(['year','month','turnterm']);
if($general['level'] < 5 || $general['nation']==0) {
pushGenLog($general, ["<C>●</>{$month}월:수뇌부가 아닙니다. 권고 실패. <1>$date</>"]);
@@ -406,9 +400,7 @@ function process_52(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -512,7 +504,7 @@ function process_53(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$date = substr($general['turntime'],11,5);
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
list($year, $month, $turnterm) = $gameStor->getValuesAsArray(['year','month','turnterm']);
if($general['level'] < 5 || $general['nation']==0) {
pushGenLog($general, ["<C>●</>{$month}월:수뇌부가 아닙니다. 제의 실패. <1>$date</>"]);
@@ -597,7 +589,7 @@ function process_61(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$date = substr($general['turntime'],11,5);
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
list($year, $month, $turnterm) = $gameStor->getValuesAsArray(['year','month','turnterm']);
if($general['level'] < 5 || $general['nation']==0) {
pushGenLog($general, ["<C>●</>{$month}월:수뇌부가 아닙니다. 제의 실패. <1>$date</>"]);
@@ -704,9 +696,7 @@ function process_62(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','startyear']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -819,7 +809,7 @@ function process_63(&$general) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$date = substr($general['turntime'],11,5);
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
list($year, $month, $turnterm) = $gameStor->getValuesAsArray(['year','month','turnterm']);
if($general['level'] < 5 || $general['nation']==0) {
pushGenLog($general, ["<C>●</>{$month}월:수뇌부가 아닙니다. 제의 실패. <1>$date</>"]);
@@ -993,9 +983,7 @@ function process_65(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1089,9 +1077,7 @@ function process_66(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1180,9 +1166,7 @@ function process_67(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1272,9 +1256,7 @@ function process_68(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1377,9 +1359,7 @@ function process_71(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1484,9 +1464,7 @@ function process_72(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1600,9 +1578,7 @@ function process_73(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1732,9 +1708,7 @@ function process_74(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1877,9 +1851,7 @@ function process_75(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2004,9 +1976,7 @@ function process_76(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select startyear,year,month,develcost,npccount,turnterm from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['startyear','year','month','develcost','npccount','turnterm']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2224,9 +2194,7 @@ function process_77(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2353,9 +2321,7 @@ function process_78(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2478,9 +2444,7 @@ function process_81(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month']);
$query = "select nation from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+4 -12
View File
@@ -13,9 +13,7 @@ function process_32(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$dist = searchDistance($general['city'], 5, false);
$command = DecodeCommand($general['turn0']);
@@ -140,9 +138,7 @@ function process_33(&$general) {
//탈취는 0까지 무제한
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$dist = searchDistance($general['city'], 5, false);
$command = DecodeCommand($general['turn0']);
@@ -292,9 +288,7 @@ function process_34(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$dist = searchDistance($general['city'], 5, false);
$command = DecodeCommand($general['turn0']);
@@ -419,9 +413,7 @@ function process_35(&$general) {
$date = substr($general['turntime'],11,5);
$query = "select year,month,develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year','month','develcost']);
$dist = searchDistance($general['city'], 5, false);
$command = DecodeCommand($general['turn0']);
+1 -1
View File
@@ -68,7 +68,7 @@ function CoreTurnTable() {
function allButton() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$npcmode = DB::db()->queryFirstField("select npcmode from game limit 1");
$npcmode = $gameStor->npcmode;
if($npcmode == 1) {
$site = "a_npcList.php";
$call = "빙의일람";
+1 -1
View File
@@ -48,7 +48,7 @@ $query = "select plock from plock limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$plock = MYDB_fetch_array($result);
$con = checkLimit($me['con'], $admin['conlimit']);
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
exit();
+2 -4
View File
@@ -22,10 +22,8 @@ $now = new \DateTime();
$status = 'not_yet';
if ($db->queryFirstField("SHOW TABLES LIKE 'game'")) {
list($isUnited, $lastTurn) = $db->queryFirstList('SELECT isUnited, turntime FROM game LIMIT 1');
}
else{
list($isUnited, $lastTurn) = $gameStor->getValues(['isUnited', 'turntime']);
if($isUnited === null || $lastTurn === null){
$isUnited = 2;
$lastTurn = '2000-01-01';
}
+3 -1
View File
@@ -47,7 +47,9 @@ if(file_exists(__dir__.'/.htaccess')){
//TODO: 천통시에도 예약 오픈 알림이 필요..?
$game = $db->queryFirstRow('SELECT isUnited, npcMode, year, month, scenario, scenario_text, maxgeneral as maxUserCnt, turnTerm from game where `no`=1');
$game = $gameStor->getValues(['isUnited', 'npcMode', 'year', 'month', 'scenario', 'scenario_text', 'maxgeneral', 'turnTerm']);
$game['maxUserCnt'] = $game['maxgeneral'];
unset($game['maxgeneral']);
$nationCnt = $db->queryFirstField('SELECT count(`nation`) from nation where `level` > 0');
$genCnt = $db->queryFirstField('SELECT count(`no`) from general where `npc` < 2');
+5 -15
View File
@@ -198,9 +198,6 @@ function command_11($turn, $command) {
$userID = Session::getUserID();
starter("징병");
$query = "select * from game limit 1";
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$query = "select no,nation,level,personal,special2,level,city,crew,horse,injury,leader,crewtype,gold from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
@@ -220,7 +217,7 @@ function command_11($turn, $command) {
$ownCities = [];
$ownRegions = [];
$relativeYear = $admin['year'] - $admin['startyear'];
$relativeYear = $gameStor->year - $gameStor->startyear;
$tech = $nation['tech'];
foreach(DB::db()->query('SELECT city, region from city where nation = %i', $me['nation']) as $city){
@@ -359,7 +356,7 @@ function calc(cost, formnum) {
$speed = $unit->speed;
$avoid = $unit->avoid;
$weapImage = ServConfig::$gameImagePath."/weap{$i}.png";
if($admin['show_img_level'] < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; }
if($gameStor->show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; }
$baseRiceShort = round($baseRice, 1);
$baseCostShort = round($baseCost, 1);
@@ -407,9 +404,6 @@ function command_12($turn, $command) {
$userID = Session::getUserID();
starter("모병");
$query = "select * from game limit 1";
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$query = "select no,nation,level,personal,special2,level,city,crew,horse,injury,leader,crewtype,gold from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error("aaa_processing.php ".MYDB_error($connect),"");
@@ -429,7 +423,7 @@ function command_12($turn, $command) {
$ownCities = [];
$ownRegions = [];
$relativeYear = $admin['year'] - $admin['startyear'];
$relativeYear = $gameStor->year - $gameStor->startyear;
$tech = $nation['tech'];
foreach(DB::db()->query('SELECT city, region from city where nation = %i', $me['nation']) as $city){
@@ -570,7 +564,7 @@ function calc(cost, formnum) {
$speed = $unit->speed;
$avoid = $unit->avoid;
$weapImage = ServConfig::$gameImagePath."/weap{$i}.png";
if($admin['show_img_level'] < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; }
if($gameStor->show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; }
$baseRiceShort = round($baseRice, 1);
$baseCostShort = round($baseCost, 1);
@@ -969,10 +963,6 @@ function command_25($turn, $command) {
starter("임관");
$query = "select startyear,year from game limit 1";
$result = MYDB_query($query, $connect) or Error("command_46 ".MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$query = "select no,nations from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error("command_27 ".MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
@@ -1005,7 +995,7 @@ function command_25($turn, $command) {
$scoutStr .= "<tr><td align=center width=100 style=color:".newColor($nation['color']).";background-color:{$nation['color']};>{$nation['name']}</td><td width=900 style=color:".newColor($nation['color']).";background-color:{$nation['color']}>".$nation['scoutmsg']."</td></tr>";
}
if($admin['year'] < $admin['startyear']+3 && $nation['gennum'] >= 10) {
if($gameStor->year < $gameStor->startyear+3 && $nation['gennum'] >= 10) {
echo "
<option value={$nation['nation']} style=color:{$nation['color']};background-color:red;>【 {$nation['name']} 】</option>";
} elseif($nation['scout'] == 1) {
+1 -4
View File
@@ -283,10 +283,7 @@ class DiplomaticMessage extends Message{
return $result;
}
list(
$year,
$month
) = $db->queryFirstList('SELECT year, month FROM game LIMIT 1');
list($year, $month) = $gameStor->getValuesAsArray(['year', 'month']);
$this->dest->generalID = $receiverID;
+1 -1
View File
@@ -40,7 +40,7 @@ class Personnel{
$this->year,
$this->month,
$this->killturn
) = $db->queryFirstList('SELECT startyear, year, month, killturn FROM game LIMIT 1');
) = $gameStor->getValuesAsArray(['startyear', 'year', 'month', 'killturn']);
}
+1 -2
View File
@@ -24,9 +24,8 @@ $connect=$db->get();
increaseRefresh("턴반복", 1);
$myActionCnt = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', $userID);
$conLimit = $db->queryFirstField('SELECT conlimit FROM game LIMIT 1');
$con = checkLimit($myActionCnt, $conLimit);
$con = checkLimit($myActionCnt);
if($con >= 2) {
header('location:commandlist.php');
exit();