Rename and clean up MapleLootManager

This commit is contained in:
P0nk
2021-09-09 22:14:54 +02:00
parent 7246647ab6
commit af2707120a
2 changed files with 21 additions and 20 deletions

View File

@@ -45,7 +45,7 @@ import scripting.event.EventInstanceManager;
import server.MapleStatEffect;
import server.TimerManager;
import server.life.LifeFactory.BanishInfo;
import server.loot.MapleLootManager;
import server.loot.LootManager;
import server.maps.AbstractAnimatedMapleMapObject;
import server.maps.MapleMap;
import server.maps.MapleMapObjectType;
@@ -751,7 +751,7 @@ public class Monster extends AbstractLoadedLife {
}
}
return MapleLootManager.retrieveRelevantDrops(this.getId(), lootChars);
return LootManager.retrieveRelevantDrops(this.getId(), lootChars);
}
public Character killBy(final Character killer) {

View File

@@ -28,11 +28,10 @@ import java.util.LinkedList;
import java.util.List;
/**
*
* @author Ronan
*/
public class MapleLootManager {
public class LootManager {
private static boolean isRelevantDrop(MonsterDropEntry dropEntry, List<Character> players, List<LootInventory> playersInv) {
int qStartAmount = 0, qCompleteAmount = 0;
MapleQuest quest = MapleQuest.getInstance(dropEntry.questid);
@@ -40,11 +39,11 @@ public class MapleLootManager {
qStartAmount = quest.getStartItemAmountNeeded(dropEntry.itemId);
qCompleteAmount = quest.getCompleteItemAmountNeeded(dropEntry.itemId);
}
//boolean restricted = MapleItemInformationProvider.getInstance().isPickupRestricted(dropEntry.itemId);
for (int i = 0; i < players.size(); i++) {
LootInventory chrInv = playersInv.get(i);
if (dropEntry.questid > 0) {
int qItemAmount, chrQuestStatus = players.get(i).getQuestStatus(dropEntry.questid);
if (chrQuestStatus == 0) {
@@ -54,9 +53,9 @@ public class MapleLootManager {
} else {
qItemAmount = qCompleteAmount;
}
// thanks kvmba for noticing quest items with no required amount failing to be detected as such
int qItemStatus = chrInv.hasItem(dropEntry.itemId, qItemAmount);
if (qItemStatus == 2) {
continue;
@@ -66,31 +65,33 @@ public class MapleLootManager {
} /*else if (restricted && chrInv.hasItem(dropEntry.itemId, 1) > 0) { // thanks Conrad, Legalize for noticing eligible loots not being available to drop for non-killer parties
continue;
}*/
return true;
}
return false;
}
public static List<MonsterDropEntry> retrieveRelevantDrops(int monsterId, List<Character> players) {
List<MonsterDropEntry> loots = MonsterInformationProvider.getInstance().retrieveEffectiveDrop(monsterId);
if(loots.isEmpty()) return loots;
if (loots.isEmpty()) {
return loots;
}
List<LootInventory> playersInv = new LinkedList<>();
for(Character chr : players) {
for (Character chr : players) {
LootInventory lootInv = new LootInventory(chr);
playersInv.add(lootInv);
}
List<MonsterDropEntry> effectiveLoot = new LinkedList<>();
for(MonsterDropEntry mde : loots) {
if(isRelevantDrop(mde, players, playersInv)) {
for (MonsterDropEntry mde : loots) {
if (isRelevantDrop(mde, players, playersInv)) {
effectiveLoot.add(mde);
}
}
return effectiveLoot;
}
}