mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Add substats when setting relic level via the give command
This commit is contained in:
@@ -144,22 +144,39 @@ public class CommandArgs {
|
||||
if (this.getLevel() > 0) {
|
||||
item.setLevel(Math.min(this.getLevel(), 80));
|
||||
item.setPromotion(Utils.getMinPromotionForLevel(item.getLevel()));
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
// Try to set promotion
|
||||
if (this.getPromotion() >= 0) {
|
||||
item.setPromotion(Math.min(this.getPromotion(), item.getExcel().getEquipmentExcel().getMaxPromotion()));
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
// Try to set rank (superimposition)
|
||||
if (this.getRank() >= 0) {
|
||||
item.setRank(Math.min(this.getRank(), item.getExcel().getEquipmentExcel().getMaxRank()));
|
||||
hasChanged = true;
|
||||
}
|
||||
} else if (item.getExcel().isRelic()) {
|
||||
// Try to set level
|
||||
if (this.getLevel() > 0) {
|
||||
int oldLevel = item.getLevel();
|
||||
int upgrades = 0;
|
||||
|
||||
item.setLevel(Math.min(this.getLevel(), 15));
|
||||
// TODO add substats
|
||||
|
||||
for (int i = oldLevel + 1; i <= item.getLevel(); i++) {
|
||||
if (i % 3 == 0) {
|
||||
upgrades++;
|
||||
}
|
||||
}
|
||||
|
||||
if (upgrades > 0) {
|
||||
item.addSubAffixes(upgrades);
|
||||
}
|
||||
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,32 +41,12 @@ public class GiveCommand implements CommandHandler {
|
||||
if (itemData.getItemMainType() == ItemMainType.AvatarCard) {
|
||||
// Add avatar
|
||||
GameAvatar avatar = new GameAvatar(itemData.getId());
|
||||
|
||||
if (args.getTarget().addAvatar(avatar)) {
|
||||
// Change avatar properties
|
||||
args.setProperties(avatar);
|
||||
}
|
||||
args.setProperties(avatar);
|
||||
args.getTarget().addAvatar(avatar);
|
||||
} else if (itemData.isEquippable()) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
GameItem item = new GameItem(itemData);
|
||||
|
||||
if (item.getExcel().isEquipment()) {
|
||||
// Try to set level
|
||||
if (args.getLevel() > 0) {
|
||||
item.setLevel(Math.min(args.getLevel(), 80));
|
||||
item.setPromotion(Utils.getMinPromotionForLevel(item.getLevel()));
|
||||
}
|
||||
|
||||
// Try to set promotion
|
||||
if (args.getPromotion() >= 0) {
|
||||
item.setPromotion(Math.min(args.getPromotion(), item.getExcel().getEquipmentExcel().getMaxPromotion()));
|
||||
}
|
||||
|
||||
// Try to set rank (superimposition)
|
||||
if (args.getRank() >= 0) {
|
||||
item.setRank(Math.min(args.getRank(), item.getExcel().getEquipmentExcel().getMaxRank()));
|
||||
}
|
||||
}
|
||||
args.setProperties(item);
|
||||
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
@@ -206,6 +206,14 @@ public class GameItem {
|
||||
ItemSubAffix subAffix = Utils.randomElement(this.subAffixes);
|
||||
subAffix.incrementCount();
|
||||
}
|
||||
|
||||
public int getTotalSubAffixCount() {
|
||||
if (this.subAffixes == null) return 0;
|
||||
|
||||
return this.subAffixes
|
||||
.stream()
|
||||
.reduce(0, (subtotal, subAffix) -> subtotal + subAffix.getCount(), Integer::sum);
|
||||
}
|
||||
|
||||
// Database
|
||||
|
||||
@@ -277,4 +285,5 @@ public class GameItem {
|
||||
.setPromotion(this.getPromotion())
|
||||
.setUniqueId(this.getInternalUid());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user