feat,wip: 토너먼트 베팅 진행
This commit is contained in:
+27
-36
@@ -380,29 +380,12 @@ function startTournament($auto, $type)
|
||||
$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;
|
||||
$gameStor->lastTournamentBettingID = 0;
|
||||
$gameStor->phase = 0;
|
||||
|
||||
$db->update('general', [
|
||||
'tournament' => 0,
|
||||
], true);
|
||||
$db->update('betting', [
|
||||
'bet0' => 0,
|
||||
'bet1' => 0,
|
||||
'bet2' => 0,
|
||||
'bet3' => 0,
|
||||
'bet4' => 0,
|
||||
'bet5' => 0,
|
||||
'bet6' => 0,
|
||||
'bet7' => 0,
|
||||
'bet8' => 0,
|
||||
'bet9' => 0,
|
||||
'bet10' => 0,
|
||||
'bet11' => 0,
|
||||
'bet12' => 0,
|
||||
'bet13' => 0,
|
||||
'bet14' => 0,
|
||||
'bet15' => 0
|
||||
], true);
|
||||
$db->query('TRUNCATE TABLE tournament');
|
||||
|
||||
$opener = $db->queryFirstField('SELECT `general`.`name` FROM `general` JOIN `nation` ON `general`.`nation` = `nation`.`nation` WHERE `general`.`officer_level` = 12 AND `nation`.`level` = 7 ORDER BY rand() LIMIT 1');
|
||||
@@ -429,6 +412,21 @@ function startTournament($auto, $type)
|
||||
pushGlobalHistoryLog($history, $admin['year'], $admin['month']);
|
||||
}
|
||||
|
||||
function getDummyBettingInfo(string $tnmt_type): BettingInfo
|
||||
{
|
||||
return new BettingInfo(
|
||||
id: 0,
|
||||
type: 'tournament',
|
||||
name: $tnmt_type,
|
||||
finished: true,
|
||||
selectCnt: 1,
|
||||
reqInheritancePoint: false,
|
||||
openYearMonth: 0,
|
||||
closeYearMonth: 0,
|
||||
candidates: []
|
||||
);
|
||||
}
|
||||
|
||||
function startBetting($type, $unit)
|
||||
{
|
||||
$db = DB::db();
|
||||
@@ -449,24 +447,22 @@ function startBetting($type, $unit)
|
||||
|
||||
|
||||
//어차피 강제로 닫을 것이므로 크게 신경쓰지 않는다.
|
||||
$monthGap = floor(Util::valueFit($unit * 60, 3600) / ($turnterm * 60)) + 1;
|
||||
|
||||
$openYearMonth = Util::joinYearMonth($year, $month);
|
||||
$closeYearMonth = $openYearMonth + $monthGap;
|
||||
$closeYearMonth = $openYearMonth + 120;
|
||||
|
||||
/** @var \sammo\DTO\SelectItem[] */
|
||||
$candidates = [];
|
||||
|
||||
$generalList = $db->query('SELECT no,npc,name,win,leadership,strength,intel,leadership+strength+intel as total from tournament where grp>=20 order by grp, grp_no LIMIT 16');
|
||||
foreach($generalList as $idx=>$general) {
|
||||
if($general['no'] <= 0){
|
||||
foreach ($generalList as $idx => $general) {
|
||||
if ($general['no'] <= 0) {
|
||||
continue;
|
||||
}
|
||||
$general['idx'] = $idx;
|
||||
$candidates[$general['no']] = new \sammo\DTO\SelectItem(
|
||||
$general['name'],
|
||||
"{$statName}: {$general[$statKey]}",
|
||||
$general
|
||||
title: $general['name'],
|
||||
info: "{$statName}: {$general[$statKey]}",
|
||||
aux: $general
|
||||
);
|
||||
}
|
||||
$candidateCnt = count($candidates);
|
||||
@@ -491,14 +487,10 @@ function startBetting($type, $unit)
|
||||
|
||||
$npcList = $db->queryFirstColumn('SELECT no FROM general WHERE npc >= 2 AND gold >= (500 + %i)', $betGold);
|
||||
$npcBet = [];
|
||||
$betSum = [
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
];
|
||||
|
||||
$targetList = array_keys($candidates);
|
||||
foreach ($npcList as $npcID) {
|
||||
$target = Util::randRangeInt(0, $candidateCnt - 1);
|
||||
$betSum[$target] += $betGold;
|
||||
$target = Util::choiceRandom($targetList);
|
||||
$npcBet[] = [$npcID, $target];
|
||||
}
|
||||
|
||||
@@ -1216,15 +1208,14 @@ function setRefund()
|
||||
$bettingID = $gameStor->lastTournamentBettingID ?? 0;
|
||||
if (!$bettingID == 0) {
|
||||
$betting = new Betting($bettingID);
|
||||
if(!$betting->getInfo()->finished){
|
||||
if (!$betting->getInfo()->finished) {
|
||||
$betting->giveReward([-1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$db->update(['general', [
|
||||
'gold' => $db->sqleval('gold + (SELECT bet0+bet1+bet2+bet3+bet4+bet5+bet6+bet7+bet8+bet9+bet10+bet11+bet12+bet13+bet14+bet15 FROM betting WHERE general_id = general.no)')
|
||||
]], true);
|
||||
|
||||
Reference in New Issue
Block a user