Fix composed relics having the same sub/main affix sometimes

This commit is contained in:
Melledy
2023-10-23 10:15:13 -07:00
parent 0c6d308b5e
commit 2e579cffd5
2 changed files with 21 additions and 10 deletions

View File

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

View File

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