fix: n차 혼합 베팅 보상 수령이 하나만 되는 버그 수정
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user