refac: Betting 시작 코드를 모듈로 이동

This commit is contained in:
2022-04-23 01:39:02 +09:00
parent 4bf67aa5e1
commit 200065fad1
2 changed files with 26 additions and 10 deletions
+5 -10
View File
@@ -2,6 +2,7 @@
namespace sammo\Event\Action;
use sammo\Betting;
use \sammo\GameConst;
use \sammo\Util;
use \sammo\DB;
@@ -28,12 +29,6 @@ class OpenNationBetting extends \sammo\Event\Action
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
$gameStor->invalidateCacheValue('last_betting_id');
$bettingID = ($gameStor->getValue('last_betting_id') ?? 0) + 1;
$gameStor->setValue('last_betting_id', $bettingID);
$bettingStor = KVStorage::getStorage($db, 'betting');
[$year, $month] = [$env['year'], $env['month']];
if ($this->nationCnt == 1) {
@@ -77,8 +72,9 @@ class OpenNationBetting extends \sammo\Event\Action
aux: $nationRaw,
);
}
$bettingInfo = new BettingInfo(
$bettingID = \sammo\Betting::genNextBettingID();
Betting::openBetting(new BettingInfo(
id: $bettingID,
type: 'bettingNation',
name: "{$name} 예상",
@@ -88,8 +84,7 @@ class OpenNationBetting extends \sammo\Event\Action
openYearMonth: $openYearMonth,
closeYearMonth: $closeYearMonth,
candidates: $candidates,
);
$bettingStor->setValue("id_{$bettingID}", $bettingInfo->toArray());
));
$db->insert('event', [
'target' => 'DESTROY_NATION',