Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Bulk sim issues #741

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions sim/core/bulksim.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,23 +495,8 @@ func isValidEquipment(equipment *proto.EquipmentSpec) bool {
return false
}

// Validate trinkets/rings for duplicate IDs
if equipment.Items[proto.ItemSlot_ItemSlotFinger1].Id == equipment.Items[proto.ItemSlot_ItemSlotFinger2].Id && equipment.Items[proto.ItemSlot_ItemSlotFinger1].Id != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to do this, as the FE UI doesn't allow for unique-equipped duplicates, and this would return as not valid if there's items that are not unique-equipped.

return false
} else if equipment.Items[proto.ItemSlot_ItemSlotTrinket1].Id == equipment.Items[proto.ItemSlot_ItemSlotTrinket2].Id && equipment.Items[proto.ItemSlot_ItemSlotTrinket1].Id != 0 {
return false
}

// Validate rings/trinkets for heroic/non-heroic (matching name)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, no need to check all of this.

f1, ok1 := ItemsByID[equipment.Items[proto.ItemSlot_ItemSlotFinger1].Id]
f2, ok2 := ItemsByID[equipment.Items[proto.ItemSlot_ItemSlotFinger2].Id]
if ok1 && ok2 && f1.Name == f2.Name {
return false
}

t1, ok1 := ItemsByID[equipment.Items[proto.ItemSlot_ItemSlotTrinket1].Id]
t2, ok2 := ItemsByID[equipment.Items[proto.ItemSlot_ItemSlotTrinket2].Id]
if ok1 && ok2 && t1.Name == t2.Name {
// Validate trinkets for duplicate IDs
if equipment.Items[proto.ItemSlot_ItemSlotTrinket1].Id == equipment.Items[proto.ItemSlot_ItemSlotTrinket2].Id && equipment.Items[proto.ItemSlot_ItemSlotTrinket1].Id != 0 {
return false
}

Expand Down
33 changes: 27 additions & 6 deletions ui/core/components/individual_sim_ui/bulk_tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ref } from 'tsx-vanilla';
import { REPO_RELEASES_URL } from '../../constants/other';
import { IndividualSimUI } from '../../individual_sim_ui';
import { BulkSettings, ProgressMetrics, TalentLoadout } from '../../proto/api';
import { GemColor, Glyphs, ItemSpec, SimDatabase, SimEnchant, SimGem, SimItem } from '../../proto/common';
import { GemColor, Glyphs, ItemRandomSuffix, ItemSpec, ReforgeStat, SimDatabase, SimEnchant, SimGem, SimItem } from '../../proto/common';
import { SavedTalents, UIEnchant, UIGem, UIItem } from '../../proto/ui';
import { ActionId } from '../../proto_utils/action_id';
import { getEmptyGemSocketIconUrl } from '../../proto_utils/gems';
Expand Down Expand Up @@ -272,6 +272,20 @@ export class BulkTab extends SimTab {
}),
);
}
if (item.randomSuffix) {
itemsDb.randomSuffixes.push(
ItemRandomSuffix.fromJson(ItemRandomSuffix.toJson(item.randomSuffix), {
ignoreUnknownFields: true,
}),
);
}
if (item.reforge) {
itemsDb.reforgeStats.push(
ReforgeStat.fromJson(ReforgeStat.toJson(item.reforge), {
ignoreUnknownFields: true,
}),
);
}
for (const gem of item.gems) {
if (gem) {
itemsDb.gems.push(SimGem.fromJson(UIGem.toJson(gem), { ignoreUnknownFields: true }));
Expand Down Expand Up @@ -400,6 +414,7 @@ export class BulkTab extends SimTab {
try {
await this.simUI.sim.runBulkSim(this.createBulkSettings(), this.createBulkItemsDatabase(), onProgress);
} catch (e) {
this.isPending = false;
this.simUI.handleCrash(e);
}
}
Expand Down Expand Up @@ -480,13 +495,20 @@ export class BulkTab extends SimTab {
for (const r of bulkSimResult.results) {
new BulkSimResultRenderer(this.resultsTabElem, this.simUI, this, r, bulkSimResult.equippedGearResult!);
}
this.isPending = false;
this.resultsTab.show();
});
}

private set isPending(value: boolean) {
if (value) {
this.simUI.rootElem.classList.add('blurred');
this.simUI.rootElem.insertAdjacentElement('afterend', this.pendingDiv);
} else {
this.simUI.rootElem.classList.remove('blurred');
this.pendingDiv.remove();
this.pendingResults.hideAll();

this.resultsTab.show();
});
}
}

protected buildBatchSettings() {
Expand Down Expand Up @@ -520,8 +542,7 @@ export class BulkTab extends SimTab {
});

bulkSimButton.addEventListener('click', () => {
this.simUI.rootElem.classList.add('blurred');
this.simUI.rootElem.insertAdjacentElement('afterend', this.pendingDiv);
this.isPending = true;

let simStart = new Date().getTime();
let lastTotal = 0;
Expand Down
2 changes: 2 additions & 0 deletions ui/core/sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ export class Sim {
playerDatabase.items.push(...bulkItemsDb.items);
playerDatabase.enchants.push(...bulkItemsDb.enchants);
playerDatabase.gems.push(...bulkItemsDb.gems);
playerDatabase.reforgeStats.push(...bulkItemsDb.reforgeStats);
playerDatabase.randomSuffixes.push(...bulkItemsDb.randomSuffixes);

this.bulkSimStartEmitter.emit(TypedEvent.nextEventID(), request);

Expand Down
Loading