mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 15:24:44 +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");
|
args.sendMessage("Giving " + target.getName() + " " + items.size() + " relics");
|
||||||
}
|
}
|
||||||
case "a", "characters", "avatars" -> {
|
case "a", "characters", "avatars" -> {
|
||||||
|
// Eidolon items
|
||||||
|
List<GameItem> items = new ArrayList<>();
|
||||||
|
|
||||||
// All avatars and their eidolons
|
// All avatars and their eidolons
|
||||||
for (ItemExcel excel : GameData.getItemExcelMap().values()) {
|
for (var excel : GameData.getAvatarExcelMap().values()) {
|
||||||
if (excel.getItemMainType() == ItemMainType.AvatarCard) {
|
// Get avatar id
|
||||||
// Skip if target already has this avatar
|
GameAvatar avatar = target.getAvatarById(excel.getAvatarID());
|
||||||
if (target.getAvatars().hasAvatar(excel.getId())) {
|
|
||||||
continue;
|
// Add avatar
|
||||||
}
|
if (avatar == null) {
|
||||||
|
|
||||||
// Add avatar
|
// Add avatar
|
||||||
var avatarExcel = GameData.getAvatarExcelMap().get(excel.getId());
|
avatar = new GameAvatar(excel);
|
||||||
if (avatarExcel != null) {
|
args.setProperties(avatar); // Set avatar properties
|
||||||
GameAvatar avatar = new GameAvatar(avatarExcel);
|
|
||||||
args.setProperties(avatar); // Set avatar properties
|
|
||||||
|
|
||||||
target.getAvatars().addAvatar(avatar);
|
target.getAvatars().addAvatar(avatar);
|
||||||
}
|
|
||||||
} else if (excel.getItemSubType() == ItemSubType.Eidolon) {
|
|
||||||
// Add eidolons
|
|
||||||
target.getInventory().addItem(excel, 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Send message
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ public class AvatarExcel extends GameResource {
|
|||||||
public int getId() {
|
public int getId() {
|
||||||
return AvatarID;
|
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) {
|
public AvatarPromotionExcel getPromotionData(int i) {
|
||||||
return this.promotionData[i];
|
return this.promotionData[i];
|
||||||
|
|||||||
@@ -194,8 +194,8 @@ public class GachaService extends BaseGameService {
|
|||||||
GameAvatar avatar = player.getAvatars().getAvatarById(avatarId);
|
GameAvatar avatar = player.getAvatars().getAvatarById(avatarId);
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
int dupeLevel = avatar.getRank();
|
int dupeLevel = avatar.getRank();
|
||||||
int dupeItemId = avatarId + 10000; // Hacky fix so we dont have to fetch data from an excel
|
int dupeItemId = avatar.getExcel().getRankUpItemId();
|
||||||
GameItem dupeItem = player.getInventory().getTabByItemType(ItemMainType.Material).getItemById(dupeItemId);
|
GameItem dupeItem = player.getInventory().getMaterialByItemId(avatar.getExcel().getRankUpItemId());
|
||||||
if (dupeItem != null) {
|
if (dupeItem != null) {
|
||||||
dupeLevel += dupeItem.getCount();
|
dupeLevel += dupeItem.getCount();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user