mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 15:24:44 +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) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|
||||||
if (args.getTarget().addAvatar(avatar)) {
|
|
||||||
// Change avatar properties
|
|
||||||
args.setProperties(avatar);
|
args.setProperties(avatar);
|
||||||
}
|
args.getTarget().addAvatar(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user