From 56c9b44c9391d95645e0cd49027d96852826d003 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 2 Nov 2022 21:17:04 +0900 Subject: [PATCH] =?UTF-8?q?game:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=9C=A0?= =?UTF-8?q?=EB=8B=88=ED=81=AC=20=EB=B6=84=EC=8B=A4=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=ED=9D=A5=EB=AF=B8=EB=A1=AD=EA=B2=8C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Event/Action/LostUniqueItem.php | 45 ++++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/hwe/sammo/Event/Action/LostUniqueItem.php b/hwe/sammo/Event/Action/LostUniqueItem.php index 0463d40a..f3c9450a 100644 --- a/hwe/sammo/Event/Action/LostUniqueItem.php +++ b/hwe/sammo/Event/Action/LostUniqueItem.php @@ -25,13 +25,13 @@ class LostUniqueItem extends \sammo\Event\Action $db = DB::db(); $generalIDList = $db->queryFirstColumn("SELECT `no` FROM general WHERE npc <= 1"); - if(!$generalIDList){ + if (!$generalIDList) { return; } $generals = General::createGeneralObjListFromDB($generalIDList); $lostItems = []; - $lostCnt = 0; + $totalLostCnt = 0; $year = $env['year']; $month = $env['month']; @@ -42,9 +42,14 @@ class LostUniqueItem extends \sammo\Event\Action $month, ))); + $maxLostByGenCnt = 0; + $maxLostGenList = []; + foreach ($generals as $general) { $itemList = $general->getItems(); $didLoseItem = false; + $lostByGenCnt = 0; + foreach ($itemList as $itemType => $item) { if ($item->isBuyable()) { continue; @@ -58,26 +63,46 @@ class LostUniqueItem extends \sammo\Event\Action $itemRawName = $item->getRawName(); $josaUl = JosaUtil::pick($itemRawName, '을'); $lostItems[$itemName] = 1; - $lostCnt++; + $totalLostCnt++; + $lostByGenCnt++; $general->setItem($itemType, 'None'); $didLoseItem = true; $logger->pushGeneralActionLog("{$itemName}{$josaUl} 잃었습니다."); } } - if ($didLoseItem) { - $general->applyDB($db); + if (!$didLoseItem) { + continue; + } + + $general->applyDB($db); + + if ($maxLostByGenCnt < $lostByGenCnt) { + $maxLostByGenCnt = $lostByGenCnt; + $maxLostGenList = [$general->getName()]; + } else if ($maxLostByGenCnt === $lostByGenCnt) { + $maxLostGenList[] = $general->getName(); } } $logger = new ActionLogger(0, 0, $year, $month); - if($lostCnt == 0){ + if ($totalLostCnt == 0) { $logger->pushGlobalHistoryLog("【망실】어떤 아이템도 잃지 않았습니다!"); - } - else{ - $logger->pushGlobalHistoryLog("【망실】{$lostCnt}개의 아이템을 잃었습니다!"); + } else { + $genCnt = count($maxLostGenList); + if($genCnt > 4){ + $maxLostGenList = array_slice($maxLostGenList, 0, 4); + + } + $maxLostGenListStr = implode(', ', $maxLostGenList); + + if($genCnt > 4){ + $maxLostGenListStr .= ' 외 ' . ($genCnt - 4) . '명'; + } + $josaYi = JosaUtil::pick($maxLostGenListStr, '이'); + + $logger->pushGlobalHistoryLog("【망실】불운하게도 {$maxLostGenListStr}{$josaYi} 한 번에 유니크 {$maxLostByGenCnt}종을 잃었습니다! (총 {$totalLostCnt}개)"); } $logger->flush(); - } }