Skip to content

Commit

Permalink
Merge pull request #942 from wowsims/infer_phase
Browse files Browse the repository at this point in the history
Automatic item release phase inference
  • Loading branch information
NerdEgghead authored Aug 19, 2024
2 parents bfa9af8 + bd3d6f4 commit 835dd40
Show file tree
Hide file tree
Showing 6 changed files with 2,871 additions and 2,820 deletions.
Binary file modified assets/database/db.bin
Binary file not shown.
5,618 changes: 2,809 additions & 2,809 deletions assets/database/db.json

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions tools/database/gen_db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"os"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -150,6 +151,11 @@ func main() {
if len(item.RandomSuffixOptions) > 0 {
item.RandPropPoints = randomPropAllocations.CalcItemAllocation(item)
}

// Auto-populate phase information if missing on Wowhead
if item.Phase < 2 {
item.Phase = InferPhase(item)
}
}

for _, spellId := range database.SharedSpellsIcons {
Expand All @@ -175,6 +181,52 @@ func main() {
db.WriteBinaryAndJson(fmt.Sprintf("%s/db.bin", dbDir), fmt.Sprintf("%s/db.json", dbDir))
}

// Uses heuristics on ilvl + source to infer release phase of an item when missing.
func InferPhase(item *proto.UIItem) int32 {
if item.Ilvl <= 352 {
return 1
}

if item.Ilvl >= 397 {
return 4 // Heroic Rag loot should already be tagged correctly by Wowhead.
}

switch item.Ilvl {
case 359, 371, 372, 379:
return 1
case 353:
return 2
case 358, 391:
return 3
case 377:
return 4
case 365:
if strings.Contains(item.Name, "Vicious") {
return 1
}

return 3
case 378:
for _, itemSource := range item.Sources {
dropSource := itemSource.GetDrop()

if (dropSource != nil) && slices.Contains([]int32{5788, 5789, 5844}, dropSource.ZoneId) {
return 4
}
}

return 3
case 384, 390:
if strings.Contains(item.Name, "Ruthless") {
return 3
}

return 4
default:
return 0
}
}

// Filters out entities which shouldn't be included anywhere.
func ApplyGlobalFilters(db *database.WowDatabase) {
db.Items = core.FilterMap(db.Items, func(_ int32, item *proto.UIItem) bool {
Expand Down
11 changes: 3 additions & 8 deletions ui/core/components/gear_picker/item_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,9 @@ export default class ItemList<T extends ItemListType> {
itemIdxs = itemIdxs.filter(i => {
const listItemData = this.itemData[i];

// TODO @1337lutz
// wowhead has implemented most of the firelands items with the appropriate phase (3)
// our code does not take into it consideration as of now, so this needs to be disabled until
// we fix all the gear to have the correct phase and add them as selectable options
//
// if (listItemData.phase > this.player.sim.getPhase()) {
// return false;
// }
if (listItemData.phase > this.player.sim.getPhase()) {
return false;
}

if (!!this.searchInput.value.length) {
const formatQuery = (value: string) => value.toLowerCase().replaceAll(/[^a-zA-Z0-9\s]/g, '');
Expand Down
7 changes: 6 additions & 1 deletion ui/core/components/inputs/other_inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ export function makePhaseSelector(parent: HTMLElement, sim: Sim): EnumPicker<Sim
return new EnumPicker<Sim>(parent, sim, {
id: 'phase-selector',
extraCssClasses: ['phase-selector'],
values: [{ name: 'Phase 1 (Cataclysm)', value: 1 }],
values: [
{ name: 'Phase 1 (Tier 11)', value: 1 },
{ name: 'Phase 2 (ZG/ZA)', value: 2 },
{ name: 'Phase 3 (Firelands)', value: 3},
{ name: 'Phase 4 (Dragon Soul)', value: 4},
],
changedEvent: (sim: Sim) => sim.phaseChangeEmitter,
getValue: (sim: Sim) => sim.getPhase(),
setValue: (eventID: EventID, sim: Sim, newValue: number) => {
Expand Down
3 changes: 1 addition & 2 deletions ui/core/constants/other.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ export enum Phase {
Phase2,
Phase3,
Phase4,
Phase5,
}

export const CURRENT_PHASE = Phase.Phase1;
export const CURRENT_PHASE = Phase.Phase2;

export const CURRENT_API_VERSION: number = readMessageOption(ProtoVersion, "proto.current_version_number")! as number;

Expand Down

0 comments on commit 835dd40

Please sign in to comment.