game 테이블을 모두 gameStor로 변환

This commit is contained in:
2018-05-20 03:43:02 +09:00
parent af9df325f0
commit 0516007130
28 changed files with 200 additions and 427 deletions
+4 -4
View File
@@ -59,13 +59,13 @@ ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
###################
# KV storage
###################
CREATE TABLE if not exists `storage` (
CREATE TABLE `storage` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`namespace` VARCHAR(40) NOT NULL,
`key` VARCHAR(40) NOT NULL,
`value` VARCHAR(100) NOT NULL,
`value` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `key` (`namespace`, `key`)
)
DEFAULT CHARSET=utf8mb4
ENGINE=MyISAM;
COLLATE='utf8mb4_general_ci'
ENGINE=MyISAM
+3 -3
View File
@@ -145,8 +145,8 @@ if ($session->userGrade >= 5) {
";
}
if ($admin['votecomment'] != "") {
$comment = explode("|", $admin['votecomment']);
if ($admin['votecomment']) {
$comment = $admin['votecomment'];
$commentCount = count($comment);
} else {
$commentCount = 0;
@@ -159,7 +159,7 @@ echo "
</tr>
";
for ($i=0; $i < $commentCount; $i++) {
$cmt = explode(":", $comment[$i]);
$cmt = $comment[$i];
$cmt[2] = Tag2Code($cmt[2]);
$j = $i+1;
echo "
+5 -3
View File
@@ -393,9 +393,11 @@ for ($i=0; $i < 16; $i++) {
echo"
</tr>";
$query = "select tournament,bet0,bet1,bet2,bet3,bet4,bet5,bet6,bet7,bet8,bet9,bet10,bet11,bet12,bet13,bet14,bet15,bet0+bet1+bet2+bet3+bet4+bet5+bet6+bet7+bet8+bet9+bet10+bet11+bet12+bet13+bet14+bet15 as bet from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
$betting = MYDB_fetch_array($result);
$betting = $gameStor->getValues(['tournament','bet0','bet1','bet2','bet3','bet4','bet5','bet6','bet7','bet8','bet9','bet10','bet11','bet12','bet13','bet14','bet15']);
$betting['bet'] = 0;
for($i=0;$i<16;$i+=1){
$betting['bet'] += $betting['bet'.$i];
}
$bet = [];
for ($i=0; $i < 16; $i++) {
if($betting['bet'] == 0){
+3 -5
View File
@@ -210,13 +210,11 @@ if($btn == "추방") {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
$query = "select year,month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
pushGeneralHistory($general, "<C>●</>{$admin['year']}{$admin['month']}월:<D>{$nation['name']}</>에서 추방됨");
list($year, $month) = $gameStor->getValuesAsArray(['year','month']);
pushGeneralHistory($general, "<C>●</>{$year}{$month}월:<D>{$nation['name']}</>에서 추방됨");
pushGenLog($general, $log);
pushGeneralPublicRecord($alllog, $admin['year'], $admin['month']);
pushGeneralPublicRecord($alllog, $year, $month);
}
header('location:b_myBossInfo.php');
die();
+8 -9
View File
@@ -181,8 +181,8 @@ if($btn == "자동개최설정") {
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$grpCount = MYDB_num_rows($result);
if($grpCount >= 8) {
$query = "update game set tournament=2, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament=2;
$gameStor->phase=0;
}
} elseif($btn == "쪼렙전부투입" || $btn == "일반전부투입" || $btn == "굇수전부투입" || $btn == "랜덤전부투입") {
@@ -238,8 +238,8 @@ if($btn == "자동개최설정") {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
$query = "update game set tournament=2, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = 2;
$gameStor->phase = 0;
} elseif($btn == "무명전부투입") {
fillLowGenAll();
} elseif($btn == "예선") {
@@ -258,8 +258,9 @@ if($btn == "자동개최설정") {
final16set();
} elseif($btn == "베팅마감") {
$dt = date("Y-m-d H:i:s", time() + 60);
$query = "update game set tournament='7',phase='0',tnmt_time='$dt'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament=7;
$gameStor->phase=0;
$gameStor->tnmt_time = $dt;
} elseif($btn == "16강") {
finalFight($admin['tnmt_type'], $admin['tournament'], $admin['phase'], 16);
} elseif($btn == "8강") {
@@ -273,9 +274,7 @@ if($btn == "자동개최설정") {
} elseif($btn == "회수") {
setRefund();
} elseif($btn == "메시지") {
$msg = addslashes(SQ2DQ($msg));
$query = "update game set tnmt_msg='$msg'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tnmt_msg = $msg;
}
header('location:b_tournament.php');
+17 -23
View File
@@ -20,9 +20,7 @@ $db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select develcost,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', 'cost', 'vote', 'votecomment']);
$query = "select no,vote,name,nation,horse,weap,book,item,npc from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -45,9 +43,10 @@ else if($btn == "댓글" && $comment != "") {
$nation = getNationStaticInfo($me['nation']);
if($admin['votecomment'] != "") { $admin['votecomment'] .= "|"; }
$admin['votecomment'] .= "{$nation['name']}:{$me['name']}:{$comment}";
if(!$admin['votecomment']){
$admin['votecomment'] = [];
}
$admin['votecomment'][] = [$nation['name'],$me['name'],$comment];
$gameStor->votecomment = $admin['votecomment'];
}
@@ -59,22 +58,20 @@ if($session->userGrade < 5){
if($btn == "수정") {
if($title != "") {
$vote = explode("|", $admin['vote']);
$vote[0] = addslashes(SQ2DQ($title));
$admin['vote'] = implode("|", $vote);
$query = "update game set vote='{$admin['vote']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$vote = $admin['vote'];
$vote[0] = $title;
$gameStor->vote = $admin['vote'];
}
} elseif($btn == "추가") {
if($str != "") {
$str = addslashes(SQ2DQ($str));
$admin['vote'] .= "|{$str}";
$query = "update game set vote='{$admin['vote']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
//TODO:vote
$admin['vote'][] = $str;
$gameStor->vote=$admin['vote'];
}
} elseif($btn == "리셋") {
$query = "update game set voteopen=1,vote='',votecomment=''";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->voteopen=1;
$gameStor->vote='';
$gameStor->votecomment='';
$query = "update general set vote='0'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -82,14 +79,11 @@ if($btn == "수정") {
$query = "update general set newvote='1' where vote=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} elseif($btn == "숨김") {
$query = "update game set voteopen=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->voteopen = 0;
} elseif($btn == "전체통계만") {
$query = "update game set voteopen=1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->voteopen = 1;
} elseif($btn == "전부") {
$query = "update game set voteopen=2";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->voteopen = 2;
}
header('location:a_vote.php');
+25 -53
View File
@@ -261,9 +261,7 @@ function myNationInfo() {
$connect=$db->get();
$userID = Session::getUserID();
$query = "select startyear,year 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']);
$query = "select no,nation from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -439,9 +437,7 @@ function commandTable() {
$connect=$db->get();
$userID = Session::getUserID();
$query = "select startyear,year,develcost,scenario 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', 'scenario']);
$query = "select no,npc,troop,city,nation,level,crew,makelimit,special from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -680,9 +676,7 @@ function CoreCommandTable() {
$connect=$db->get();
$userID = Session::getUserID();
$query = "select develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$develcost = $gameStor->develcost;
$query = "select no,nation,city,level from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -729,8 +723,8 @@ function CoreCommandTable() {
commandGroup("", 1);
commandGroup("====== 특 수 ======");
addCommand("초토화", 65, $valid);
addCommand("천도/3턴(금쌀{$admin['develcost']}0)", 66, $valid);
$cost = $admin['develcost'] * 500 + 60000; // 7만~13만
addCommand("천도/3턴(금쌀{$develcost}0)", 66, $valid);
$cost = $develcost * 500 + 60000; // 7만~13만
addCommand("증축/6턴(금쌀{$cost})", 67, $valid);
addCommand("감축/6턴", 68, $valid);
commandGroup("", 1);
@@ -782,9 +776,7 @@ function generalInfo($no) {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select show_img_level from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$show_img_level = $gameStor->show_img_level;
$query = "select block,no,name,picture,imgsvr,injury,nation,city,troop,leader,leader2,power,power2,intel,intel2,explevel,experience,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,killturn,age,personal,special,specage,special2,specage2,mode,con,connect from general where no='$no'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -880,7 +872,7 @@ function generalInfo($no) {
else { $general['mode'] = "<font color=red>수비 안함</font>"; }
$weapImage = ServConfig::$gameImagePath."/weap{$general['crewtype']}.png";
if($admin['show_img_level'] < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; };
if($show_img_level < 2) { $weapImage = ServConfig::$sharedIconPath."/default.jpg"; };
$imageTemp = GetImageURL($general['imgsvr']);
echo "<table width=498 class='tb_layout bg2'>
<tr>
@@ -1411,13 +1403,13 @@ function unlock() {
function timeover() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$admin = DB::db()->queryFirstRow(
'SELECT turnterm,TIMESTAMPDIFF(SECOND,turntime,now()) as diff from game limit 1'
);
$t = min($admin['turnterm'], 5);
list($turnterm, $turntime) = $gameStor->getValuesAsArray(['turnterm', 'turntime']);
$diff = (new \DateTime())->getTimestamp() - (new \DateTime($turntime))->getTimestamp();
$term = $admin['diff'];
$t = min($turnterm, 5);
$term = $diff;
if($term >= $t || $term < 0) { return 1; }
else { return 0; }
}
@@ -1495,8 +1487,7 @@ function updateOnline() {
$onnationstr .= "{$nationname[$key]}】, ";
if($key == 0) {
$query = "update game set onlinegen='$onnation[0]'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->onlinegen = $onnation[0];
} else {
$query = "update nation set onlinegen='$onnation[$key]' where nation='$key'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1505,8 +1496,8 @@ function updateOnline() {
}
//접속중인 국가
$query = "update game set online='$onlinenum',onlinenation='$onnationstr'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->online = $onlinenume;
$gameStor->onlinenation = $onnationstr;
}
function checkTurn() {
@@ -1546,12 +1537,8 @@ function checkTurn() {
//if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', 진입');
//천통시에는 동결
$query = "select turntime from game where isUnited=2";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$down = MYDB_num_rows($result);
if($down > 0) {
$query = "update plock set plock=1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
if($gameStor->isUnited == 2) {
$db->update('plock', ['plock'=>1], true);
return;
}
$gameStor->cacheAll();
@@ -1743,9 +1730,7 @@ function addAge() {
$query = "update general set age=age+1,belong=belong+1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$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(['startyear', 'year', 'month']);
if($admin['year'] >= $admin['startyear']+3) {
$query = "select no,name,nation,leader,power,intel from general where specage<=age and special='0'";
@@ -1782,7 +1767,7 @@ function addAge() {
function turnDate($curtime) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$admin = $db->queryFirstRow('SELECT startyear,starttime,turnterm,year,month from game limit 1');
$admin = $gameStor->getValues(['startyear', 'starttime', 'turnterm', 'year', 'month']);
$turn = $admin['starttime'];
$curturn = cutTurn($curtime, $admin['turnterm']);
@@ -1809,11 +1794,8 @@ function turnDate($curtime) {
function triggerTournament() {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select tournament,tnmt_trig from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['tournament', 'tnmt_trig']);
//현재 토너먼트 없고, 자동개시 걸려있을때, 40%확률
if($admin['tournament'] == 0 && $admin['tnmt_trig'] > 0 && rand() % 100 < 40) {
@@ -1911,9 +1893,7 @@ function updateTurntime($no) {
$alllog = [];
$log = [];
$query = "select year,month,isUnited,turnterm 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', 'isUnited', 'turnterm']);
$query = "select no,name,name2,nation,troop,age,turntime,killturn,level,deadyear,npc,npc_org,affinity,npcid from general where no='$no'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2167,9 +2147,7 @@ function uniqueItem($general, $log, $vote=0) {
if($general['npc'] >= 2) { return $log; }
if($general['weap'] > 6 || $general['book'] > 6 || $general['horse'] > 6 || $general['item'] > 6) { return $log; }
$query = "select year,month,scenario from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$game_env = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['year', 'month', 'scenario']);
$query = "select count(*) as cnt from general where npc<2";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2426,9 +2404,7 @@ function deleteNation($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']);
$nation = getNationStaticInfo($general['nation']);
@@ -2459,9 +2435,7 @@ function nextRuler($general) {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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,name from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2668,9 +2642,7 @@ function SabotageInjury($city, $type=0) {
$connect=$db->get();
$log = [];
$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 no,name,nation from general where city='$city'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+2 -6
View File
@@ -21,9 +21,7 @@ function registerAuction() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select startyear,year,month,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', 'turnterm']);
$unit = 60 * $admin['turnterm'];
@@ -155,9 +153,7 @@ function processAuction() {
$date = date("Y-m-d H:i:s");
$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 * from auction where expire<='$date'";
$result2 = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+7 -9
View File
@@ -463,23 +463,21 @@ function processCommand($no) {
$query = "select npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40 from general where no='$no'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$general = MYDB_fetch_array($result);
$query = "select month,killturn from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
list($month, $killturn) = $gameStor->getValuesAsArray(['month', 'killturn']);
$log = [];
// 블럭자는 미실행. 삭턴 감소
if($general['block'] == 2) {
$date = substr($general['turntime'],11,5);
$log[] = "<C>●</>{$admin['month']}월:현재 멀티, 또는 비매너로 인한<R>블럭</> 대상자입니다. <1>$date</>";
$log[] = "<C>●</>{$month}월:현재 멀티, 또는 비매너로 인한<R>블럭</> 대상자입니다. <1>$date</>";
pushGenLog($general, $log);
$query = "update general set recturn='',resturn='BLOCK_2',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} elseif($general['block'] == 3) {
$date = substr($general['turntime'],11,5);
$log[] = "<C>●</>{$admin['month']}월:현재 악성유저로 분류되어 <R>블럭, 발언권 무효</> 대상자입니다. <1>$date</>";
$log[] = "<C>●</>{$month}월:현재 악성유저로 분류되어 <R>블럭, 발언권 무효</> 대상자입니다. <1>$date</>";
pushGenLog($general, $log);
$query = "update general set recturn='',resturn='BLOCK_3',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
@@ -531,14 +529,14 @@ function processCommand($no) {
$command = DecodeCommand($general['turn0']);
//삭턴 처리
if($general['npc'] >= 2 || $general['killturn'] > $admin['killturn']) {
if($general['npc'] >= 2 || $general['killturn'] > $killturn) {
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} elseif($command[0] == 0) {
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
} else {
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn='{$admin['killturn']}' where no='{$general['no']}'";
$query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn='{$killturn}' where no='{$general['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
//FIXME: 운영자 같이 사망하면 안되는 인물에 대한 처리가 필요
@@ -552,7 +550,7 @@ function processCommand($no) {
switch($command[0]) {
case 0: //휴식
$date = substr($general['turntime'],11,5);
$log[] = "<C>●</>{$admin['month']}월:아무것도 실행하지 않았습니다. <1>$date</>";
$log[] = "<C>●</>{$month}월:아무것도 실행하지 않았습니다. <1>$date</>";
pushGenLog($general, $log);
break;
case 1: process_1($general, 1); break; //농업
+12 -26
View File
@@ -350,9 +350,7 @@ function preUpdateMonthly() {
if($result == false) { return false; }
$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(['startyear', 'year', 'month']);
//배신 횟수 최대 10회 미만
$query = "update general set betray=9 where betray>9";
@@ -432,8 +430,10 @@ function preUpdateMonthly() {
$ratio = 100;
// 20 ~ 140원
$develcost = ($admin['year'] - $admin['startyear'] + 10) * 2;
$query = "update game set gold_rate='$ratio',rice_rate='$ratio',city_rate='$rate',develcost='$develcost'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->gold_rate = $ratio;
$gameStor->rice_rate = $ratio;
$gameStor->city_rate = $rate;
$gameStor->develcost = $develcost;
//매달 사망자 수입 결산
processDeadIncome($ratio);
@@ -497,9 +497,7 @@ function postUpdateMonthly() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select startyear,year,month,scenario 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', 'scenario']);
$history = [];
@@ -652,9 +650,7 @@ function checkWander() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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']);
$needRefresh = false;
@@ -688,9 +684,7 @@ function checkMerge() {
$youlog = [];
$history = [];
$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 * from diplomacy where state='3' and term='0'";
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -807,9 +801,7 @@ function checkSurrender() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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 * from diplomacy where state='5' and term='0'";
$dipresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -933,9 +925,7 @@ function updateNationState() {
$connect=$db->get();
$history = array();
$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,name,level from nation";
$nationresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1014,9 +1004,7 @@ function checkStatistic() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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']);
$nationHists = [];
$specialHists = [];
@@ -1171,9 +1159,7 @@ function checkEmperior() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select year,month,isUnited 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', 'isUnited']);
$query = "select nation,name from nation where level>0";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+1 -1
View File
@@ -248,7 +248,7 @@ function LogHistory($isFirst=0) {
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$obj = $db->queryFirstRow('SELECT year, month, startyear FROM game limit 1');
$obj = $gameStor->getValues(['startyear', 'year', 'month']);
//TODO: 새롭게 추가할 지도 값 받아오는 함수를 이용하여 재구성
$map = getWorldMap([
+1 -3
View File
@@ -109,9 +109,7 @@ function info($type=0) {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select year,month,turnterm,maxgeneral 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', 'turnterm', 'maxgeneral']);
$termtype = "{$admin['turnterm']}분 턴";
+2 -6
View File
@@ -168,9 +168,7 @@ function processAI($no) {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select startyear,year,month,turnterm,scenario,gold_rate,rice_rate from game limit 1";
$result = MYDB_query($query, $connect) or Error("processAI00 ".MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['startyear','year','month','turnterm','scenario','gold_rate','rice_rate']);
// 초반 여부
if($admin['startyear']+2 > $admin['year'] || ($admin['startyear']+2 == $admin['year'] && $admin['month'] < 5)) {
$isStart = 1;
@@ -1051,9 +1049,7 @@ function Promotion($nation, $level) {
$lv = getNationChiefLevel($level);
$query = "select scenario,killturn from game limit 1";
$result = MYDB_query($query, $connect) or Error("processAI00 ".MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getValues(['scenario', 'killturn']);
//우선 수뇌 해제 (승상 뺴고)
$query = "update general set level=1 where level<11 and level>4 and nation='$nation'";
+27 -77
View File
@@ -195,9 +195,7 @@ function process_1(&$general, $type) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
if($type == 1) { $dtype = "농지 개간"; $atype = ""; $btype = ""; $stype = "agri"; }
elseif($type == 2) { $dtype = "상업 투자"; $atype = ""; $btype = ""; $stype = "comm"; }
@@ -297,9 +295,7 @@ function process_3(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
$dtype = "기술 연구";
@@ -398,9 +394,7 @@ function process_4(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
$query = "select * from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -490,9 +484,7 @@ function process_5(&$general, $type) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
if($type == 1) { $dtype = "수비 강화"; $stype = "def"; }
elseif($type == 2) { $dtype = "성벽 보수"; $stype = "wall"; }
@@ -592,9 +584,7 @@ function process_7(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
$query = "select * from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -684,9 +674,7 @@ function process_8(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear', 'year', 'month', 'develcost']);
$dtype = "치안"; $stype = "secu";
@@ -784,9 +772,7 @@ function process_9(&$general) {
$history = [];
$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),"");
@@ -878,9 +864,7 @@ function process_11(&$general, $type) {
if($type == 1) { $defaultatmos = GameConst::$defaultAtmosLow; $defaulttrain = GameConst::$defaultTrainLow; }
else { $defaultatmos = GameConst::$defaultAtmosHigh; $defaulttrain = GameConst::$defaultTrainHigh; }
$query = "select year,month,startyear 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']);
$query = "select level,tech from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1062,9 +1046,7 @@ function process_13(&$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']);
$nation = getNationStaticInfo($general['nation']);
@@ -1132,9 +1114,7 @@ function process_14(&$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']);
$nation = getNationStaticInfo($general['nation']);
@@ -1195,9 +1175,7 @@ function process_15(&$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,tech from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1269,9 +1247,7 @@ function process_16(&$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(['startyear', 'year', 'month']);
$query = "select nation,war,sabotagelimit,tech from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1363,9 +1339,7 @@ function process_17(&$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']);
if($general['crew'] == 0) {
$log[] = "<C>●</>{$admin['month']}월:병사가 없습니다. 소집해제 실패. <1>$date</>";
@@ -1407,7 +1381,7 @@ function process_21(&$general) {
$db = DB::db();
$admin = $db->queryFirstRow('SELECT year, month, develcost FROM game limit 1');
$admin = $gameStor->getValues(['year', 'month', 'develcost']);
$city = CityConst::byID($general['city']);
$command = DecodeCommand($general['turn0']);
$destination = $command[1];
@@ -1469,9 +1443,7 @@ function process_26(&$general) {
$troop = getTroop($general['troop']);
$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,name,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1536,9 +1508,7 @@ function process_28(&$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']);
$nation = getNationStaticInfo($general['nation']);
@@ -1601,9 +1571,7 @@ function process_30(&$general) {
$history = [];
$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 path from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -1671,9 +1639,7 @@ function process_31(&$general) {
$date = substr($general['turntime'],11,5);
$msg = [];
$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'], 2, false);
$command = DecodeCommand($general['turn0']);
@@ -1812,9 +1778,7 @@ function process_41(&$general) {
$history = [];
$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']);
$ratio = rand() % 100;
$exp = $general['crew'] / 400;
@@ -1882,9 +1846,7 @@ function process_42(&$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']);
$type = rand() % 27 + 1;
$exp = 30;
@@ -2105,9 +2067,7 @@ function process_43(&$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']);
$command = DecodeCommand($general['turn0']);
$what = $command[3];
@@ -2196,9 +2156,7 @@ function process_44(&$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 name,gold,rice from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -2288,9 +2246,7 @@ function process_48(&$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']);
$city = getCity($general['city']);
@@ -2398,9 +2354,7 @@ function process_49(&$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']);
$nation = getNationStaticInfo($general['nation']);
@@ -2535,11 +2489,9 @@ function process_50(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select month from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$month = $gameStor->month;
$log[] = "<C>●</>{$admin['month']}월:건강 회복을 위해 요양합니다. <1>$date</>";
$log[] = "<C>●</>{$month}월:건강 회복을 위해 요양합니다. <1>$date</>";
// 경험치 상승 // 공헌도, 명성 상승
$exp = 10;
$ded = 7;
@@ -2563,9 +2515,7 @@ function process_99(&$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']);
$log[] = "<C>●</>{$admin['month']}월:아직 구현되지 않았습니다. <1>$date</>";
+1 -2
View File
@@ -2153,8 +2153,7 @@ function process_76(&$general) {
$npcid++;
}
//npccount
$query = "update game set npccount={$npcid}";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->npccount=$npcid;
//국가 기술력 그대로
$query = "select no from general where nation='{$general['nation']}'";
+11 -32
View File
@@ -11,9 +11,7 @@ function process_22(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,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(['startyear','year','month','develcost']);
$query = "select nation,supply from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -69,9 +67,7 @@ function process_25(&$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(['startyear', 'year', 'month']);
$query = "select nation from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -193,9 +189,7 @@ function process_29(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select startyear,year,month,develcost,npccount,turnterm,scenario 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','scenario']);
$query = "select nation,name,level,gennum,scout from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -403,8 +397,7 @@ function process_29(&$general) {
$npcid++;
//npccount
$query = "update game set npccount={$npcid}";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->npccount=$npcid;
//국가 기술력 그대로
$query = "select no from general where nation='{$general['nation']}'";
@@ -448,9 +441,7 @@ function process_45(&$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(['startyear', 'year', 'month']);
$query = "select name,chemi from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -561,9 +552,7 @@ function process_46(&$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(['startyear', 'year', 'month']);
$query = "select * from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -650,9 +639,7 @@ function process_47(&$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(['startyear', 'year', 'month']);
$nation = getNationStaticInfo($general['nation']);
@@ -717,9 +704,7 @@ function process_54(&$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']);
$command = DecodeCommand($general['turn0']);
$who = $command[1];
@@ -784,9 +769,7 @@ function process_55(&$general) {
$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(['startyear', 'year', 'month']);
$query = "select name from city where city='{$general['city']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -873,9 +856,7 @@ function process_56(&$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']);
$nation = getNationStaticInfo($general['nation']);
@@ -928,9 +909,7 @@ function process_57(&$general) {
$history = [];
$date = substr($general['turntime'],11,5);
$query = "select year,month,killturn 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', 'killturn']);
$query = "select nation,name from nation where nation='{$general['nation']}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+4 -12
View File
@@ -38,9 +38,7 @@ function processSpring() {
$query = "update nation set gold=gold*0.95 where gold>100000";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$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']);
pushWorldHistory(["<R>★</>{$admin['year']}{$admin['month']}월: <S>모두들 즐거운 게임 하고 계신가요? ^^ <Y>삼국일보</> 애독해 주시고, <M>훼접</>은 삼가주세요~</>"], $admin['year'], $admin['month']);
}
@@ -49,9 +47,7 @@ function processGoldIncome() {
$db = DB::db();
$connect=$db->get();
$query = "select year,month,gold_rate 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','gold_rate']);
$adminLog = [];
$query = "select name,nation,gold,rate_tmp,bill,type from nation";
@@ -373,9 +369,7 @@ function processRiceIncome() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select year,month,rice_rate 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','rice_rate']);
$adminLog = [];
$query = "select name,nation,rice,rate_tmp,bill,type from nation";
@@ -575,9 +569,7 @@ function disaster() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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(['startyear', 'year', 'month']);
//재난표시 초기화
$query = "update city set state=0 where state<=10";
+53 -70
View File
@@ -7,9 +7,10 @@ function processTournament() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select tournament,phase,tnmt_type,tnmt_auto,tnmt_time,now() as now,TIMESTAMPDIFF(SECOND,tnmt_time,now()) as offset 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', 'tnmt_auto', 'tnmt_time']);
$now = new \DateTime();
$admin['now'] = $now->format('Y-m-d H:i:s');
$admin['offset'] = $now->getTimestamp() - (new \DateTime($admin['tnmt_time']))->getTimestamp();
//수동일땐 무시
if($admin['tnmt_auto'] == 0) { return; }
@@ -84,8 +85,9 @@ function processTournament() {
if($betTerm > 3600) { $betTerm = 3600; }
//처리 초 더한 날짜
$dt = date("Y-m-d H:i:s", strtotime($admin['tnmt_time']) + $unit * $i + $betTerm);
$query = "update game set tournament='$tnmt',phase='$phase',tnmt_time='$dt'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = $tnmt;
$gameStor->phase = $phase;
$gameStor->tnmt_time = $dt;
return;
}
@@ -96,16 +98,18 @@ function processTournament() {
//지정시간대 넘어가면 중단 20~24시
if($hr < 20) {
$dt = substr($dt, 0, 11)."20:00:00";
$query = "update game set tournament='$tnmt',phase='$phase',tnmt_time='$dt'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = $tnmt;
$gameStor->phase = $phase;
$gameStor->tnmt_time = $dt;
return;
}
}
}
$second = $unit * $iter;
$query = "update game set tournament='$tnmt',phase='$phase',tnmt_time=DATE_ADD(tnmt_time, INTERVAL {$second} SECOND)";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = $tnmt;
$gameStor->phase = $phase;
$gameStor->tnmt_time = (new \DateTimeImmutable($gameStor->tnmt_time))->add(new \DateInterval("PT{$second}S"))->format('Y-m-d H:i:s');
}
}
@@ -114,11 +118,9 @@ function getTournamentTerm() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select tnmt_auto from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$tnmt_auto = $gameStor->tnmt_auto;
switch($admin['tnmt_auto']) {
switch($tnmt_auto) {
case 0: $str = ''; break;
case 1: $str = "경기당 12분"; break;
case 2: $str = "경기당 7분"; break;
@@ -136,12 +138,8 @@ function getTournamentTime() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select tournament,tnmt_time from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$tnmt = $admin['tournament'];
$dt = substr($admin['tnmt_time'], 11, 5);
list($tnmt, $tnmt_time) = $gameStor->getValuesAsArray(['tournament', 'tnmt_time']);
$dt = substr($tnmt_time, 11, 5);
switch($tnmt) {
case 1: $tnmt = "개막시간 {$dt}"; break;
case 2: $tnmt = "다음경기 {$dt}"; break;
@@ -250,12 +248,17 @@ function startTournament($auto, $type) {
default:$unit = 60; break;
}
$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 = "update game set tnmt_auto='$auto',tnmt_time=DATE_ADD(now(), INTERVAL {$unit} MINUTE),tournament=1,tnmt_type='$type',phase=0,bet0=0,bet1=0,bet2=0,bet3=0,bet4=0,bet5=0,bet6=0,bet7=0,bet8=0,bet9=0,bet10=0,bet11=0,bet12=0,bet13=0,bet14=0,bet15=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tnmt_auto = $auto;
$gameStor->tnmt_time = (new \DateTimeImmutable())->add(new \DateInterval("PT{$unit}M"))->format('Y-m-d H:i:s');
$gameStor->tournament = 1;
$gameStor->tnmt_type = $type;
$gameStor->phase = 0;
$gameStor->bet = 0;
for($i=0;$i<16;$i+=1){
$gameStor->setValue("bet{$i}", 0);
}
$query = "update general set tournament=0,bet0=0,bet1=0,bet2=0,bet3=0,bet4=0,bet5=0,bet6=0,bet7=0,bet8=0,bet9=0,bet10=0,bet11=0,bet12=0,bet13=0,bet14=0,bet15=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "truncate tournament";
@@ -279,9 +282,7 @@ function fillLowGenAll() {
$general = [];
$grpCount = [];
$query = "select develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$develcost = $gameStor->develcost;
$general['no'] = 0;
$general['name'] = "무명장수";
@@ -298,7 +299,7 @@ function fillLowGenAll() {
}
//자동신청하고, 돈 있고, 아직 참가 안한 장수
$query = "select no,npc,name,leader,power,intel,explevel from general where tnmt='1' and tournament='0' and gold>='{$admin['develcost']}' order by rand() limit 0,64";
$query = "select no,npc,name,leader,power,intel,explevel from general where tnmt='1' and tournament='0' and gold>='{$develcost}' order by rand() limit 0,64";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$genCount = MYDB_num_rows($result);
@@ -313,7 +314,7 @@ function fillLowGenAll() {
if($genCount > 0) {
$genCount--;
$gen = MYDB_fetch_array($result);
$query = "update general set gold=gold-'{$admin['develcost']}',tournament='1' where no='{$gen['no']}'";
$query = "update general set gold=gold-'{$develcost}',tournament='1' where no='{$gen['no']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "insert into tournament (no, npc, name, ldr, pwr, itl, lvl, grp, grp_no) values ('{$gen['no']}', '{$gen['npc']}', '{$gen['name']}', '{$gen['leader']}', '{$gen['power']}', '{$gen['intel']}', '{$gen['explevel']}', '$i', '$grpCount[$i]')";
@@ -332,8 +333,8 @@ function fillLowGenAll() {
}
}
$query = "update game set tournament=2, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = 2;
$gameStor->phase = 0;
}
//0 경기없음
@@ -391,11 +392,10 @@ function qualify($tnmt_type, $tnmt, $phase) {
fight($tnmt_type, $tnmt, $phase, $i, $cand[0], $cand[1], 0);
}
if($phase < 55) {
$query = "update game set phase=phase+1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->phase+=1;
} else {
$query = "update game set tournament=3, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->phase=0;
$gameStor->tournament=3;
for($i=0; $i < 8; $i++) {
$query = "select grp,grp_no,win+draw+lose as game,win,draw,lose,gl,win*3+draw as gd from tournament where grp='$i' order by gd desc, gl desc, seq limit 0,4";
@@ -451,18 +451,14 @@ function selection($tnmt_type, $tnmt, $phase) {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
if($phase < 31) {
$query = "update game set phase=phase+1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->phase+=1;
} else {
$query = "update game set tournament=4, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournamemt = 4;
$gameStor->phase=0;
}
}
function selectionAll($tnmt_type, $tnmt, $phase) {
$db = DB::db();
$connect=$db->get();
$start = $phase;
$end = $phase - ($phase % 8) + 8;
for($i=$start; $i < $end; $i++) {
@@ -482,11 +478,10 @@ function finallySingle($tnmt_type, $tnmt, $phase) {
fight($tnmt_type, $tnmt, $phase, $i, $cand[0], $cand[1], 0);
}
if($phase < 5) {
$query = "update game set phase=phase+1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->phase+=1;
} else {
$query = "update game set tournament=5, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament=5;
$gameStor->phase=0;
for($i=10; $i < 18; $i++) {
$query = "select grp,grp_no,win+draw+lose as game,win,draw,lose,gl,win*3+draw as gd from tournament where grp='$i' order by gd desc, gl desc, seq limit 0,2";
@@ -501,9 +496,6 @@ function finallySingle($tnmt_type, $tnmt, $phase) {
}
function finallyAll($tnmt_type, $tnmt, $phase) {
$db = DB::db();
$connect=$db->get();
$start = $phase;
$end = $phase - ($phase % 2) + 2;
for($i=$start; $i < $end; $i++) {
@@ -532,8 +524,8 @@ function final16set() {
$query = "update tournament set prmt=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$query = "update game set tournament=6, phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament=6;
$gameStor->phase=0;
}
function finalFight($tnmt_type, $tnmt, $phase, $type) {
@@ -551,8 +543,7 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) {
$grp = $phase + $offset;
fight($tnmt_type, $tnmt, $phase, $grp, 0, 1, 1);
$query = "update game set phase=phase+1";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->phase+=1;
$query = "select * from tournament where grp='$grp' and win>0 and (grp_no=0 or grp_no=1)";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
@@ -564,8 +555,8 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) {
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
if($phase >= $turn) {
$query = "update game set tournament='$next', phase=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tournament = $next;
$gameStor->phase = 0;
}
}
@@ -574,9 +565,7 @@ function setGift($tnmt_type, $tnmt, $phase) {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$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']);
$genNo = [];
$genName = [];
@@ -667,8 +656,7 @@ function setGift($tnmt_type, $tnmt, $phase) {
$general2 = MYDB_fetch_array($result);
//자동진행 끝
$query = "update game set tnmt_auto=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tnmt_auto = 0;
//장수열전 기록
$query = "select no from general where no={$general['no']}";
@@ -704,9 +692,9 @@ function setGift($tnmt_type, $tnmt, $phase) {
$general = MYDB_fetch_array($result);
$no = ($general['grp'] - 20) * 2 + $general['grp_no'];
$query = "select bet{$no},bet0+bet1+bet2+bet3+bet4+bet5+bet6+bet7+bet8+bet9+bet10+bet11+bet12+bet13+bet14+bet15 as bet from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
$admin = $gameStor->getDBValues(['bet0','bet1','bet2','bet3','bet4','bet5','bet6','bet7','bet8','bet9','bet10','bet11','bet12','bet13','bet14','bet15']);
$admin['bet'] = array_sum($admin);
$bet = @round($admin['bet'] / $admin["bet{$no}"], 2);
//당첨칸에 베팅한 사람들만
@@ -729,12 +717,8 @@ function setRefund() {
$gameStor = KVStorage::getStorage($db, 'game_env');
$connect=$db->get();
$query = "select develcost from game limit 1";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$admin = MYDB_fetch_array($result);
//16강자 명성 돈
$cost = $admin['develcost'];
$cost = $gameStor->develcost;
$query = "select no from tournament where grp<10";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$count = MYDB_num_rows($result);
@@ -745,8 +729,7 @@ function setRefund() {
}
//자동진행 끝
$query = "update game set tnmt_auto=0";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$gameStor->tnmt_auto = 0;
//베팅금 환수
$query = "update general set gold=gold+bet0+bet1+bet2+bet3+bet4+bet5+bet6+bet7+bet8+bet9+bet10+bet11+bet12+bet13+bet14+bet15";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
+1 -1
View File
@@ -35,7 +35,7 @@ list(
$maxgeneral,
$turnterm,
$npcmode
) = $db->queryFirstList('SELECT maxgeneral,turnterm,npcmode from game limit 1');
) = $gameStor->getValuesAsArray(['maxgeneral', 'turnterm', 'npcmode']);
if(!$npcmode){
Json::die([
+1 -1
View File
@@ -55,7 +55,7 @@ list(
$month,
$maxgeneral,
$npcmode
) = $db->queryFirstList('SELECT year,month,maxgeneral,npcmode from game limit 1');
) = $gameStor->getValuesAsArray(['year', 'month', 'maxgeneral', 'npcmode']);
if(!$npcmode){
Json::die([
+1 -1
View File
@@ -1638,7 +1638,7 @@ function addConflict($city, $nationID, $mykillnum) {
$nationlist = [];
$killnum = [0];
list($year, $month) = $db->queryFirstList('SELECT year, month FROM game LIMIT 1');
list($year, $month) = $gameStor->getValuesAsArray(['year', 'month']);
$conflict = Json::decode($city['conflict']);
+1 -1
View File
@@ -1526,7 +1526,7 @@ function command_46($turn, $command) {
starter("건국");
$maxnation = $db->queryFirstField('SELECT maxnation FROM game LIMIT 1');
$maxnation = $gameStor->maxnation;
$colorUsed = [];
+1 -1
View File
@@ -59,7 +59,7 @@ class Diplomacy{
$this->startYear,
$this->year,
$this->month
) = $db->queryFirstList('SELECT startyear, year, month FROM game LIMIT 1');
) = $gameStor->getValuesAsArray(['startyear', 'year', 'month']);
}
+1 -1
View File
@@ -300,7 +300,7 @@ class Scenario{
/*
env로 사용된 것들,
게임 변수 : year, month
game 테이블 변수 : startyear, year, month, genius, turnterm, show_img_level, extended_general, fiction, npcmode
gameStor 변수 : startyear, year, month, genius, turnterm, show_img_level, extended_general, fiction, npcmode
install 변수 : npcmode, show_img_level, extended_general, scenario, fiction
event변수 : currentEventID
+1 -1
View File
@@ -9,7 +9,7 @@ $userID = Session::getUserID();
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
list($npcmode, $maxgeneral) = $db->queryFirstList('SELECT npcmode,maxgeneral FROM game LIMIT 1');
list($npcmode, $maxgeneral) = $gameStor->getValuesAsArray(['npcmode', 'maxgeneral']);
if(!$npcmode) {
header('location:..');
-3
View File
@@ -13,9 +13,6 @@ DROP TABLE IF EXISTS troop;
#
DROP TABLE IF EXISTS plock;
#
DROP TABLE IF EXISTS game;
#
DROP TABLE IF EXISTS message;
+4 -69
View File
@@ -341,71 +341,6 @@ create table plock (
PRIMARY KEY (no)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
##########################################################################
##
##########################################################################
CREATE TABLE `game` (
`no` ENUM('1') NOT NULL DEFAULT '1',
`startyear` INT(3) NOT NULL,
`year` INT(3) NOT NULL,
`month` INT(3) NOT NULL,
`refresh` INT(9) NULL DEFAULT '0',
`maxonline` INT(9) NULL DEFAULT '1',
`maxrefresh` INT(9) NULL DEFAULT '1',
`conlimit` INT(9) NULL DEFAULT '5',
`develcost` INT(4) NULL DEFAULT '20',
`online` INT(9) NULL DEFAULT '0',
`onlinenation` VARCHAR(256) NULL DEFAULT '',
`onlinegen` VARCHAR(1024) NULL DEFAULT '',
`msg` TEXT NULL DEFAULT '',
`maxgeneral` INT(3) NULL DEFAULT '100',
`genius` INT(2) NULL DEFAULT '3',
`maxnation` INT(3) NULL DEFAULT '50',
`gold_rate` INT(3) NULL DEFAULT '100',
`rice_rate` INT(3) NULL DEFAULT '100',
`city_rate` INT(3) NULL DEFAULT '50',
`turnterm` INT(3) NULL DEFAULT '60',
`killturn` INT(6) NULL DEFAULT '80',
`turntime` DATETIME NULL DEFAULT NULL,
`starttime` DATETIME NULL DEFAULT NULL,
`isUnited` INT(1) NULL DEFAULT '0',
`scenario` INT(4) NULL DEFAULT '0',
`scenario_text` VARCHAR(80) NULL DEFAULT '0',
`show_img_level` INT(2) NULL DEFAULT '0',
`extended_general` INT(1) NULL DEFAULT '0',
`fiction` INT(1) NULL DEFAULT '0',
`npcmode` INT(1) NULL DEFAULT '0',
`tnmt_auto` INT(2) NULL DEFAULT '0',
`tnmt_time` DATETIME NULL DEFAULT '2100-01-01 00:00:00',
`tournament` INT(2) NULL DEFAULT '0',
`phase` INT(2) NULL DEFAULT '0',
`tnmt_type` INT(2) NULL DEFAULT '0',
`tnmt_msg` CHAR(255) NULL DEFAULT '',
`tnmt_trig` INT(2) NULL DEFAULT '0',
`voteopen` INT(1) NULL DEFAULT '1',
`vote` TEXT NULL DEFAULT '',
`votecomment` TEXT NULL DEFAULT '',
`npccount` INT(4) NULL DEFAULT '0',
`bet0` INT(8) NULL DEFAULT '0',
`bet1` INT(8) NULL DEFAULT '0',
`bet2` INT(8) NULL DEFAULT '0',
`bet3` INT(8) NULL DEFAULT '0',
`bet4` INT(8) NULL DEFAULT '0',
`bet5` INT(8) NULL DEFAULT '0',
`bet6` INT(8) NULL DEFAULT '0',
`bet7` INT(8) NULL DEFAULT '0',
`bet8` INT(8) NULL DEFAULT '0',
`bet9` INT(8) NULL DEFAULT '0',
`bet10` INT(8) NULL DEFAULT '0',
`bet11` INT(8) NULL DEFAULT '0',
`bet12` INT(8) NULL DEFAULT '0',
`bet13` INT(8) NULL DEFAULT '0',
`bet14` INT(8) NULL DEFAULT '0',
`bet15` INT(8) NULL DEFAULT '0',
PRIMARY KEY (`no`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
###########################################################################
##
###########################################################################
@@ -676,13 +611,13 @@ ENGINE=MyISAM;
###################
# KV storage
###################
CREATE TABLE if not exists `storage` (
CREATE TABLE `storage` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`namespace` VARCHAR(40) NOT NULL,
`key` VARCHAR(40) NOT NULL,
`value` VARCHAR(100) NOT NULL,
`value` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `key` (`namespace`, `key`)
)
DEFAULT CHARSET=utf8mb4
ENGINE=MyISAM;
COLLATE='utf8mb4_general_ci'
ENGINE=MyISAM
+3 -4
View File
@@ -242,10 +242,9 @@ class Session
}
return $this;
}
$gameInstance = $db->queryFirstRow('SELECT turnterm, isUnited from game limit 1');
$turnterm = $gameInstance['turnterm'];
$isUnited = $gameInstance['isUnited'] != 0;
$turnterm = $gameStor->turnterm;
$isUnited = $gameStor->isUnited != 0;
$generalID = $general['no'];
$generalName = $general['name'];