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

@@ -70,6 +70,10 @@ public class GameItem {
} }
public GameItem(ItemExcel excel, int count) { public GameItem(ItemExcel excel, int count) {
this(excel, count, 0);
}
public GameItem(ItemExcel excel, int count, int overrideMainAffix) {
this.itemId = excel.getId(); this.itemId = excel.getId();
this.excel = excel; this.excel = excel;
@@ -87,10 +91,14 @@ public class GameItem {
// Init affixes // Init affixes
if (getExcel().getRelicExcel() != null) { if (getExcel().getRelicExcel() != null) {
// Main affix // Main affix
if (overrideMainAffix > 0) {
this.mainAffix = overrideMainAffix;
} else {
var affix = GameDepot.getRandomRelicMainAffix(getExcel().getRelicExcel().getMainAffixGroup()); var affix = GameDepot.getRandomRelicMainAffix(getExcel().getRelicExcel().getMainAffixGroup());
if (affix != null) { if (affix != null) {
this.mainAffix = affix.getAffixID(); this.mainAffix = affix.getAffixID();
} }
}
// Sub affixes // Sub affixes
int baseSubAffixes = Math.min(Math.max(getExcel().getRarity().getVal() - 2, 0), 3); int baseSubAffixes = Math.min(Math.max(getExcel().getRarity().getVal() - 2, 0), 3);
this.addSubAffixes(Utils.randomRange(baseSubAffixes, baseSubAffixes + 1)); this.addSubAffixes(Utils.randomRange(baseSubAffixes, baseSubAffixes + 1));

View File

@@ -606,12 +606,20 @@ public class InventoryService extends BaseGameService {
return null; return null;
} }
// Get relic excel
ItemExcel itemExcel = GameData.getItemExcelMap().get(relicId);
if (itemExcel == null) {
return null;
}
// Build cost items // Build cost items
List<ItemParam> costItems = new ArrayList<>(); List<ItemParam> costItems = new ArrayList<>();
costItems.addAll(excel.getMaterialCost()); costItems.addAll(excel.getMaterialCost());
// Check main affix // Check main affix
if (mainAffix > 0) { if (mainAffix > 0) {
// TODO verify main affix on item
for (int specialId : excel.getSpecialMaterialCost()) { for (int specialId : excel.getSpecialMaterialCost()) {
costItems.add(new ItemParam(specialId, 1)); costItems.add(new ItemParam(specialId, 1));
} }
@@ -630,12 +638,7 @@ public class InventoryService extends BaseGameService {
List<GameItem> items = new ArrayList<>(); List<GameItem> items = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
GameItem item = new GameItem(relicId, 1); GameItem item = new GameItem(itemExcel, 1, mainAffix);
if (mainAffix > 0) {
item.setMainAffix(mainAffix);
}
items.add(item); items.add(item);
} }