From ca9db6dc18b1bc7360e173637f35397041d1015c Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 26 Jan 2022 02:59:00 +0900 Subject: [PATCH] =?UTF-8?q?Feat(WIP):=20OpenNationBetting=20Action=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20=EC=8B=9C=EB=82=98=EB=A6=AC=EC=98=A4?= =?UTF-8?q?=20event=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Event/Action/FinishNationBetting.php | 39 ++++++++++ hwe/sammo/Event/Action/OpenNationBetting.php | 71 +++++++++++++++++++ hwe/scenario/scenario_904.json | 35 +++++++++ 3 files changed, 145 insertions(+) create mode 100644 hwe/sammo/Event/Action/FinishNationBetting.php create mode 100644 hwe/sammo/Event/Action/OpenNationBetting.php diff --git a/hwe/sammo/Event/Action/FinishNationBetting.php b/hwe/sammo/Event/Action/FinishNationBetting.php new file mode 100644 index 00000000..d33c847e --- /dev/null +++ b/hwe/sammo/Event/Action/FinishNationBetting.php @@ -0,0 +1,39 @@ +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']; + } +} diff --git a/hwe/sammo/Event/Action/OpenNationBetting.php b/hwe/sammo/Event/Action/OpenNationBetting.php new file mode 100644 index 00000000..5fe6c5a7 --- /dev/null +++ b/hwe/sammo/Event/Action/OpenNationBetting.php @@ -0,0 +1,71 @@ +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("【내기】천하통일을 염원하는 내기가 진행중입니다! 호사가의 참여를 기다립니다!"); + $logger->flush(); + + return [__CLASS__, true]; + } +} diff --git a/hwe/scenario/scenario_904.json b/hwe/scenario/scenario_904.json index c81d6752..c6ad8f3e 100644 --- a/hwe/scenario/scenario_904.json +++ b/hwe/scenario/scenario_904.json @@ -144,6 +144,41 @@ ["or", ["Date", "==", null, 12], ["Date", "==", null, 6]], ["CreateManyNPC", 10, 10], ["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"] ] ] } \ No newline at end of file