fix: n차 혼합 베팅 보상 수령이 하나만 되는 버그 수정

This commit is contained in:
2022-02-05 07:43:28 +00:00
committed by Gitea
parent 6650cd2e41
commit 5b58e2efa5
4 changed files with 82 additions and 32 deletions
+27 -13
View File
@@ -2,6 +2,7 @@
namespace sammo\Event\Action;
use sammo\ActionLogger;
use sammo\Betting;
use \sammo\GameConst;
use \sammo\Util;
@@ -20,30 +21,43 @@ class FinishNationBetting extends \sammo\Event\Action
{
$db = DB::db();
$bettingStor = KVStorage::getStorage($db, 'betting');
$bettingInfoRaw = $bettingStor->getValue("id_{$this->bettingID}");
if($bettingInfoRaw === null){
return [__CLASS__, true];
}
try{
try {
$bettingHelper = new Betting($this->bettingID);
}
catch (\Exception $e){
} catch (\Exception $e) {
return [__CLASS__, false, $e->getMessage()];
}
$bettingInfo = $bettingHelper->getInfo();
if($bettingInfo->type != 'nationBetting'){
if ($bettingInfo->type != 'bettingNation') {
return [__CLASS__, false, 'invalid type', $bettingInfo->type];
}
$winnerNations = $bettingHelper->purifyBettingKey($db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0'));
if(count($winnerNations) != $bettingInfo->selectCnt){
$winnerNations = $db->queryFirstColumn('SELECT nation FROM nation WHERE level > 0');
if (count($winnerNations) != $bettingInfo->selectCnt) {
return [__CLASS__, false, 'invalid winner cnt', $bettingInfo->selectCnt];
}
$bettingHelper->giveReward($winnerNations);
//nation_id와 betting_type이 일치하지 않으므로 정렬
$nationIDMap = [];
foreach ($bettingInfo->candidates as $idx => $candidate) {
$aux = $candidate->aux;
if (!$aux) {
return [__CLASS__, false, "invalid aux {$idx}:{$candidate->title}"];
}
$nationID = $aux['nation'];
$nationIDMap[$nationID] = $idx;
}
$winnerTypes = [];
foreach ($winnerNations as $winnerNationID) {
$winnerTypes[] = $nationIDMap[$winnerNationID];
}
$winnerTypes = $bettingHelper->purifyBettingKey($winnerTypes);
$bettingHelper->giveReward($winnerTypes);
$logger = new ActionLogger(0, 0, $env['year'], $env['month']);
[$year, $month] = Util::parseYearMonth($bettingInfo->openYearMonth);
$logger->pushGlobalHistoryLog("<B><b>【내기】</b></> {$year}{$month}월에 열렸던 {$bettingInfo->name} 내기의 결과가 나왔습니다!");
return [__CLASS__, true];
}
+1 -1
View File
@@ -81,7 +81,7 @@ class OpenNationBetting extends \sammo\Event\Action
$bettingInfo = new BettingInfo(
id: $bettingID,
type: 'bettingNation',
name: "[{$year}{$month}월] {$name} 예상 베팅",
name: "{$name} 예상",
finished: false,
selectCnt: $this->nationCnt,
reqInheritancePoint: true,