Feat(WIP): OpenNationBetting Action 추가
- 시나리오 event에 추가
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\Event\Action;
|
||||||
|
|
||||||
|
use \sammo\GameConst;
|
||||||
|
use \sammo\Util;
|
||||||
|
use \sammo\DB;
|
||||||
|
use sammo\DTO\NationBettingInfo;
|
||||||
|
use sammo\Json;
|
||||||
|
use sammo\KVStorage;
|
||||||
|
|
||||||
|
class FinishNationBetting extends \sammo\Event\Action
|
||||||
|
{
|
||||||
|
public function __construct(private int $bettingID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(array $env)
|
||||||
|
{
|
||||||
|
$db = DB::db();
|
||||||
|
[$year, $month] = [$env['year'], $env['month']];
|
||||||
|
|
||||||
|
$nationBettingStor = KVStorage::getStorage($db, 'nation_betting');
|
||||||
|
$bettingInfoRaw = $nationBettingStor->getValue("id_{$this->bettingID}");
|
||||||
|
if($bettingInfoRaw === null){
|
||||||
|
return [__CLASS__, true];
|
||||||
|
}
|
||||||
|
$bettingInfo = new NationBettingInfo($bettingInfoRaw);
|
||||||
|
$bettingInfo->finished = true;
|
||||||
|
$nationBettingStor->setValue("id_{$this->bettingID}", $bettingInfo->toArray());
|
||||||
|
|
||||||
|
//TODO: 포인트를 배분해주어야 함
|
||||||
|
//TODO: 이후 토너먼트 베팅 결과도 같이 처리할 것이므로, 별도의 함수나 모듈을 생성하여 처리!
|
||||||
|
|
||||||
|
//NOTE: 완료되었음을 알릴 것인가?
|
||||||
|
|
||||||
|
return [__CLASS__, false, 'NYI'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace sammo\Event\Action;
|
||||||
|
|
||||||
|
use \sammo\GameConst;
|
||||||
|
use \sammo\Util;
|
||||||
|
use \sammo\DB;
|
||||||
|
use sammo\DTO\NationBettingInfo;
|
||||||
|
use sammo\Json;
|
||||||
|
use sammo\KVStorage;
|
||||||
|
|
||||||
|
class OpenNationBetting extends \sammo\Event\Action
|
||||||
|
{
|
||||||
|
public function __construct(private int $nationCnt = 1)
|
||||||
|
{
|
||||||
|
if ($nationCnt < 1) {
|
||||||
|
throw new \RuntimeException("1 미만의 숫자");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run(array $env)
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
|
||||||
|
$nationBettingStor = KVStorage::getStorage($db, 'nation_betting');
|
||||||
|
[$year, $month] = [$env['year'], $env['month']];
|
||||||
|
|
||||||
|
if ($this->nationCnt == 1) {
|
||||||
|
$name = "천통국";
|
||||||
|
} else {
|
||||||
|
$name = "최후 {$this->nationCnt}국";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$openYearMonth = Util::joinYearMonth($year, $month);
|
||||||
|
$closeYearMonth = $openYearMonth + 24;
|
||||||
|
|
||||||
|
$bettingInfo = new NationBettingInfo(
|
||||||
|
id: $bettingID,
|
||||||
|
name: "[{$year}년 {$month}월] {$name} 예상 베팅",
|
||||||
|
finished: false,
|
||||||
|
selectCnt: $this->nationCnt,
|
||||||
|
reqInheritancePoint: true,
|
||||||
|
openYearMonth: $openYearMonth,
|
||||||
|
closeYearMonth: $closeYearMonth,
|
||||||
|
);
|
||||||
|
$nationBettingStor->setValue("id_{$bettingID}", $bettingInfo->toArray());
|
||||||
|
|
||||||
|
$db->insert('event', [
|
||||||
|
'target' => 'DESTROY_NATION',
|
||||||
|
'priority' => 1000,
|
||||||
|
'condition' => Json::encode(
|
||||||
|
["RemainNation", $this->nationCnt],
|
||||||
|
),
|
||||||
|
'action' => Json::encode([
|
||||||
|
["FinishNationBetting", $bettingID],
|
||||||
|
["DeleteEvent"],
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
$logger = new \sammo\ActionLogger(0, 0, $year, $month);
|
||||||
|
$logger->pushGlobalHistoryLog("<B><b>【내기】</b></>천하통일을 염원하는 <C>내기</>가 진행중입니다! 호사가의 참여를 기다립니다!");
|
||||||
|
$logger->flush();
|
||||||
|
|
||||||
|
return [__CLASS__, true];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -144,6 +144,41 @@
|
|||||||
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
["or", ["Date", "==", null, 12], ["Date", "==", null, 6]],
|
||||||
["CreateManyNPC", 10, 10],
|
["CreateManyNPC", 10, 10],
|
||||||
["DeleteEvent"]
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["Date", "==", 181, 1],
|
||||||
|
["OpenNationBetting", 4],
|
||||||
|
["OpenNationBetting", 1],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["and",
|
||||||
|
["Date", ">=", 183, 1],
|
||||||
|
["RemainNation", "<=", 16]
|
||||||
|
],
|
||||||
|
["OpenNationBetting", 4],
|
||||||
|
["OpenNationBetting", 1],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["and",
|
||||||
|
["Date", ">=", 183, 1],
|
||||||
|
["RemainNation", "<=", 8]
|
||||||
|
],
|
||||||
|
["OpenNationBetting", 1],
|
||||||
|
["DeleteEvent"]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"month", 1000,
|
||||||
|
["and",
|
||||||
|
["Date", ">=", 183, 1],
|
||||||
|
["RemainNation", "<=", 4]
|
||||||
|
],
|
||||||
|
["OpenNationBetting", 1],
|
||||||
|
["DeleteEvent"]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user