feat,wip: 토너먼트 베팅 진행

This commit is contained in:
2022-04-25 00:30:31 +09:00
parent 18f2e9ffea
commit 42fc0f6aed
7 changed files with 164 additions and 178 deletions
+51 -42
View File
@@ -17,40 +17,10 @@ TurnExecutionHelper::executeAllCommand();
$generalID = $session->generalID;
$bettingID = $gameStor->lastTournamentBettingID ?? 0;
if ($bettingID == 0) {
//TODO: 좋은 방법 없나?
die('아직 베팅이 열리지 않았습니다.');
}
$betting = new Betting($bettingID);
$info = $betting->getInfo();
$myBet = [];
$globalBet = [];
foreach ($db->queryAllLists(
'SELECT general_id, user_id, amount, betting_type FROM ng_betting WHERE betting_id = %i',
$this->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;
}
}
$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']);
@@ -60,34 +30,68 @@ if ($con >= 2) {
}
switch ($admin['tnmt_type']) {
default:
throw new \RuntimeException('Invalid tnmt_type');
case convertTournamentType('전력전'):
$tnmt_type = "<font color=cyan>전력전</font>";
$tnmt_type = "전력전";
$color = "cyan";
$tp = "total";
$tp2 = "종합";
$tp3 = "total";
break;
case convertTournamentType('통솔전'):
$tnmt_type = "<font color=cyan>통솔전</font>";
$tnmt_type = "통솔전";
$color = "cyan";
$tp = "leadership";
$tp2 = "통솔";
$tp3 = "leadership";
break;
case convertTournamentType('일기토'):
$tnmt_type = "<font color=cyan>일기토</font>";
$tnmt_type = "일기토";
$color = "cyan";
$tp = "strength";
$tp2 = "무력";
$tp3 = "strength";
break;
case convertTournamentType('설전'):
$tnmt_type = "<font color=cyan>설전</font>";
$tnmt_type = "설전";
$color = "cyan";
$tp = "intel";
$tp2 = "지력";
$tp3 = "intel";
break;
default:
throw new \RuntimeException('Invalid tnmt_type');
}
$bettingID = $gameStor->lastTournamentBettingID ?? 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) {
@@ -114,6 +118,11 @@ if ($str3) {
<?= WebUtil::printCSS('../d_shared/common.css') ?>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
<?= WebUtil::printDist('ts', ['common', 'betting']) ?>
<?= WebUtil::printStaticValues([
'staticValues'=>[
'bettingID'=> $bettingID
]
])?>
</head>
<body>
@@ -128,7 +137,7 @@ if ($str3) {
</tr>
<tr>
<td colspan=16 align=center>
<font color=white size=6><?= $tnmt_type ?> (<?= $str1 . $str2 . $str3 ?>)</font>
<font color=white size=6><span style="color:<?= $color ?>"><?= $tnmt_type ?></span> (<?= $str1 . $str2 . $str3 ?>)</font>
</td>
</tr>
<tr>
@@ -368,7 +377,7 @@ if ($str3) {
<tr align=center>";
foreach (range(0, 15) as $i) {
$amount = $bet[$keyMap[$i]] ?? 0;
$amount = $bet[$keyMap[$i] ?? -1] ?? 0;
echo "<td width=70><font color=skyblue>{$amount}</font></td>";
}
?>
@@ -394,7 +403,7 @@ if ($str3) {
<tr align=center>
<?php
foreach (range(0, 15) as $i) {
$amount = $myBet[$keyMap[$i]] ?? 0;
$amount = $myBet[$keyMap[$i] ?? -1] ?? 0;
echo "<td><font color=orange>{$amount}</font></td>";
}
?>
@@ -420,7 +429,7 @@ if ($str3) {
<tr align=center>
<?php
foreach (range(0, 15) as $i) {
$amount = $gold[$keyMap[$i]] ?? 0;
$amount = $gold[$keyMap[$i] ?? -1] ?? 0;
echo "<td><font color=cyan>{$amount}</font></td>";
}
@@ -433,7 +442,7 @@ if ($str3) {
<tr align=center>";
foreach (range(0, 15) as $i) {
$key = $keyMap[$i];
$key = $keyMap[$i] ?? -1;
echo "
<td>
<select size=1 id='target_{$key}' style=color:white;background-color:black;>
@@ -453,7 +462,7 @@ if ($str3) {
<tr align=center>";
foreach (range(0, 15) as $i) {
$key = $keyMap[$i];
$key = $keyMap[$i] ?? -1;
echo "
<td><input type=button class='submitBtn' data-target='{$key}' value=베팅! style=width:100%;color:white;background-color:black;></td>";
}