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) { if (this.getLevel() > 0) {
item.setLevel(Math.min(this.getLevel(), 80)); item.setLevel(Math.min(this.getLevel(), 80));
item.setPromotion(Utils.getMinPromotionForLevel(item.getLevel())); item.setPromotion(Utils.getMinPromotionForLevel(item.getLevel()));
hasChanged = true;
} }
// Try to set promotion // Try to set promotion
if (this.getPromotion() >= 0) { if (this.getPromotion() >= 0) {
item.setPromotion(Math.min(this.getPromotion(), item.getExcel().getEquipmentExcel().getMaxPromotion())); item.setPromotion(Math.min(this.getPromotion(), item.getExcel().getEquipmentExcel().getMaxPromotion()));
hasChanged = true;
} }
// Try to set rank (superimposition) // Try to set rank (superimposition)
if (this.getRank() >= 0) { if (this.getRank() >= 0) {
item.setRank(Math.min(this.getRank(), item.getExcel().getEquipmentExcel().getMaxRank())); item.setRank(Math.min(this.getRank(), item.getExcel().getEquipmentExcel().getMaxRank()));
hasChanged = true;
} }
} else if (item.getExcel().isRelic()) { } else if (item.getExcel().isRelic()) {
// Try to set level // Try to set level
if (this.getLevel() > 0) { if (this.getLevel() > 0) {
int oldLevel = item.getLevel();
int upgrades = 0;
item.setLevel(Math.min(this.getLevel(), 15)); 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) { if (itemData.getItemMainType() == ItemMainType.AvatarCard) {
// Add avatar // Add avatar
GameAvatar avatar = new GameAvatar(itemData.getId()); GameAvatar avatar = new GameAvatar(itemData.getId());
args.setProperties(avatar);
if (args.getTarget().addAvatar(avatar)) { args.getTarget().addAvatar(avatar);
// Change avatar properties
args.setProperties(avatar);
}
} else if (itemData.isEquippable()) { } else if (itemData.isEquippable()) {
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
GameItem item = new GameItem(itemData); GameItem item = new GameItem(itemData);
args.setProperties(item);
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()));
}
}
items.add(item); items.add(item);
} }

View File

@@ -207,6 +207,14 @@ public class GameItem {
subAffix.incrementCount(); 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 // Database
public void save() { public void save() {
@@ -277,4 +285,5 @@ public class GameItem {
.setPromotion(this.getPromotion()) .setPromotion(this.getPromotion())
.setUniqueId(this.getInternalUid()); .setUniqueId(this.getInternalUid());
} }
} }