forked from devsam/core
KVStorage로 game 테이블 대체 준비
This commit is contained in:
@@ -25,6 +25,7 @@ if($session->userGrade < 4) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select turntime,tnmt_time from game";
|
||||
|
||||
@@ -27,6 +27,7 @@ $minute2 = Util::getReq('minute2', 'int');
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
switch($btn) {
|
||||
|
||||
@@ -33,6 +33,7 @@ $startyear = Util::getReq('startyear', 'int', GameConst::$defaultStartYear);
|
||||
extractMissingPostToGlobals();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$admin = getAdmin();
|
||||
|
||||
@@ -26,6 +26,7 @@ if($session->userGrade < 5) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select conlimit from game limit 1";
|
||||
|
||||
@@ -22,6 +22,7 @@ if(!$generalID){
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$src = MessageTarget::buildQuick($session->generalID);
|
||||
|
||||
@@ -26,6 +26,7 @@ if($session->userGrade < 5) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select conlimit from game limit 1";
|
||||
|
||||
@@ -39,6 +39,7 @@ if($session->userGrade < 5) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$sel = [];
|
||||
|
||||
@@ -74,6 +74,7 @@ $dec = 0;
|
||||
$rice = 0;
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
increaseRefresh("시뮬", 2);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("명장일람", 2);
|
||||
|
||||
@@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("장수일람", 2);
|
||||
|
||||
@@ -13,6 +13,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("연감", 2);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("세력일람", 2);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("세력도", 2);
|
||||
|
||||
@@ -5,6 +5,7 @@ include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("갱신정보", 2);
|
||||
|
||||
@@ -7,6 +7,7 @@ include "func.php";
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("설문조사", 1);
|
||||
|
||||
@@ -14,6 +14,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("거래장", 2);
|
||||
|
||||
@@ -23,6 +23,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("감찰부", 2);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("베팅장", 1);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("사령부", 1);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("내무부", 1);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("중원정보", 1);
|
||||
|
||||
@@ -16,6 +16,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("암행부", 2);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("세력정보", 1);
|
||||
|
||||
@@ -25,6 +25,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("내정보", 1);
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("토너먼트", 1);
|
||||
|
||||
@@ -34,6 +34,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("입찰", 1);
|
||||
|
||||
@@ -38,6 +38,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
increaseRefresh("베팅", 1);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month,scenario from game limit 1";
|
||||
|
||||
@@ -21,6 +21,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select tournament,phase,tnmt_type,develcost from game limit 1";
|
||||
|
||||
@@ -8,6 +8,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select killturn from game limit 1";
|
||||
|
||||
@@ -17,6 +17,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select develcost,vote,votecomment from game limit 1";
|
||||
|
||||
@@ -67,6 +67,7 @@ myCommandList();
|
||||
|
||||
function myCommandList() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
|
||||
+25
-1
@@ -96,6 +96,7 @@ function checkLimit($con = null, $conlimit = null) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
if($con === null){
|
||||
$con = $db->queryFirstField('SELECT con FROM general WHERE `owner`=%i', Session::getUserID());
|
||||
@@ -258,6 +259,7 @@ function cityInfo() {
|
||||
|
||||
function myNationInfo() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -435,6 +437,7 @@ function commandGroup($typename, $type=0) {
|
||||
|
||||
function commandTable() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -675,6 +678,7 @@ function commandTable() {
|
||||
|
||||
function CoreCommandTable() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -777,6 +781,7 @@ function myInfo() {
|
||||
|
||||
function generalInfo($no) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select show_img_level from game limit 1";
|
||||
@@ -1084,6 +1089,7 @@ function generalInfo2($no) {
|
||||
|
||||
function adminMsg() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select msg from game limit 1";
|
||||
@@ -1100,6 +1106,7 @@ function getOnlineNum() {
|
||||
|
||||
function onlinegen() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$onlinegen = "";
|
||||
@@ -1119,6 +1126,7 @@ function onlinegen() {
|
||||
|
||||
function onlineNation() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select onlinenation from game limit 1";
|
||||
@@ -1268,6 +1276,7 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$db->update('game', [
|
||||
'refresh'=>$db->sqleval('refresh+%i', $cnt)
|
||||
], true);
|
||||
@@ -1338,6 +1347,7 @@ function increaseRefresh($type="", $cnt=1) {
|
||||
function updateTraffic() {
|
||||
$online = getOnlineNum();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$game = $db->queryFirstRow('SELECT year,month,refresh,maxonline,maxrefresh from game limit 1');
|
||||
|
||||
//최다갱신자
|
||||
@@ -1374,6 +1384,7 @@ function updateTraffic() {
|
||||
function CheckOverhead() {
|
||||
//서버정보
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$admin = $db->queryFirstRow('SELECT turnterm, conlimit from game LIMIT 1');
|
||||
|
||||
$con = Util::round(pow($admin['turnterm'], 0.6) * 3) * 10;
|
||||
@@ -1420,6 +1431,8 @@ function unlock() {
|
||||
}
|
||||
|
||||
function timeover() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$admin = DB::db()->queryFirstRow(
|
||||
'SELECT turnterm,TIMESTAMPDIFF(SECOND,turntime,now()) as diff from game limit 1'
|
||||
);
|
||||
@@ -1433,6 +1446,7 @@ function timeover() {
|
||||
|
||||
function checkDelay() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//서버정보
|
||||
@@ -1465,6 +1479,7 @@ function checkDelay() {
|
||||
|
||||
function updateOnline() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$nationname = ["재야"];
|
||||
|
||||
@@ -1514,6 +1529,7 @@ function updateOnline() {
|
||||
|
||||
function checkTurn() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$alllog = [];
|
||||
@@ -1743,6 +1759,7 @@ function checkTurn() {
|
||||
|
||||
function addAge() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//나이와 호봉 증가
|
||||
@@ -1787,7 +1804,7 @@ function addAge() {
|
||||
|
||||
function turnDate($curtime) {
|
||||
$db = DB::db();
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$admin = $db->queryFirstRow('SELECT startyear,starttime,turnterm,year,month from game limit 1');
|
||||
|
||||
$turn = $admin['starttime'];
|
||||
@@ -1816,6 +1833,7 @@ function turnDate($curtime) {
|
||||
|
||||
function triggerTournament() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select tournament,tnmt_trig from game limit 1";
|
||||
@@ -1913,6 +1931,7 @@ function PreprocessCommand($no) {
|
||||
|
||||
function updateTurntime($no) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$alllog = [];
|
||||
$log = [];
|
||||
@@ -2163,6 +2182,7 @@ function CheckHall($no) {
|
||||
|
||||
function uniqueItem($general, $log, $vote=0) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$alllog = [];
|
||||
$history = [];
|
||||
@@ -2374,6 +2394,7 @@ function checkExperience($general, $log) {
|
||||
|
||||
function getAdmin() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select * from game limit 1";
|
||||
@@ -2430,6 +2451,7 @@ function getNation($nation) {
|
||||
|
||||
function deleteNation($general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$history = [];
|
||||
@@ -2465,6 +2487,7 @@ function deleteNation($general) {
|
||||
|
||||
function nextRuler($general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
@@ -2672,6 +2695,7 @@ function CharCritical($rate, $personal) {
|
||||
|
||||
function SabotageInjury($city, $type=0) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$log = [];
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ function GetStuffName($stuff) {
|
||||
|
||||
function registerAuction() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month,turnterm from game limit 1";
|
||||
@@ -142,6 +143,7 @@ function registerAuction() {
|
||||
|
||||
function processAuction() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$trader = [];
|
||||
|
||||
@@ -457,6 +457,7 @@ function getCoreTurn($nation, $level) {
|
||||
function processCommand($no) {
|
||||
$session = Session::getInstance();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$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'";
|
||||
|
||||
@@ -341,6 +341,7 @@ function updateQuaterly() {
|
||||
// 벌점 감소와 건국제한-1 전턴제한-1 외교제한-1, 1달마다 실행, 병사 있는 장수의 군량 감소, 수입비율 조정
|
||||
function preUpdateMonthly() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//연감 월결산
|
||||
@@ -493,6 +494,7 @@ function preUpdateMonthly() {
|
||||
// 외교 로그처리, 외교 상태 처리
|
||||
function postUpdateMonthly() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month,scenario from game limit 1";
|
||||
@@ -647,6 +649,7 @@ group by A.nation
|
||||
|
||||
function checkWander() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
@@ -678,6 +681,7 @@ function checkWander() {
|
||||
|
||||
function checkMerge() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$mylog = [];
|
||||
@@ -800,6 +804,7 @@ function checkMerge() {
|
||||
|
||||
function checkSurrender() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
@@ -924,6 +929,7 @@ function checkSurrender() {
|
||||
|
||||
function updateNationState() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$history = array();
|
||||
@@ -1005,6 +1011,7 @@ function updateNationState() {
|
||||
|
||||
function checkStatistic() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month from game limit 1";
|
||||
@@ -1161,6 +1168,7 @@ function checkStatistic() {
|
||||
|
||||
function checkEmperior() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month,isUnited from game limit 1";
|
||||
|
||||
@@ -151,6 +151,7 @@ function pushWorldHistory(array $history, $year=null, $month=null) {
|
||||
return;
|
||||
}
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
if($year === null || $month === null){
|
||||
$game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1');
|
||||
$year = $game['year'];
|
||||
@@ -199,6 +200,7 @@ function pushGeneralPublicRecord(array $history, $year=null, $month=null) {
|
||||
return;
|
||||
}
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
if($year === null || $month === null){
|
||||
$game = $db->queryFirstRow('SELECT year, month FROM game LIMIT 1');
|
||||
$year = $game['year'];
|
||||
@@ -249,6 +251,7 @@ function LogHistory($isFirst=0) {
|
||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', LogHistory Start');
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$obj = $db->queryFirstRow('SELECT year, month, startyear FROM game limit 1');
|
||||
|
||||
//TODO: 새롭게 추가할 지도 값 받아오는 함수를 이용하여 재구성
|
||||
|
||||
@@ -106,6 +106,7 @@ function printCitiesBasedOnDistance(int $cityNo, int $maxDistance=1) {
|
||||
|
||||
function info($type=0) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month,turnterm,maxgeneral from game limit 1";
|
||||
|
||||
@@ -54,6 +54,7 @@ function getWorldMap($req){
|
||||
$userID = $session->userID;
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
$game = $db->queryFirstRow('select `startyear`, `year`, `month` from `game` where `no` = 1');
|
||||
$startYear = Util::toInt($game['startyear']);
|
||||
|
||||
@@ -165,6 +165,7 @@ function SetCrew($no, $personal, $gold, $leader, $genType, $tech, $region, $city
|
||||
|
||||
function processAI($no) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month,turnterm,scenario,gold_rate,rice_rate from game limit 1";
|
||||
@@ -1045,6 +1046,7 @@ function processAI($no) {
|
||||
|
||||
function Promotion($nation, $level) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$lv = getNationChiefLevel($level);
|
||||
|
||||
@@ -187,6 +187,7 @@ function CriticalScore($score, $type) {
|
||||
|
||||
function process_1(&$general, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -288,6 +289,7 @@ function process_1(&$general, $type) {
|
||||
|
||||
function process_3(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -388,6 +390,7 @@ function process_3(&$general) {
|
||||
|
||||
function process_4(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -479,6 +482,7 @@ function process_4(&$general) {
|
||||
|
||||
function process_5(&$general, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -580,6 +584,7 @@ function process_5(&$general, $type) {
|
||||
|
||||
function process_7(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -671,6 +676,7 @@ function process_7(&$general) {
|
||||
|
||||
function process_8(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -770,6 +776,7 @@ function process_8(&$general) {
|
||||
|
||||
function process_9(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -860,6 +867,7 @@ function process_9(&$general) {
|
||||
|
||||
function process_11(&$general, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1046,6 +1054,7 @@ function process_11(&$general, $type) {
|
||||
|
||||
function process_13(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1115,6 +1124,7 @@ function process_13(&$general) {
|
||||
|
||||
function process_14(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1177,6 +1187,7 @@ function process_14(&$general) {
|
||||
|
||||
function process_15(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1250,6 +1261,7 @@ function process_15(&$general) {
|
||||
|
||||
function process_16(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1343,6 +1355,7 @@ function process_16(&$general) {
|
||||
|
||||
function process_17(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1384,6 +1397,7 @@ function process_17(&$general) {
|
||||
|
||||
function process_21(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1445,6 +1459,7 @@ function process_21(&$general) {
|
||||
|
||||
function process_26(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1511,6 +1526,7 @@ function process_26(&$general) {
|
||||
|
||||
function process_28(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1577,6 +1593,7 @@ function process_28(&$general) {
|
||||
|
||||
function process_30(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1645,6 +1662,7 @@ function process_30(&$general) {
|
||||
|
||||
function process_31(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1786,6 +1804,7 @@ function process_31(&$general) {
|
||||
|
||||
function process_41(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1855,6 +1874,7 @@ function process_41(&$general) {
|
||||
|
||||
function process_42(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2076,6 +2096,7 @@ function process_42(&$general) {
|
||||
|
||||
function process_43(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$genlog = [];
|
||||
@@ -2167,6 +2188,7 @@ function process_43(&$general) {
|
||||
|
||||
function process_44(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2258,6 +2280,7 @@ function process_44(&$general) {
|
||||
|
||||
function process_48(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2366,6 +2389,7 @@ function process_48(&$general) {
|
||||
|
||||
function process_49(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2503,6 +2527,7 @@ function process_49(&$general) {
|
||||
|
||||
function process_50(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2530,6 +2555,7 @@ function process_50(&$general) {
|
||||
|
||||
function process_99(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo;
|
||||
|
||||
function process_23(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$genlog = [];
|
||||
@@ -105,6 +106,7 @@ function process_23(&$general) {
|
||||
|
||||
function process_24(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$genlog = [];
|
||||
@@ -233,6 +235,7 @@ function process_24(&$general) {
|
||||
|
||||
function process_27(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -310,6 +313,7 @@ function process_27(&$general) {
|
||||
function process_51(&$general) {
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$date = substr($general['turntime'],11,5);
|
||||
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
|
||||
|
||||
@@ -393,6 +397,7 @@ function process_51(&$general) {
|
||||
|
||||
function process_52(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -505,6 +510,7 @@ function process_52(&$general) {
|
||||
|
||||
function process_53(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$date = substr($general['turntime'],11,5);
|
||||
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
|
||||
|
||||
@@ -589,6 +595,7 @@ function process_53(&$general) {
|
||||
|
||||
function process_61(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$date = substr($general['turntime'],11,5);
|
||||
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
|
||||
|
||||
@@ -689,6 +696,7 @@ function process_61(&$general) {
|
||||
|
||||
function process_62(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -809,6 +817,7 @@ function process_62(&$general) {
|
||||
|
||||
function process_63(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$date = substr($general['turntime'],11,5);
|
||||
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
|
||||
|
||||
@@ -892,6 +901,7 @@ function process_63(&$general) {
|
||||
|
||||
function process_64(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$date = substr($general['turntime'],11,5);
|
||||
list($year, $month, $turnterm) = $db->queryFirstList('SELECT year,month,turnterm FROM game LIMIT 1');
|
||||
|
||||
@@ -975,6 +985,7 @@ function process_64(&$general) {
|
||||
|
||||
function process_65(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1069,6 +1080,7 @@ function process_65(&$general) {
|
||||
|
||||
function process_66(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1159,6 +1171,7 @@ function process_66(&$general) {
|
||||
|
||||
function process_67(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1250,6 +1263,7 @@ function process_67(&$general) {
|
||||
|
||||
function process_68(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1353,6 +1367,7 @@ function process_68(&$general) {
|
||||
|
||||
function process_71(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1459,6 +1474,7 @@ function process_71(&$general) {
|
||||
|
||||
function process_72(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1574,6 +1590,7 @@ function process_72(&$general) {
|
||||
|
||||
function process_73(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1705,6 +1722,7 @@ function process_73(&$general) {
|
||||
|
||||
function process_74(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1849,6 +1867,7 @@ function process_74(&$general) {
|
||||
|
||||
function process_75(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -1975,6 +1994,7 @@ function process_75(&$general) {
|
||||
|
||||
function process_76(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2194,6 +2214,7 @@ function process_76(&$general) {
|
||||
|
||||
function process_77(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2322,6 +2343,7 @@ function process_77(&$general) {
|
||||
|
||||
function process_78(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -2447,6 +2469,7 @@ function process_78(&$general) {
|
||||
|
||||
function process_81(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace sammo;
|
||||
|
||||
function process_22(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -60,6 +61,7 @@ function process_22(&$general) {
|
||||
|
||||
function process_25(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -183,6 +185,7 @@ function process_25(&$general) {
|
||||
|
||||
function process_29(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -437,6 +440,7 @@ function process_29(&$general) {
|
||||
|
||||
function process_45(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -549,6 +553,7 @@ function process_45(&$general) {
|
||||
|
||||
function process_46(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -637,6 +642,7 @@ function process_46(&$general) {
|
||||
|
||||
function process_47(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -702,6 +708,7 @@ function process_47(&$general) {
|
||||
|
||||
function process_54(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -768,6 +775,7 @@ function process_54(&$general) {
|
||||
|
||||
function process_55(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -857,6 +865,7 @@ function process_55(&$general) {
|
||||
|
||||
function process_56(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -910,6 +919,7 @@ function process_56(&$general) {
|
||||
|
||||
function process_57(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace sammo;
|
||||
|
||||
function process_32(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -129,6 +130,7 @@ function process_32(&$general) {
|
||||
|
||||
function process_33(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -281,6 +283,7 @@ function process_33(&$general) {
|
||||
|
||||
function process_34(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
@@ -407,6 +410,7 @@ function process_34(&$general) {
|
||||
|
||||
function process_35(&$general) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$log = [];
|
||||
|
||||
@@ -66,6 +66,8 @@ function CoreTurnTable() {
|
||||
|
||||
|
||||
function allButton() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$npcmode = DB::db()->queryFirstField("select npcmode from game limit 1");
|
||||
if($npcmode == 1) {
|
||||
$site = "a_npcList.php";
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace sammo;
|
||||
//1월마다 실행
|
||||
function processSpring() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//인구 증가
|
||||
@@ -369,6 +370,7 @@ function processFall() {
|
||||
|
||||
function processRiceIncome() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month,rice_rate from game limit 1";
|
||||
@@ -570,6 +572,7 @@ function tradeRate() {
|
||||
|
||||
function disaster() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select startyear,year,month from game limit 1";
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace sammo;
|
||||
|
||||
function processTournament() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$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";
|
||||
@@ -110,6 +111,7 @@ function processTournament() {
|
||||
|
||||
function getTournamentTerm() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select tnmt_auto from game limit 1";
|
||||
@@ -131,6 +133,7 @@ function getTournamentTerm() {
|
||||
|
||||
function getTournamentTime() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select tournament,tnmt_time from game limit 1";
|
||||
@@ -231,6 +234,7 @@ function printFighting($tournament, $phase) {
|
||||
|
||||
function startTournament($auto, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
eraseTnmtFightLogAll();
|
||||
@@ -269,6 +273,7 @@ function startTournament($auto, $type) {
|
||||
|
||||
function fillLowGenAll() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$general = [];
|
||||
@@ -376,6 +381,7 @@ function getTwo($tournament, $phase) {
|
||||
|
||||
function qualify($tnmt_type, $tnmt, $phase) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$cand = getTwo($tnmt, $phase);
|
||||
@@ -416,6 +422,7 @@ function qualifyAll($tnmt_type, $tnmt, $phase) {
|
||||
|
||||
function selection($tnmt_type, $tnmt, $phase) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//시드1 배정
|
||||
@@ -465,6 +472,7 @@ function selectionAll($tnmt_type, $tnmt, $phase) {
|
||||
|
||||
function finallySingle($tnmt_type, $tnmt, $phase) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$cand = getTwo($tnmt, $phase);
|
||||
@@ -505,6 +513,7 @@ function finallyAll($tnmt_type, $tnmt, $phase) {
|
||||
|
||||
function final16set() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
//1조1-5조2, 2조1-6조2, 3조1-7조2, 4조1-8조2, 5조1-1조2, 6조1-2조2, 7조1-3조2, 8조1-4조2
|
||||
@@ -529,6 +538,7 @@ function final16set() {
|
||||
|
||||
function finalFight($tnmt_type, $tnmt, $phase, $type) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
switch($type) {
|
||||
@@ -561,6 +571,7 @@ function finalFight($tnmt_type, $tnmt, $phase, $type) {
|
||||
|
||||
function setGift($tnmt_type, $tnmt, $phase) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select year,month,develcost from game limit 1";
|
||||
@@ -715,6 +726,7 @@ function setGift($tnmt_type, $tnmt, $phase) {
|
||||
|
||||
function setRefund() {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select develcost from game limit 1";
|
||||
|
||||
@@ -10,6 +10,7 @@ $userID = Session::getUserID();
|
||||
increaseRefresh("메인", 1);
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
if (!$userID) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ include 'lib.php';
|
||||
include "func.php";
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$reserved = $db->queryFirstRow('SELECT `date`, options FROM reserved_open ORDER BY `date` ASC LIMIT 1');
|
||||
|
||||
if(!$reserved){
|
||||
|
||||
@@ -21,6 +21,7 @@ $oNow = new \DateTimeImmutable();
|
||||
$now = $oNow->format('Y-m-d H:i:s');
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
$oldGeneral = $db->queryFirstField('SELECT `no` FROM general WHERE `owner`=%i', $userID);
|
||||
if($oldGeneral !== null){
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@ $reserve_open = Util::getReq('reserve_open');
|
||||
if($reserve_open){
|
||||
$reserve_open = new \DateTime($reserve_open);
|
||||
$db = DB::db();
|
||||
|
||||
if (!$db->queryFirstField("SHOW TABLES LIKE 'game'")) {
|
||||
|
||||
if (!$db->queryFirstField("SHOW TABLES LIKE 'storage'")) {
|
||||
$clearResult = ResetHelper::clearDB();
|
||||
if(!$clearResult['result']){
|
||||
Json::die($clearResult);
|
||||
|
||||
@@ -16,6 +16,7 @@ if(!$pick){
|
||||
$session = Session::requireLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$rootDB = RootDB::db();
|
||||
|
||||
$oNow = new \DateTimeImmutable();
|
||||
|
||||
@@ -17,6 +17,7 @@ if(!class_exists('\\sammo\\DB')){
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
if(file_exists(__dir__.'/.htaccess')){
|
||||
$reserved = $db->queryFirstRow(
|
||||
|
||||
@@ -23,6 +23,7 @@ if (!$member) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
?>
|
||||
|
||||
@@ -66,6 +66,7 @@ if (!$member) {
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
########## 동일 정보 존재여부 확인. ##########
|
||||
|
||||
$admin = $db->queryFirstRow('SELECT year,month,maxgeneral,scenario,show_img_level,turnterm,genius,npcmode from game limit 1');
|
||||
|
||||
@@ -6,6 +6,7 @@ function processWar($general, $city) {
|
||||
'@phan-var array<string,int|string|null> $general';
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
$templates = new \League\Plates\Engine('templates');
|
||||
@@ -1634,6 +1635,7 @@ function getRate($game, $type, $dtype) {
|
||||
|
||||
function addConflict($city, $nationID, $mykillnum) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
$nationlist = [];
|
||||
$killnum = [0];
|
||||
|
||||
@@ -193,6 +193,7 @@ function command_99($turn) {
|
||||
|
||||
function command_11($turn, $command) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -401,6 +402,7 @@ function calc(cost, formnum) {
|
||||
|
||||
function command_12($turn, $command) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -961,6 +963,7 @@ function command_24($turn, $command) {
|
||||
|
||||
function command_25($turn, $command) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
@@ -1528,6 +1531,7 @@ function command_44($turn, $command) {
|
||||
|
||||
function command_46($turn, $command) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
starter("건국");
|
||||
|
||||
@@ -225,6 +225,8 @@ class DiplomaticMessage extends Message{
|
||||
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
$general = $db->queryFirstRow(
|
||||
'SELECT `name`, `level` FROM general WHERE `no`=%i AND nation=%i',
|
||||
$receiverID,
|
||||
|
||||
@@ -24,6 +24,7 @@ class Diplomacy{
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$srcNation = $db->queryFirstRow(
|
||||
'SELECT nation, `name`, `power`, capital, gold, rice, surlimit, color, `level` FROM nation WHERE nation=%i',
|
||||
$srcNationID
|
||||
|
||||
@@ -21,6 +21,7 @@ class Personnel{
|
||||
|
||||
public function __construct(int $nationID, int $senderID){
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$nation = $db->queryFirstRow(
|
||||
'SELECT nation, `name`, `level`, capital, scout FROM nation WHERE nation=%i',
|
||||
$nationID
|
||||
|
||||
@@ -89,7 +89,7 @@ class ResetHelper{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
(KVStorage::getStorage($db, 'game'))->resetValues();
|
||||
|
||||
return [
|
||||
'result'=>true
|
||||
|
||||
@@ -7,6 +7,7 @@ include "func.php";
|
||||
$session = Session::requireLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
list($npcmode, $maxgeneral) = $db->queryFirstList('SELECT npcmode,maxgeneral FROM game LIMIT 1');
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ $session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
$connect=$db->get();
|
||||
|
||||
increaseRefresh("턴반복", 1);
|
||||
|
||||
+65
-15
@@ -2,16 +2,28 @@
|
||||
namespace sammo;
|
||||
|
||||
class KVStorage{
|
||||
private $db = null;
|
||||
private $db;
|
||||
private $tableName;
|
||||
private $storNamespace;
|
||||
private $cacheData = null;
|
||||
|
||||
public function __construct(\MeekroDB $db, string $storNamespace, bool $cacheMode=false){
|
||||
static private $storageList = [];
|
||||
|
||||
static public function getStorage(\MeekroDB $db, string $storNamespace, string $tableName='storage'):self{
|
||||
$obj_id = spl_object_hash($db);
|
||||
$fullKey = $obj_id.','.$storNamespace.','.$tableName;
|
||||
if(key_exists($fullKey, static::$storageList)){
|
||||
return static::$storageList[$fullKey];
|
||||
}
|
||||
$obj = new static($db, $storNamespace, $tableName);
|
||||
static::$storageList[$fullKey] = $obj;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function __construct(\MeekroDB $db, string $storNamespace, string $tableName='storage'){
|
||||
$this->db = $db;
|
||||
$this->storNamespace = $storNamespace;
|
||||
if($cacheMode){
|
||||
$this->cacheData = [];
|
||||
}
|
||||
$this->tableName = $tableName;
|
||||
}
|
||||
|
||||
public function __get($key) {
|
||||
@@ -26,6 +38,13 @@ class KVStorage{
|
||||
$this->deleteValue($key);
|
||||
}
|
||||
|
||||
public function turnOnCache(): self{
|
||||
if($this->cacheData === null){
|
||||
$this->cacheData = [];
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function resetCache(bool $disableCache=true):self{
|
||||
if($disableCache){
|
||||
$this->cacheData = null;
|
||||
@@ -66,17 +85,36 @@ class KVStorage{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheAll():self{
|
||||
public function cacheAll(bool $invalidateAll=true):self{
|
||||
if(!$invalidateAll && $this->cacheData !== null && count($this->cacheData)>0){
|
||||
return $this;
|
||||
}
|
||||
$this->cacheData = $this->getDBAll();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function cacheValues(array $keys):self{
|
||||
public function cacheValues(array $keys, bool $invalidateAll=false):self{
|
||||
if($this->cacheData === null){
|
||||
$this->cacheData = [];
|
||||
}
|
||||
$values = $this->getDBValues($keys);
|
||||
foreach($keys as $key){
|
||||
|
||||
if($invalidateAll){
|
||||
$notExists = $keys;
|
||||
}
|
||||
else{
|
||||
$notExists = [];
|
||||
foreach($keys as $key){
|
||||
if(!key_exists($key, $this->cacheData)){
|
||||
$notExists[] = $key;
|
||||
}
|
||||
}
|
||||
if(!$notExists){
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
$values = $this->getDBValues($notExists);
|
||||
foreach($notExists as $key){
|
||||
if(key_exists($key, $values)){
|
||||
$this->cacheData[$key] = $values[$key];
|
||||
}
|
||||
@@ -99,6 +137,15 @@ class KVStorage{
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getValuesAsArray(array $keys, bool $onlyCache=false): array{
|
||||
$dictResult = $this->getValues($keys, $onlyCache);
|
||||
$result = [];
|
||||
foreach($keys as $key){
|
||||
$result[] = $dictResult[$key]??null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getValues(array $keys, bool $onlyCache=false): array{
|
||||
if ($this->cacheData === null) {
|
||||
return $this->getDBValues($keys);
|
||||
@@ -165,7 +212,8 @@ class KVStorage{
|
||||
private function getDBAll(): array{
|
||||
$result = [];
|
||||
foreach($this->db->queryAllLists(
|
||||
'SELECT `key`, `value` FROM storage WHERE `namespace`=%s',
|
||||
'SELECT `key`, `value` FROM %b WHERE `namespace`=%s',
|
||||
$this->tableName,
|
||||
$this->storNamespace
|
||||
) as list($key, $value))
|
||||
{
|
||||
@@ -177,7 +225,8 @@ class KVStorage{
|
||||
private function getDBValues(array $keys): array{
|
||||
$result = [];
|
||||
foreach($this->db->queryAllLists(
|
||||
'SELECT `key`, `value` FROM storage WHERE `namespace`=%s AND `key` IN %ls',
|
||||
'SELECT `key`, `value` FROM %b WHERE `namespace`=%s AND `key` IN %ls',
|
||||
$this->tableName,
|
||||
$this->storNamespace,
|
||||
$keys
|
||||
) as list($key, $value))
|
||||
@@ -194,7 +243,8 @@ class KVStorage{
|
||||
|
||||
private function getDBValue($key){
|
||||
$value = $this->db->queryFirstField(
|
||||
'SELECT `value` FROM storage WHERE `namespace`=%s AND `key`=%s',
|
||||
'SELECT `value` FROM %b WHERE `namespace`=%s AND `key`=%s',
|
||||
$this->tableName,
|
||||
$this->storNamespace,
|
||||
$key
|
||||
);
|
||||
@@ -208,7 +258,7 @@ class KVStorage{
|
||||
if($value === null){
|
||||
return $this->deleteDBValue($key);
|
||||
}
|
||||
$this->db->insertUpdate('storage', [
|
||||
$this->db->insertUpdate($this->tableName, [
|
||||
'namespace'=>$this->storNamespace,
|
||||
'key'=>$key,
|
||||
'value'=>Json::encode($value)
|
||||
@@ -217,7 +267,7 @@ class KVStorage{
|
||||
}
|
||||
|
||||
private function deleteDBValue($key):self{
|
||||
$this->db->delete('storage', [
|
||||
$this->db->delete($this->tableName, [
|
||||
'namespace'=>$this->storNamespace,
|
||||
'key'=>$key
|
||||
]);
|
||||
@@ -225,7 +275,7 @@ class KVStorage{
|
||||
}
|
||||
|
||||
private function resetDBNamespace():self{
|
||||
$this->db->delete('storage', [
|
||||
$this->db->delete($this->tableName, [
|
||||
'namespace'=>$this->storNamespace
|
||||
]);
|
||||
return $this;
|
||||
|
||||
@@ -230,6 +230,7 @@ class Session
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game');
|
||||
|
||||
$general = $db->queryFirstRow(
|
||||
'SELECT `no`, `name`, `killturn`, `turntime` from general where `owner` = %i',
|
||||
|
||||
Reference in New Issue
Block a user