feat: 나중을 위해 plock에 GAME, TOURNAMENT, ETC 사전 생성

This commit is contained in:
2022-04-25 01:02:23 +09:00
parent 889c524049
commit 1a5ba02b4a
5 changed files with 26 additions and 15 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ $gameStor = KVStorage::getStorage($db, 'game_env');
[$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>
<html>
+8 -7
View File
@@ -472,7 +472,8 @@ function getCommandTable(General $general)
return $result;
}
function getChiefCommandTable(General $general){
function getChiefCommandTable(General $general)
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$gameStor->turnOnCache();
@@ -1121,7 +1122,7 @@ function CheckOverhead()
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
@@ -1133,7 +1134,7 @@ function tryLock(): bool
$db->update('plock', [
'plock' => 1,
'locktime' => TimeUtil::now(true)
], 'plock=0');
], 'plock=0 AND type="GAME"');
return $db->affectedRows() > 0;
}
@@ -1144,7 +1145,7 @@ function unlock(): bool
$db = DB::db();
$db->update('plock', [
'plock' => 0
], true);
], 'type="GAME"');
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);
$itemClass = buildItemClass($itemCode);
if (!$itemClass) {
@@ -1590,7 +1591,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool
if ($itemClass->isBuyable()) {
continue;
}
$occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode]??0) + $cnt;
$occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode] ?? 0) + $cnt;
}
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);
$availableBuyUnique = $relMonthByInit >= GameConst::$minMonthToAllowInheritItem;
if($availableBuyUnique){
if ($availableBuyUnique) {
$general->setAuxVar('inheritRandomUnique', null);
}
}
+6 -6
View File
@@ -47,7 +47,7 @@ if ($me['newmsg'] == 1 || $me['newvote'] == 1) {
], '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']);
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-8 col-md-4"><?= info(3) ?></div>
<div class="s-border-t py-2 col col-6 col-md-4">
<?php if ($isTournamentActive) : ?>
↑<span style='color:cyan'><?=(['전력전', '통솔전', '일기토', '설전',])[$gameStor->tnmt_type] ?? '' ?> <?= getTournament($gameStor->tournament) ?> <?= getTournamentTime() ?></span>↑
<?php else : ?>
<span style='color:magenta'>현재 토너먼트 경기 없음</span>
<?php endif; ?>
<?php if ($isTournamentActive) : ?>
↑<span style='color:cyan'><?= (['전력전', '통솔전', '일기토', '설전',])[$gameStor->tnmt_type] ?? '' ?> <?= getTournament($gameStor->tournament) ?> <?= getTournamentTime() ?></span>↑
<?php else : ?>
<span style='color:magenta'>현재 토너먼트 경기 없음</span>
<?php endif; ?>
</div>
<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>
+10
View File
@@ -196,6 +196,16 @@ class ResetHelper{
'plock'=>1,
'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');
$serverCnt = $db->queryFirstField('SELECT count(*) FROM ng_games') + 1;
+1 -1
View File
@@ -278,7 +278,7 @@ class Session
$deadTime = $nextTurn + $general['killturn'] * $turnterm;
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 ($result !== null) {
$result = false;