mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-14 22:34:35 +01:00
Fix composed relics having the same sub/main affix sometimes
This commit is contained in:
@@ -68,8 +68,12 @@ public class GameItem {
|
||||
public GameItem(ItemExcel data) {
|
||||
this(data, 1);
|
||||
}
|
||||
|
||||
|
||||
public GameItem(ItemExcel excel, int count) {
|
||||
this(excel, count, 0);
|
||||
}
|
||||
|
||||
public GameItem(ItemExcel excel, int count, int overrideMainAffix) {
|
||||
this.itemId = excel.getId();
|
||||
this.excel = excel;
|
||||
|
||||
@@ -87,9 +91,13 @@ public class GameItem {
|
||||
// Init affixes
|
||||
if (getExcel().getRelicExcel() != null) {
|
||||
// Main affix
|
||||
var affix = GameDepot.getRandomRelicMainAffix(getExcel().getRelicExcel().getMainAffixGroup());
|
||||
if (affix != null) {
|
||||
this.mainAffix = affix.getAffixID();
|
||||
if (overrideMainAffix > 0) {
|
||||
this.mainAffix = overrideMainAffix;
|
||||
} else {
|
||||
var affix = GameDepot.getRandomRelicMainAffix(getExcel().getRelicExcel().getMainAffixGroup());
|
||||
if (affix != null) {
|
||||
this.mainAffix = affix.getAffixID();
|
||||
}
|
||||
}
|
||||
// Sub affixes
|
||||
int baseSubAffixes = Math.min(Math.max(getExcel().getRarity().getVal() - 2, 0), 3);
|
||||
|
||||
@@ -606,12 +606,20 @@ public class InventoryService extends BaseGameService {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get relic excel
|
||||
ItemExcel itemExcel = GameData.getItemExcelMap().get(relicId);
|
||||
if (itemExcel == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Build cost items
|
||||
List<ItemParam> costItems = new ArrayList<>();
|
||||
costItems.addAll(excel.getMaterialCost());
|
||||
|
||||
// Check main affix
|
||||
if (mainAffix > 0) {
|
||||
// TODO verify main affix on item
|
||||
|
||||
for (int specialId : excel.getSpecialMaterialCost()) {
|
||||
costItems.add(new ItemParam(specialId, 1));
|
||||
}
|
||||
@@ -630,12 +638,7 @@ public class InventoryService extends BaseGameService {
|
||||
List<GameItem> items = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
GameItem item = new GameItem(relicId, 1);
|
||||
|
||||
if (mainAffix > 0) {
|
||||
item.setMainAffix(mainAffix);
|
||||
}
|
||||
|
||||
GameItem item = new GameItem(itemExcel, 1, mainAffix);
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user