From 1da47863ae465afe33f1271f57e092e40b5cabef Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 30 Oct 2022 22:13:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A0=84=EC=97=AD=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=ED=85=9C=20=EB=A7=9D=EC=8B=A4=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Event/Action/LostUniqueItem.php | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 hwe/sammo/Event/Action/LostUniqueItem.php diff --git a/hwe/sammo/Event/Action/LostUniqueItem.php b/hwe/sammo/Event/Action/LostUniqueItem.php new file mode 100644 index 00000000..0463d40a --- /dev/null +++ b/hwe/sammo/Event/Action/LostUniqueItem.php @@ -0,0 +1,83 @@ +queryFirstColumn("SELECT `no` FROM general WHERE npc <= 1"); + if(!$generalIDList){ + return; + } + $generals = General::createGeneralObjListFromDB($generalIDList); + + $lostItems = []; + $lostCnt = 0; + + $year = $env['year']; + $month = $env['month']; + $rng = new RandUtil(new LiteHashDRBG(Util::simpleSerialize( + UniqueConst::$hiddenSeed, + 'LostUniqueItem', + $year, + $month, + ))); + + foreach ($generals as $general) { + $itemList = $general->getItems(); + $didLoseItem = false; + foreach ($itemList as $itemType => $item) { + if ($item->isBuyable()) { + continue; + } + + + $logger = $general->getLogger(); + + if ($rng->nextBool($this->lostProb)) { + $itemName = $item->getName(); + $itemRawName = $item->getRawName(); + $josaUl = JosaUtil::pick($itemRawName, '을'); + $lostItems[$itemName] = 1; + $lostCnt++; + $general->setItem($itemType, 'None'); + $didLoseItem = true; + $logger->pushGeneralActionLog("{$itemName}{$josaUl} 잃었습니다."); + } + } + + if ($didLoseItem) { + $general->applyDB($db); + } + } + + $logger = new ActionLogger(0, 0, $year, $month); + if($lostCnt == 0){ + $logger->pushGlobalHistoryLog("【망실】어떤 아이템도 잃지 않았습니다!"); + } + else{ + $logger->pushGlobalHistoryLog("【망실】{$lostCnt}개의 아이템을 잃었습니다!"); + } + $logger->flush(); + + } +}