diff --git a/hwe/b_betting.php b/hwe/b_betting.php
index 7432aa7a..dbbb31a2 100644
--- a/hwe/b_betting.php
+++ b/hwe/b_betting.php
@@ -23,8 +23,8 @@ $generalID = $session->generalID;
$me = $db->queryFirstRow('SELECT no,tournament,con,turntime from general where owner=%i', $userID);
-$admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'develcost']);
-
+$admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'turnterm', 'develcost']);
+$turnTerm = $admin['turnterm'];
$con = checkLimit($me['con']);
if ($con >= 2) {
printLimitMsg($me['turntime']);
@@ -99,7 +99,7 @@ $str2 = getTournamentTime();
if ($str2) {
$str2 = ', ' . $str2;
}
-$str3 = getTournamentTermText();
+$str3 = getTournamentTermText($turnTerm);
if ($str3) {
$str3 = ', ' . $str3;
}
diff --git a/hwe/b_tournament.php b/hwe/b_tournament.php
index 0626b8eb..c0a9d136 100644
--- a/hwe/b_tournament.php
+++ b/hwe/b_tournament.php
@@ -17,7 +17,8 @@ TurnExecutionHelper::executeAllCommand();
$me = $db->queryFirstRow('select no,tournament,con,turntime from general where owner=%i', $userID);
$generalID = $session->generalID;
-$admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_msg', 'tnmt_type', 'develcost', 'tnmt_trig']);
+$admin = $gameStor->getValues(['tournament', 'phase', 'turnterm', 'tnmt_msg', 'tnmt_type', 'develcost', 'tnmt_trig']);
+$turnTerm = $admin['turnterm'];
$con = checkLimit($me['con']);
if ($con >= 2) {
@@ -120,128 +121,80 @@ $globalBetTotal = array_sum($globalBet);
- userGrade >= 5) {
- $sel = [];
- echo "
-
+ 0 && $me['tournament'] == 0 && $admin['tournament'] == 1) : ?>
+
+
+
+ |
+
+ userGrade < 5) {
}
if($btn == "자동개최설정") {
- $gameStor->tnmt_trig = $trig;
+ $gameStor->tnmt_trig = !!$trig;
} elseif($btn == "개최") {
startTournament($auto, $type);
} elseif($btn == "중단") {
- $gameStor->tnmt_auto = 0;
+ $gameStor->tnmt_auto = false;
$gameStor->tournament = 0;
$gameStor->phase = 0;
} elseif($btn == "랜덤투입") {
diff --git a/hwe/func.php b/hwe/func.php
index e464a532..0d6b22e0 100644
--- a/hwe/func.php
+++ b/hwe/func.php
@@ -1358,7 +1358,7 @@ function triggerTournament(RandUtil $rng)
if ($tournament != 0) {
return;
}
- if ($tnmt_trig == 0) {
+ if (!$tnmt_trig) {
return;
}
if (!$rng->nextBool(0.4)) {
@@ -1374,7 +1374,7 @@ function triggerTournament(RandUtil $rng)
$tnmt_type = array_pop($tnmt_pattern);
$gameStor->setValue('tnmt_pattern', $tnmt_pattern);
- startTournament($tnmt_trig, $tnmt_type);
+ startTournament($tnmt_type);
}
function CheckHall($no)
diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php
index c020270d..4973f31a 100644
--- a/hwe/func_tournament.php
+++ b/hwe/func_tournament.php
@@ -5,17 +5,25 @@ namespace sammo;
use sammo\DTO\BettingInfo;
use sammo\Enums\InheritanceKey;
+/**
+ * @param int $turnTerm 서버 턴 단위
+ * @return int 토너먼트 초 단위
+ */
+function calcTournamentTerm(int $turnTerm): int{
+ return Util::valueFit($turnTerm, 5, 120);
+}
+
function processTournament()
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
- $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time', 'last_tournament_betting_id']);
+ $admin = $gameStor->getValues(['tournament', 'phase', 'tnmt_type', 'tnmt_auto', 'tnmt_time', 'turnterm', 'last_tournament_betting_id']);
$now = new \DateTime();
$offset = $now->getTimestamp() - (new \DateTime($admin['tnmt_time']))->getTimestamp();
//수동일땐 무시
- if ($admin['tnmt_auto'] == 0) {
+ if (!$admin['tnmt_auto']) {
return;
}
@@ -28,18 +36,7 @@ function processTournament()
}
//현시간이 스탬프 지나친경우
- $unit = [
- 1 => 720,
- 2 => 420,
- 3 => 180,
- 4 => 60,
- 5 => 30,
- 6 => 15,
- 7 => 5,
- ][$admin['tnmt_auto']] ?? null;
- if($unit === null){
- throw new MustNotBeReachedException();
- }
+ $unit = calcTournamentTerm($admin['turnterm']);
//업데이트 횟수
$iter = intdiv($offset, $unit) + 1;
@@ -123,10 +120,7 @@ function processTournament()
//베팅은 무조건 60페이즈후 진행(최대 1시간)
if ($tnmt == 6) {
- $betTerm = $unit * 60;
- if ($betTerm > 3600) {
- $betTerm = 3600;
- }
+ $betTerm = Util::valueFit($unit * 60, null, 3600);
//처리 초 더한 날짜
$dt = date("Y-m-d H:i:s", strtotime($admin['tnmt_time']) + $unit * $i + $betTerm);
$gameStor->tournament = $tnmt;
@@ -134,20 +128,6 @@ function processTournament()
$gameStor->tnmt_time = $dt;
return;
}
-
- if ($admin['tnmt_auto'] == 1) {
- //처리 초 더한 날짜
- $dt = date("Y-m-d H:i:s", strtotime($admin['tnmt_time']) + $unit * $i);
- $hr = substr($dt, 11, 2);
- //지정시간대 넘어가면 중단 20~24시
- if ($hr < 20) {
- $dt = substr($dt, 0, 11) . "20:00:00";
- $gameStor->tournament = $tnmt;
- $gameStor->phase = $phase;
- $gameStor->tnmt_time = $dt;
- return;
- }
- }
}
$second = $unit * $iter;
@@ -156,35 +136,9 @@ 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 getTournamentTermText(int $turnTerm)
{
- $db = DB::db();
- $gameStor = KVStorage::getStorage($db, 'game_env');
-
- $tnmt_auto = $gameStor->tnmt_auto;
- if ($tnmt_auto === null) {
- $tnmt_auto = $gameStor->tnmt_trig;
- }
-
- return [
- 0 => null,
- 1 => 12 * 60,
- 2 => 7 * 60,
- 3 => 3 * 60,
- 4 => 1 * 60,
- 5 => 30,
- 6 => 15,
- 7 => 5,
- ][$tnmt_auto] ?? null;
-}
-
-function getTournamentTermText()
-{
- $term = getTournamentTerm();
-
- if ($term === null) {
- return '수동';
- }
+ $term = calcTournamentTerm($turnTerm);
if ($term % 60 === 0) {
$termMin = intdiv($term, 60);
@@ -320,26 +274,18 @@ function printFighting($tournament, $phase)
}
}
-function startTournament($auto, $type)
+function startTournament($type)
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
eraseTnmtFightLogAll();
- $unit = [
- 1 => 60,
- 2 => 60,
- 3 => 60,
- 4 => 60,
- 5 => 30,
- 6 => 15,
- 7 => 5,
- ][$auto] ?? 60;
+ $admin = $gameStor->getValues(['year', 'month', 'turnterm']);
+ $turnTerm = $admin['turnterm'];
+ $unit = calcTournamentTerm($turnTerm);
- $admin = $gameStor->getValues(['year', 'month']);
-
- $gameStor->tnmt_auto = $auto;
+ $gameStor->tnmt_auto = true;
$gameStor->tnmt_time = (new \DateTimeImmutable())->add(new \DateInterval("PT{$unit}M"))->format('Y-m-d H:i:s');
$gameStor->tournament = 1;
$gameStor->tnmt_type = $type;
@@ -392,7 +338,7 @@ function getDummyBettingInfo(string $tnmt_type): BettingInfo
);
}
-function startBetting($type, $unit)
+function startBetting($type)
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
@@ -431,7 +377,6 @@ function startBetting($type, $unit)
aux: $general
);
}
- $candidateCnt = count($candidates);
Betting::openBetting(new BettingInfo(
id: $bettingID,
@@ -982,7 +927,7 @@ function setGift($tnmt_type, $tnmt, $phase)
}
//자동진행 끝
- $gameStor->tnmt_auto = 0;
+ $gameStor->tnmt_auto = false;
//장수열전 기록
/** @var ActionLogger */
@@ -1041,7 +986,7 @@ function setRefund()
}
//자동진행 끝
- $gameStor->tnmt_auto = 0;
+ $gameStor->tnmt_auto = false;
}
//10차이 1.1, 50 차이 1.17, 100차이 1.2
diff --git a/hwe/index.php b/hwe/index.php
index 273c4150..0cc2d4f2 100644
--- a/hwe/index.php
+++ b/hwe/index.php
@@ -190,7 +190,7 @@ if ($lastVoteID) {
NPC선택 : = $npcmode ?>
- 토너먼트 : = getTournamentTermText() ?>
+ 토너먼트 : = getTournamentTermText($gameStor->turnterm) ?>
기타 설정: = $otherTextInfo ?>
diff --git a/hwe/install.php b/hwe/install.php
index 25969c90..96b785f8 100644
--- a/hwe/install.php
+++ b/hwe/install.php
@@ -194,17 +194,11 @@ if ($session->userGrade < 5 && !$allowReset) {
diff --git a/hwe/j_autoreset.php b/hwe/j_autoreset.php
index 000f1588..4a881457 100644
--- a/hwe/j_autoreset.php
+++ b/hwe/j_autoreset.php
@@ -56,7 +56,7 @@ else if(
$status = 'closed';
}
else if(
- $isUnited > 0 &&
+ $isUnited > 0 &&
$now->getTimestamp() - $lastTurn->getTimestamp() > ($reservedDate->getTimestamp() - $now->getTimestamp()) * 2
){
//천통 & 비정지 상태 & 2/3 넘음
@@ -88,7 +88,7 @@ $result = ResetHelper::buildScenario(
$options['block_general_create'],
$options['npcmode'],
$options['show_img_level'],
- $options['tournament_trig'],
+ !!$options['tournament_trig'],
$options['join_mode'],
$options['starttime'],
$options['autorun_user']?:null
diff --git a/hwe/j_install.php b/hwe/j_install.php
index 9a3124ba..503f8af5 100644
--- a/hwe/j_install.php
+++ b/hwe/j_install.php
@@ -111,7 +111,7 @@ $extend = (int)$_POST['extend'];
$npcmode = (int)$_POST['npcmode'];
$block_general_create = (bool)$_POST['block_general_create'];
$show_img_level = (int)$_POST['show_img_level'];
-$tournament_trig = (int)$_POST['tournament_trig'];
+$tournament_trig = !!(int)$_POST['tournament_trig'];
$join_mode = $_POST['join_mode'];
$autorun_user_minutes = (int)$_POST['autorun_user_minutes'];
$autorun_user_options = [];
@@ -208,7 +208,7 @@ Json::die(ResetHelper::buildScenario(
$block_general_create,
$npcmode,
$show_img_level,
- $tournament_trig,
+ !!$tournament_trig,
$join_mode,
TimeUtil::now(),
$autorun_user
diff --git a/hwe/sammo/ResetHelper.php b/hwe/sammo/ResetHelper.php
index 51a3b64a..a0070f61 100644
--- a/hwe/sammo/ResetHelper.php
+++ b/hwe/sammo/ResetHelper.php
@@ -163,7 +163,7 @@ class ResetHelper{
bool $block_general_create,
int $npcmode,
int $show_img_level,
- int $tournament_trig,
+ bool $tournament_trig,
string $join_mode,
string $turntime,
?array $autorun_user
@@ -176,13 +176,6 @@ class ResetHelper{
];
}
- if($tournament_trig < 0 || $tournament_trig > 7){
- return [
- 'result'=>false,
- 'reason'=>'올바르지 않은 토너먼트 주기입니다.'
- ];
- }
-
$clearResult = self::clearDB();
if(!$clearResult['result']){
return $clearResult;