diff --git a/.phan/config.php b/.phan/config.php index 56676933..0d09cd0c 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -84,7 +84,6 @@ return [ 'hwe/j_adjust_icon.php', 'hwe/j_autoreset.php', 'hwe/j_basic_info.php', - 'hwe/j_betting.php', 'hwe/j_board_article_add.php', 'hwe/j_board_comment_add.php', 'hwe/j_board_get_articles.php', diff --git a/hwe/_119.php b/hwe/_119.php index 513301d1..206a45dc 100644 --- a/hwe/_119.php +++ b/hwe/_119.php @@ -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"'); ?> diff --git a/hwe/b_betting.php b/hwe/b_betting.php index dae28212..b20d4024 100644 --- a/hwe/b_betting.php +++ b/hwe/b_betting.php @@ -16,17 +16,11 @@ TurnExecutionHelper::executeAllCommand(); $generalID = $session->generalID; -//NOTE: general_id만 빼기 귀찮음. -$myBet = $db->queryFirstList('SELECT * FROM betting WHERE general_id = %i', $generalID); -$myBet = array_splice($myBet, -16); -$globalBet = $db->queryFirstList('SELECT * FROM betting WHERE general_id = 0'); -$globalBet = array_splice($globalBet, -16); + + $me = $db->queryFirstRow('SELECT no,tournament,con,turntime from general where owner=%i', $userID); -$myBetTotal = array_sum($myBet); -$globalBetTotal = array_sum($globalBet); - $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'develcost']); $con = checkLimit($me['con']); @@ -36,34 +30,68 @@ if ($con >= 2) { } switch ($admin['tnmt_type']) { - default: - throw new \RuntimeException('Invalid tnmt_type'); case convertTournamentType('전력전'): - $tnmt_type = "전력전"; + $tnmt_type = "전력전"; + $color = "cyan"; $tp = "total"; $tp2 = "종합"; $tp3 = "total"; break; case convertTournamentType('통솔전'): - $tnmt_type = "통솔전"; + $tnmt_type = "통솔전"; + $color = "cyan"; $tp = "leadership"; $tp2 = "통솔"; $tp3 = "leadership"; break; case convertTournamentType('일기토'): - $tnmt_type = "일기토"; + $tnmt_type = "일기토"; + $color = "cyan"; $tp = "strength"; $tp2 = "무력"; $tp3 = "strength"; break; case convertTournamentType('설전'): - $tnmt_type = "설전"; + $tnmt_type = "설전"; + $color = "cyan"; $tp = "intel"; $tp2 = "지력"; $tp3 = "intel"; break; + default: + throw new \RuntimeException('Invalid tnmt_type'); } +$bettingID = $gameStor->last_tournament_betting_id ?? 0; +$myBet = []; +$globalBet = []; + +if ($bettingID != 0) { + $betting = $bettingID != 0 ? new Betting($bettingID) : null; + $info = $betting->getInfo(); + + foreach ($db->queryAllLists( + 'SELECT general_id, user_id, amount, betting_type FROM ng_betting WHERE betting_id = %i', + $bettingID + ) as [$betGeneralID, $userID, $amount, $bettingTypeKey]) { + $bettingKey = Json::decode($bettingTypeKey)[0]; + if ($betGeneralID == $generalID) { + $myBet[$bettingKey] = $amount; + } + + if (key_exists($bettingKey, $globalBet)) { + $globalBet[$bettingKey] += $amount; + } else { + $globalBet[$bettingKey] = $amount; + } + } +} else { + $info = getDummyBettingInfo($tnmt_type); +} + +$myBetTotal = array_sum($myBet); +$globalBetTotal = array_sum($globalBet); + $str1 = getTournament($admin['tournament']); $str2 = getTournamentTime(); if ($str2) { @@ -90,6 +118,11 @@ if ($str3) { = WebUtil::printCSS('../d_shared/common.css') ?> = WebUtil::printDist('ts', ['common', 'betting']) ?> + = WebUtil::printStaticValues([ + 'staticValues'=>[ + 'bettingID'=> $bettingID + ] + ])?>
@@ -104,7 +137,7 @@ if ($str3) {| {$bet[$i]} | "; + foreach (range(0, 15) as $i) { + $amount = $bet[$keyMap[$i] ?? -1] ?? 0; + echo "{$amount} | "; } ?>|||||||
| {$amount} | "; } ?>||||||||
| {$amount} | "; } echo " @@ -406,10 +441,11 @@ if ($str3) { echo "||||||||
| - | ||||||||
| "; + | "; } echo " | |||||||
| - = $tnmt_type ?> (= $str1 . $str2 . $str3 ?>) + = $tnmt_type ?> (= $str1 . $str2 . $str3 ?>) | ||||||||
| {$bet[$i]} | "; + foreach (range(0, 15) as $i) { + $amount = $bet[$keyMap[$i] ?? -1] ?? 0; + echo "{$amount} | "; } echo " diff --git a/hwe/c_tournament.php b/hwe/c_tournament.php index e34cc19a..aaf89b61 100644 --- a/hwe/c_tournament.php +++ b/hwe/c_tournament.php @@ -225,6 +225,8 @@ if($btn == "자동개최설정") { finallyAll($admin['tnmt_type'], $admin['tournament'], $admin['phase']); } elseif($btn == "배정") { final16set(); + $phase = 0; + startBetting($admin['tnmt_type'], 720); } elseif($btn == "베팅마감") { $dt = date("Y-m-d H:i:s", time() + 60); $gameStor->tournament=7; diff --git a/hwe/func.php b/hwe/func.php index dfbe9057..d6ca6911 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -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); } } diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php index c67754c6..9bf51ca2 100644 --- a/hwe/func_tournament.php +++ b/hwe/func_tournament.php @@ -2,13 +2,14 @@ namespace sammo; +use sammo\DTO\BettingInfo; function processTournament() { $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); - $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time']); + $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time', 'last_tournament_betting_id']); $now = new \DateTime(); $offset = $now->getTimestamp() - (new \DateTime($admin['tnmt_time']))->getTimestamp(); @@ -90,9 +91,12 @@ function processTournament() final16set(); $tnmt = 6; $phase = 0; - startBetting(); + startBetting($type, $unit); break; case 6: //베팅중 + $bettingID = $admin['last_tournament_betting_id']; + $betting = new Betting($bettingID); + $betting->closeBetting(); $tnmt = 7; $phase = 0; break; @@ -164,23 +168,32 @@ function processTournament() $gameStor->tnmt_time = (new \DateTimeImmutable($admin['tnmt_time']))->add(new \DateInterval("PT{$second}S"))->format('Y-m-d H:i:s'); } -function getTournamentTerm(): ?int{ +function getTournamentTerm(): ?int +{ $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); $tnmt_auto = $gameStor->tnmt_auto; - if($tnmt_auto === null){ + if ($tnmt_auto === null) { $tnmt_auto = $gameStor->tnmt_trig; } - switch($tnmt_auto){ - case 0: return null; - case 1: return 12 * 60; - case 2: return 7 * 60; - case 3: return 3 * 60; - case 4: return 1 * 60; - case 5: return 30; - case 6: return 15; - case 7: return 5; + switch ($tnmt_auto) { + case 0: + return null; + case 1: + return 12 * 60; + case 2: + return 7 * 60; + case 3: + return 3 * 60; + case 4: + return 1 * 60; + case 5: + return 30; + case 6: + return 15; + case 7: + return 5; } return null; } @@ -189,16 +202,16 @@ function getTournamentTermText() { $term = getTournamentTerm(); - if($term === null){ + if ($term === null) { return '수동'; } - if($term % 60 === 0){ + if ($term % 60 === 0) { $termMin = intdiv($term, 60); return "경기당 {$termMin}분"; } - if($term > 60){ + if ($term > 60) { $termSec = $term % 60; $termMin = intdiv($term, 60); return "경기당 {$termMin}분 {$termSec}초"; @@ -268,7 +281,7 @@ function printRow($k, $npc, $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $k += 1; if ($prmt > 0) { $name = "" . $name . ""; - } else if($npc > 0){ + } else if ($npc > 0) { $name = formatName($name, $npc); } echo "|||||||
| $k | $name | $abil | $tgame | $win | $draw | $lose | $gd | $gl |