mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 07:14:58 +01:00
/giveall should not give more eidolons than needed
This commit is contained in:
@@ -102,26 +102,46 @@ public class GiveAllCommand implements CommandHandler {
|
||||
args.sendMessage("Giving " + target.getName() + " " + items.size() + " relics");
|
||||
}
|
||||
case "a", "characters", "avatars" -> {
|
||||
// Eidolon items
|
||||
List<GameItem> items = new ArrayList<>();
|
||||
|
||||
// All avatars and their eidolons
|
||||
for (ItemExcel excel : GameData.getItemExcelMap().values()) {
|
||||
if (excel.getItemMainType() == ItemMainType.AvatarCard) {
|
||||
// Skip if target already has this avatar
|
||||
if (target.getAvatars().hasAvatar(excel.getId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var excel : GameData.getAvatarExcelMap().values()) {
|
||||
// Get avatar id
|
||||
GameAvatar avatar = target.getAvatarById(excel.getAvatarID());
|
||||
|
||||
// Add avatar
|
||||
if (avatar == null) {
|
||||
// Add avatar
|
||||
var avatarExcel = GameData.getAvatarExcelMap().get(excel.getId());
|
||||
if (avatarExcel != null) {
|
||||
GameAvatar avatar = new GameAvatar(avatarExcel);
|
||||
args.setProperties(avatar); // Set avatar properties
|
||||
avatar = new GameAvatar(excel);
|
||||
args.setProperties(avatar); // Set avatar properties
|
||||
|
||||
target.getAvatars().addAvatar(avatar);
|
||||
}
|
||||
} else if (excel.getItemSubType() == ItemSubType.Eidolon) {
|
||||
// Add eidolons
|
||||
target.getInventory().addItem(excel, 6);
|
||||
target.getAvatars().addAvatar(avatar);
|
||||
}
|
||||
|
||||
// Get eidolon excel
|
||||
ItemExcel itemExcel = GameData.getItemExcelMap().get(excel.getRankUpItemId());
|
||||
if (itemExcel == null || itemExcel.getItemSubType() != ItemSubType.Eidolon) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate how many eidolons we need
|
||||
int rankCount = avatar.getRank();
|
||||
GameItem rankItem = target.getInventory().getMaterialByItemId(itemExcel.getId());
|
||||
if (rankItem != null) {
|
||||
rankCount += rankItem.getCount();
|
||||
}
|
||||
|
||||
// Add eidolons
|
||||
int amount = 6 - rankCount;
|
||||
if (amount > 0) {
|
||||
items.add(new GameItem(itemExcel, amount));
|
||||
}
|
||||
}
|
||||
|
||||
// Add to target's inventory
|
||||
if (items.size() > 0) {
|
||||
target.getInventory().addItems(items, true);
|
||||
}
|
||||
|
||||
// Send message
|
||||
|
||||
@@ -53,6 +53,11 @@ public class AvatarExcel extends GameResource {
|
||||
public int getId() {
|
||||
return AvatarID;
|
||||
}
|
||||
|
||||
public int getRankUpItemId() {
|
||||
// Hacky fix so we dont have to fetch data from an excel
|
||||
return this.AvatarID + 10000;
|
||||
}
|
||||
|
||||
public AvatarPromotionExcel getPromotionData(int i) {
|
||||
return this.promotionData[i];
|
||||
|
||||
@@ -194,8 +194,8 @@ public class GachaService extends BaseGameService {
|
||||
GameAvatar avatar = player.getAvatars().getAvatarById(avatarId);
|
||||
if (avatar != null) {
|
||||
int dupeLevel = avatar.getRank();
|
||||
int dupeItemId = avatarId + 10000; // Hacky fix so we dont have to fetch data from an excel
|
||||
GameItem dupeItem = player.getInventory().getTabByItemType(ItemMainType.Material).getItemById(dupeItemId);
|
||||
int dupeItemId = avatar.getExcel().getRankUpItemId();
|
||||
GameItem dupeItem = player.getInventory().getMaterialByItemId(avatar.getExcel().getRankUpItemId());
|
||||
if (dupeItem != null) {
|
||||
dupeLevel += dupeItem.getCount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user