Add substats when setting relic level via the give command

This commit is contained in:
Melledy
2023-11-27 06:37:23 -08:00
parent 31d8885b97
commit 488ba43792
3 changed files with 30 additions and 24 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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());
}
}