feat: 나중을 위해 plock에 GAME, TOURNAMENT, ETC 사전 생성
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
|
|||||||
|
|
||||||
[$turntime, $tnmt_time] = $gameStor->getValuesAsArray(['turntime','tnmt_time']);
|
[$turntime, $tnmt_time] = $gameStor->getValuesAsArray(['turntime','tnmt_time']);
|
||||||
|
|
||||||
$plock = $db->queryFirstField('SELECT plock FROM plock');
|
$plock = $db->queryFirstField('SELECT plock FROM plock WHERE `type` ="GAME"');
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|||||||
+8
-7
@@ -472,7 +472,8 @@ function getCommandTable(General $general)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChiefCommandTable(General $general){
|
function getChiefCommandTable(General $general)
|
||||||
|
{
|
||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||||
$gameStor->turnOnCache();
|
$gameStor->turnOnCache();
|
||||||
@@ -1121,7 +1122,7 @@ function CheckOverhead()
|
|||||||
|
|
||||||
function isLock()
|
function isLock()
|
||||||
{
|
{
|
||||||
return DB::db()->queryFirstField("SELECT plock from plock limit 1") != 0;
|
return DB::db()->queryFirstField("SELECT plock from plock WHERE `type`='GAME'") != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryLock(): bool
|
function tryLock(): bool
|
||||||
@@ -1133,7 +1134,7 @@ function tryLock(): bool
|
|||||||
$db->update('plock', [
|
$db->update('plock', [
|
||||||
'plock' => 1,
|
'plock' => 1,
|
||||||
'locktime' => TimeUtil::now(true)
|
'locktime' => TimeUtil::now(true)
|
||||||
], 'plock=0');
|
], 'plock=0 AND type="GAME"');
|
||||||
|
|
||||||
return $db->affectedRows() > 0;
|
return $db->affectedRows() > 0;
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1145,7 @@ function unlock(): bool
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
$db->update('plock', [
|
$db->update('plock', [
|
||||||
'plock' => 0
|
'plock' => 0
|
||||||
], true);
|
], 'type="GAME"');
|
||||||
|
|
||||||
return $db->affectedRows() > 0;
|
return $db->affectedRows() > 0;
|
||||||
}
|
}
|
||||||
@@ -1581,7 +1582,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($db->queryAllLists('SELECT namespace, count(*) as cnt FROM `storage` WHERE namespace LIKE "ut_%" GROUP BY namespace') as [$uniqueNS, $cnt]){
|
foreach ($db->queryAllLists('SELECT namespace, count(*) as cnt FROM `storage` WHERE namespace LIKE "ut_%" GROUP BY namespace') as [$uniqueNS, $cnt]) {
|
||||||
$itemCode = substr($uniqueNS, 3);
|
$itemCode = substr($uniqueNS, 3);
|
||||||
$itemClass = buildItemClass($itemCode);
|
$itemClass = buildItemClass($itemCode);
|
||||||
if (!$itemClass) {
|
if (!$itemClass) {
|
||||||
@@ -1590,7 +1591,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
|
|||||||
if ($itemClass->isBuyable()) {
|
if ($itemClass->isBuyable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode]??0) + $cnt;
|
$occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode] ?? 0) + $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (GameConst::$allItems as $itemType => $itemCategories) {
|
foreach (GameConst::$allItems as $itemType => $itemCategories) {
|
||||||
@@ -1632,7 +1633,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
|
|||||||
$relMonthByInit = Util::joinYearMonth($year, $month) - Util::joinYearMonth($initYear, $initMonth);
|
$relMonthByInit = Util::joinYearMonth($year, $month) - Util::joinYearMonth($initYear, $initMonth);
|
||||||
$availableBuyUnique = $relMonthByInit >= GameConst::$minMonthToAllowInheritItem;
|
$availableBuyUnique = $relMonthByInit >= GameConst::$minMonthToAllowInheritItem;
|
||||||
|
|
||||||
if($availableBuyUnique){
|
if ($availableBuyUnique) {
|
||||||
$general->setAuxVar('inheritRandomUnique', null);
|
$general->setAuxVar('inheritRandomUnique', null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -47,7 +47,7 @@ if ($me['newmsg'] == 1 || $me['newvote'] == 1) {
|
|||||||
], 'owner=%i', $userID);
|
], 'owner=%i', $userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
$plock = boolval($db->queryFirstField('SELECT plock FROM plock LIMIT 1'));
|
$plock = boolval($db->queryFirstField('SELECT plock FROM plock WHERE `type`="GAME" LIMIT 1'));
|
||||||
|
|
||||||
$con = checkLimit($me['con']);
|
$con = checkLimit($me['con']);
|
||||||
if ($con >= 2) {
|
if ($con >= 2) {
|
||||||
@@ -189,11 +189,11 @@ if (!$otherTextInfo) {
|
|||||||
<div class="s-border-t col py-2 col-4 col-md-2">턴당 갱신횟수 : <?= $gameStor->conlimit ?>회</div>
|
<div class="s-border-t col py-2 col-4 col-md-2">턴당 갱신횟수 : <?= $gameStor->conlimit ?>회</div>
|
||||||
<div class="s-border-t col py-2 col-8 col-md-4"><?= info(3) ?></div>
|
<div class="s-border-t col py-2 col-8 col-md-4"><?= info(3) ?></div>
|
||||||
<div class="s-border-t py-2 col col-6 col-md-4">
|
<div class="s-border-t py-2 col col-6 col-md-4">
|
||||||
<?php if ($isTournamentActive) : ?>
|
<?php if ($isTournamentActive) : ?>
|
||||||
↑<span style='color:cyan'><?=(['전력전', '통솔전', '일기토', '설전',])[$gameStor->tnmt_type] ?? '' ?> <?= getTournament($gameStor->tournament) ?> <?= getTournamentTime() ?></span>↑
|
↑<span style='color:cyan'><?= (['전력전', '통솔전', '일기토', '설전',])[$gameStor->tnmt_type] ?? '' ?> <?= getTournament($gameStor->tournament) ?> <?= getTournamentTime() ?></span>↑
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<span style='color:magenta'>현재 토너먼트 경기 없음</span>
|
<span style='color:magenta'>현재 토너먼트 경기 없음</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="s-border-t py-2 col col-6 col-md-2">
|
<div class="s-border-t py-2 col col-6 col-md-2">
|
||||||
<div style="display:inline-block;"><?= $plock ? ("<span style='color:magenta;'>동작 시각: " . substr($gameStor->turntime, 5, 14) . "</span>") : ("<span style='color:cyan;'>동작 시각: " . substr($gameStor->turntime, 5, 14) . "</span>") ?></div>
|
<div style="display:inline-block;"><?= $plock ? ("<span style='color:magenta;'>동작 시각: " . substr($gameStor->turntime, 5, 14) . "</span>") : ("<span style='color:cyan;'>동작 시각: " . substr($gameStor->turntime, 5, 14) . "</span>") ?></div>
|
||||||
|
|||||||
@@ -196,6 +196,16 @@ class ResetHelper{
|
|||||||
'plock'=>1,
|
'plock'=>1,
|
||||||
'locktime'=>TimeUtil::now(true)
|
'locktime'=>TimeUtil::now(true)
|
||||||
]);
|
]);
|
||||||
|
$db->insert('plock', [
|
||||||
|
'type'=>'TOURNAMENT',
|
||||||
|
'plock'=>1,
|
||||||
|
'locktime'=>TimeUtil::now(true)
|
||||||
|
]);
|
||||||
|
$db->insert('plock', [
|
||||||
|
'type'=>'ETC',
|
||||||
|
'plock'=>1,
|
||||||
|
'locktime'=>TimeUtil::now(true)
|
||||||
|
]);
|
||||||
|
|
||||||
$prevWinner = $db->queryFirstField('SELECT l12name FROM emperior ORDER BY `no` DESC LIMIT 1');
|
$prevWinner = $db->queryFirstField('SELECT l12name FROM emperior ORDER BY `no` DESC LIMIT 1');
|
||||||
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games') + 1;
|
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games') + 1;
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ class Session
|
|||||||
|
|
||||||
$deadTime = $nextTurn + $general['killturn'] * $turnterm;
|
$deadTime = $nextTurn + $general['killturn'] * $turnterm;
|
||||||
if ($deadTime < $now && !$isUnited) {
|
if ($deadTime < $now && !$isUnited) {
|
||||||
$locked = $db->queryFirstField('SELECT plock FROM plock LIMIT 1');
|
$locked = $db->queryFirstField('SELECT plock FROM plock WHERE `type` = "GAME" LIMIT 1');
|
||||||
if (!$locked) {
|
if (!$locked) {
|
||||||
if ($result !== null) {
|
if ($result !== null) {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user