game: 이벤트 유니크 분실 메시지를 흥미롭게 변경
This commit is contained in:
@@ -25,13 +25,13 @@ class LostUniqueItem extends \sammo\Event\Action
|
|||||||
$db = DB::db();
|
$db = DB::db();
|
||||||
|
|
||||||
$generalIDList = $db->queryFirstColumn("SELECT `no` FROM general WHERE npc <= 1");
|
$generalIDList = $db->queryFirstColumn("SELECT `no` FROM general WHERE npc <= 1");
|
||||||
if(!$generalIDList){
|
if (!$generalIDList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$generals = General::createGeneralObjListFromDB($generalIDList);
|
$generals = General::createGeneralObjListFromDB($generalIDList);
|
||||||
|
|
||||||
$lostItems = [];
|
$lostItems = [];
|
||||||
$lostCnt = 0;
|
$totalLostCnt = 0;
|
||||||
|
|
||||||
$year = $env['year'];
|
$year = $env['year'];
|
||||||
$month = $env['month'];
|
$month = $env['month'];
|
||||||
@@ -42,9 +42,14 @@ class LostUniqueItem extends \sammo\Event\Action
|
|||||||
$month,
|
$month,
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
$maxLostByGenCnt = 0;
|
||||||
|
$maxLostGenList = [];
|
||||||
|
|
||||||
foreach ($generals as $general) {
|
foreach ($generals as $general) {
|
||||||
$itemList = $general->getItems();
|
$itemList = $general->getItems();
|
||||||
$didLoseItem = false;
|
$didLoseItem = false;
|
||||||
|
$lostByGenCnt = 0;
|
||||||
|
|
||||||
foreach ($itemList as $itemType => $item) {
|
foreach ($itemList as $itemType => $item) {
|
||||||
if ($item->isBuyable()) {
|
if ($item->isBuyable()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -58,26 +63,46 @@ class LostUniqueItem extends \sammo\Event\Action
|
|||||||
$itemRawName = $item->getRawName();
|
$itemRawName = $item->getRawName();
|
||||||
$josaUl = JosaUtil::pick($itemRawName, '을');
|
$josaUl = JosaUtil::pick($itemRawName, '을');
|
||||||
$lostItems[$itemName] = 1;
|
$lostItems[$itemName] = 1;
|
||||||
$lostCnt++;
|
$totalLostCnt++;
|
||||||
|
$lostByGenCnt++;
|
||||||
$general->setItem($itemType, 'None');
|
$general->setItem($itemType, 'None');
|
||||||
$didLoseItem = true;
|
$didLoseItem = true;
|
||||||
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 잃었습니다.");
|
$logger->pushGeneralActionLog("<C>{$itemName}</>{$josaUl} 잃었습니다.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($didLoseItem) {
|
if (!$didLoseItem) {
|
||||||
$general->applyDB($db);
|
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);
|
$logger = new ActionLogger(0, 0, $year, $month);
|
||||||
if($lostCnt == 0){
|
if ($totalLostCnt == 0) {
|
||||||
$logger->pushGlobalHistoryLog("<R><b>【망실】</b></>어떤 아이템도 잃지 않았습니다!");
|
$logger->pushGlobalHistoryLog("<R><b>【망실】</b></>어떤 아이템도 잃지 않았습니다!");
|
||||||
}
|
} else {
|
||||||
else{
|
$genCnt = count($maxLostGenList);
|
||||||
$logger->pushGlobalHistoryLog("<R><b>【망실】</b></>총 <C>{$lostCnt}</>개의 아이템을 잃었습니다!");
|
if($genCnt > 4){
|
||||||
|
$maxLostGenList = array_slice($maxLostGenList, 0, 4);
|
||||||
|
|
||||||
|
}
|
||||||
|
$maxLostGenListStr = implode(', ', $maxLostGenList);
|
||||||
|
|
||||||
|
if($genCnt > 4){
|
||||||
|
$maxLostGenListStr .= ' 외 ' . ($genCnt - 4) . '명';
|
||||||
|
}
|
||||||
|
$josaYi = JosaUtil::pick($maxLostGenListStr, '이');
|
||||||
|
|
||||||
|
$logger->pushGlobalHistoryLog("<R><b>【망실】</b></>불운하게도 <Y>{$maxLostGenListStr}</>{$josaYi} 한 번에 유니크 <C>{$maxLostByGenCnt}</>종을 잃었습니다! (총 <C>{$totalLostCnt}</>개)");
|
||||||
}
|
}
|
||||||
$logger->flush();
|
$logger->flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user