┌─ GO ───────────────────────────────────────────────────────────────────────┐
│ package wow │
│ │
│ // SpecInfo represents class and spec information │
│ type SpecInfo struct { │
│ ClassName string │
│ SpecName string │
│ } │
│ │
│ // SpecByID maps spec IDs to their class and spec names │
│ var SpecByID = map[int]SpecInfo{ │
│ // Tanks │
│ 73: {ClassName: "Warrior", SpecName: "Protection"}, │
│ 104: {ClassName: "Druid", SpecName: "Guardian"}, │
│ 250: {ClassName: "Death Knight", SpecName: "Blood"}, │
│ 268: {ClassName: "Monk", SpecName: "Brewmaster"}, │
│ 66: {ClassName: "Paladin", SpecName: "Protection"}, │
│ // Healers │
│ 105: {ClassName: "Druid", SpecName: "Restoration"}, │
│ 270: {ClassName: "Monk", SpecName: "Mistweaver"}, │
│ 65: {ClassName: "Paladin", SpecName: "Holy"}, │
│ 256: {ClassName: "Priest", SpecName: "Discipline"}, │
│ 257: {ClassName: "Priest", SpecName: "Holy"}, │
│ 264: {ClassName: "Shaman", SpecName: "Restoration"}, │
│ // DPS - Warriors │
│ 71: {ClassName: "Warrior", SpecName: "Arms"}, │
│ 72: {ClassName: "Warrior", SpecName: "Fury"}, │
│ // DPS - Paladins │
│ 70: {ClassName: "Paladin", SpecName: "Retribution"}, │
│ // DPS - Hunters │
│ 253: {ClassName: "Hunter", SpecName: "Beast Mastery"}, │
│ 254: {ClassName: "Hunter", SpecName: "Marksmanship"}, │
│ 255: {ClassName: "Hunter", SpecName: "Survival"}, │
│ // DPS - Rogues │
│ 259: {ClassName: "Rogue", SpecName: "Assassination"}, │
│ 260: {ClassName: "Rogue", SpecName: "Combat"}, │
│ 261: {ClassName: "Rogue", SpecName: "Subtlety"}, │
│ // DPS - Priests │
│ 258: {ClassName: "Priest", SpecName: "Shadow"}, │
│ // DPS - Death Knights │
│ 251: {ClassName: "Death Knight", SpecName: "Frost"}, │
│ 252: {ClassName: "Death Knight", SpecName: "Unholy"}, │
│ // DPS - Shamans │
│ 262: {ClassName: "Shaman", SpecName: "Elemental"}, │
│ 263: {ClassName: "Shaman", SpecName: "Enhancement"}, │
│ // DPS - Mages │
│ 62: {ClassName: "Mage", SpecName: "Arcane"}, │
│ 63: {ClassName: "Mage", SpecName: "Fire"}, │
│ 64: {ClassName: "Mage", SpecName: "Frost"}, │
│ // DPS - Warlocks │
│ 265: {ClassName: "Warlock", SpecName: "Affliction"}, │
│ 266: {ClassName: "Warlock", SpecName: "Demonology"}, │
│ 267: {ClassName: "Warlock", SpecName: "Destruction"}, │
│ // DPS - Monks │
│ 269: {ClassName: "Monk", SpecName: "Windwalker"}, │
│ // DPS - Druids │
│ 102: {ClassName: "Druid", SpecName: "Balance"}, │
│ 103: {ClassName: "Druid", SpecName: "Feral"}, │
│ } │
│ │
│ var specClassIDs = map[int]int{ │
│ 73: 1, │
│ 71: 1, │
│ 72: 1, │
│ 66: 2, │
│ 65: 2, │
│ 70: 2, │
│ 253: 3, │
│ 254: 3, │
│ 255: 3, │
│ 259: 4, │
│ 260: 4, │
│ 261: 4, │
│ 256: 5, │
│ 257: 5, │
│ 258: 5, │
│ 250: 6, │
│ 251: 6, │
│ 252: 6, │
│ 262: 7, │
│ 263: 7, │
│ 264: 7, │
│ 62: 8, │
│ 63: 8, │
│ 64: 8, │
│ 265: 9, │
│ 266: 9, │
│ 267: 9, │
│ 268: 10, │
│ 269: 10, │
│ 270: 10, │
│ 102: 11, │
│ 103: 11, │
│ 104: 11, │
│ 105: 11, │
│ } │
│ │
│ // GetClassAndSpec returns the class and spec name for a given spec ID. │
│ // Returns empty strings and false if the spec ID is not found. │
│ func GetClassAndSpec(specID int) (className, specName string, ok bool) { │
│ info, exists := SpecByID[specID] │
│ if !exists { │
│ return "", "", false │
│ } │
│ return info.ClassName, info.SpecName, true │
│ } │
│ │
│ // FallbackClassAndSpec attempts to populate missing class/spec fields using the s │
│ pec ID. │
│ // If both className and specName are already set, returns them unchanged. │
│ // If specID is nil, returns the original values. │
│ func FallbackClassAndSpec(className, specName string, specID *int) (string, string │
│ ) { │
│ // If both are already populated, nothing to do │
│ if className != "" && specName != "" { │
│ return className, specName │
│ } │
│ │
│ // If no spec ID available, can't fallback │
│ if specID == nil { │
│ return className, specName │
│ } │
│ │
│ // Try to get from spec ID │
│ cls, spec, ok := GetClassAndSpec(*specID) │
│ if !ok { │
│ return className, specName │
│ } │
│ │
│ // Fill in missing fields │
│ if className == "" { │
│ className = cls │
│ } │
│ if specName == "" { │
│ specName = spec │
│ } │
│ │
│ return className, specName │
│ } │
│ │
│ // GetClassIDForSpec returns the numeric class ID for a spec ID. │
│ func GetClassIDForSpec(specID int) (int, bool) { │
│ classID, ok := specClassIDs[specID] │
│ return classID, ok │
│ } │
│ │
│ // the primary stat each spec gears for in MoP, used by the gear generator │
│ // to drop players (and individual items) whose primary stat doesn't match │
│ // the spec they're tagged as │
│ type PrimaryStat string │
│ │
│ const ( │
│ PrimaryStatStr PrimaryStat = "str" │
│ PrimaryStatAgi PrimaryStat = "agi" │
│ PrimaryStatInt PrimaryStat = "int" │
│ ) │
│ │
│ var specPrimaryStat = map[int]PrimaryStat{ │
│ // death knight - all str │
│ 250: PrimaryStatStr, 251: PrimaryStatStr, 252: PrimaryStatStr, │
│ // druid - Balance/Resto int, Feral/Guardian agi │
│ 102: PrimaryStatInt, 103: PrimaryStatAgi, 104: PrimaryStatAgi, 105: PrimaryStatIn │
│ t, │
│ // hunter - all agi │
│ 253: PrimaryStatAgi, 254: PrimaryStatAgi, 255: PrimaryStatAgi, │
│ // mage - all int │
│ 62: PrimaryStatInt, 63: PrimaryStatInt, 64: PrimaryStatInt, │
│ // monk - Brewmaster/Windwalker agi, Mistweaver int │
│ 268: PrimaryStatAgi, 269: PrimaryStatAgi, 270: PrimaryStatInt, │
│ // paladin - Holy int, Prot/Ret str │
│ 65: PrimaryStatInt, 66: PrimaryStatStr, 70: PrimaryStatStr, │
│ // priest - all int │
│ 256: PrimaryStatInt, 257: PrimaryStatInt, 258: PrimaryStatInt, │
│ // rogue - all agi │
│ 259: PrimaryStatAgi, 260: PrimaryStatAgi, 261: PrimaryStatAgi, │
│ // shaman - Resto/Ele int, Enh agi │
│ 262: PrimaryStatInt, 263: PrimaryStatAgi, 264: PrimaryStatInt, │
│ // warlock - all int │
│ 265: PrimaryStatInt, 266: PrimaryStatInt, 267: PrimaryStatInt, │
│ // warrior - all str │
│ 71: PrimaryStatStr, 72: PrimaryStatStr, 73: PrimaryStatStr, │
│ } │
│ │
│ // GetPrimaryStat returns the primary stat the given spec gears for. │
│ func GetPrimaryStat(specID int) (PrimaryStat, bool) { │
│ s, ok := specPrimaryStat[specID] │
│ return s, ok │
│ } │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ GO ─────────────────────────────────┐
│ package wow │
│ │
│ // SpecInfo represents class and spec inform │
│ ation │
│ type SpecInfo struct { │
│ ClassName string │
│ SpecName string │
│ } │
│ │
│ // SpecByID maps spec IDs to their class and │
│ spec names │
│ var SpecByID = map[int]SpecInfo{ │
│ // Tanks │
│ 73: {ClassName: "Warrior", SpecName: "Prot │
│ ection"}, │
│ 104: {ClassName: "Druid", SpecName: "Guardi │
│ an"}, │
│ 250: {ClassName: "Death Knight", SpecName: │
│ "Blood"}, │
│ 268: {ClassName: "Monk", SpecName: "Brewmas │
│ ter"}, │
│ 66: {ClassName: "Paladin", SpecName: "Prot │
│ ection"}, │
│ // Healers │
│ 105: {ClassName: "Druid", SpecName: "Restor │
│ ation"}, │
│ 270: {ClassName: "Monk", SpecName: "Mistwea │
│ ver"}, │
│ 65: {ClassName: "Paladin", SpecName: "Holy │
│ "}, │
│ 256: {ClassName: "Priest", SpecName: "Disci │
│ pline"}, │
│ 257: {ClassName: "Priest", SpecName: "Holy" │
│ }, │
│ 264: {ClassName: "Shaman", SpecName: "Resto │
│ ration"}, │
│ // DPS - Warriors │
│ 71: {ClassName: "Warrior", SpecName: "Arms" │
│ }, │
│ 72: {ClassName: "Warrior", SpecName: "Fury" │
│ }, │
│ // DPS - Paladins │
│ 70: {ClassName: "Paladin", SpecName: "Retri │
│ bution"}, │
│ // DPS - Hunters │
│ 253: {ClassName: "Hunter", SpecName: "Beast │
│ Mastery"}, │
│ 254: {ClassName: "Hunter", SpecName: "Marks │
│ manship"}, │
│ 255: {ClassName: "Hunter", SpecName: "Survi │
│ val"}, │
│ // DPS - Rogues │
│ 259: {ClassName: "Rogue", SpecName: "Assass │
│ ination"}, │
│ 260: {ClassName: "Rogue", SpecName: "Combat │
│ "}, │
│ 261: {ClassName: "Rogue", SpecName: "Subtle │
│ ty"}, │
│ // DPS - Priests │
│ 258: {ClassName: "Priest", SpecName: "Shado │
│ w"}, │
│ // DPS - Death Knights │
│ 251: {ClassName: "Death Knight", SpecName: │
│ "Frost"}, │
│ 252: {ClassName: "Death Knight", SpecName: │
│ "Unholy"}, │
│ // DPS - Shamans │
│ 262: {ClassName: "Shaman", SpecName: "Eleme │
│ ntal"}, │
│ 263: {ClassName: "Shaman", SpecName: "Enhan │
│ cement"}, │
│ // DPS - Mages │
│ 62: {ClassName: "Mage", SpecName: "Arcane"} │
│ , │
│ 63: {ClassName: "Mage", SpecName: "Fire"}, │
│ 64: {ClassName: "Mage", SpecName: "Frost"}, │
│ // DPS - Warlocks │
│ 265: {ClassName: "Warlock", SpecName: "Affl │
│ iction"}, │
│ 266: {ClassName: "Warlock", SpecName: "Demo │
│ nology"}, │
│ 267: {ClassName: "Warlock", SpecName: "Dest │
│ ruction"}, │
│ // DPS - Monks │
│ 269: {ClassName: "Monk", SpecName: "Windwal │
│ ker"}, │
│ // DPS - Druids │
│ 102: {ClassName: "Druid", SpecName: "Balanc │
│ e"}, │
│ 103: {ClassName: "Druid", SpecName: "Feral" │
│ }, │
│ } │
│ │
│ var specClassIDs = map[int]int{ │
│ 73: 1, │
│ 71: 1, │
│ 72: 1, │
│ 66: 2, │
│ 65: 2, │
│ 70: 2, │
│ 253: 3, │
│ 254: 3, │
│ 255: 3, │
│ 259: 4, │
│ 260: 4, │
│ 261: 4, │
│ 256: 5, │
│ 257: 5, │
│ 258: 5, │
│ 250: 6, │
│ 251: 6, │
│ 252: 6, │
│ 262: 7, │
│ 263: 7, │
│ 264: 7, │
│ 62: 8, │
│ 63: 8, │
│ 64: 8, │
│ 265: 9, │
│ 266: 9, │
│ 267: 9, │
│ 268: 10, │
│ 269: 10, │
│ 270: 10, │
│ 102: 11, │
│ 103: 11, │
│ 104: 11, │
│ 105: 11, │
│ } │
│ │
│ // GetClassAndSpec returns the class and spe │
│ c name for a given spec ID. │
│ // Returns empty strings and false if the sp │
│ ec ID is not found. │
│ func GetClassAndSpec(specID int) (className, │
│ specName string, ok bool) { │
│ info, exists := SpecByID[specID] │
│ if !exists { │
│ return "", "", false │
│ } │
│ return info.ClassName, info.SpecName, true │
│ } │
│ │
│ // FallbackClassAndSpec attempts to populate │
│ missing class/spec fields using the spec ID │
│ . │
│ // If both className and specName are alread │
│ y set, returns them unchanged. │
│ // If specID is nil, returns the original va │
│ lues. │
│ func FallbackClassAndSpec(className, specNam │
│ e string, specID *int) (string, string) { │
│ // If both are already populated, nothing t │
│ o do │
│ if className != "" && specName != "" { │
│ return className, specName │
│ } │
│ │
│ // If no spec ID available, can't fallback │
│ if specID == nil { │
│ return className, specName │
│ } │
│ │
│ // Try to get from spec ID │
│ cls, spec, ok := GetClassAndSpec(*specID) │
│ if !ok { │
│ return className, specName │
│ } │
│ │
│ // Fill in missing fields │
│ if className == "" { │
│ className = cls │
│ } │
│ if specName == "" { │
│ specName = spec │
│ } │
│ │
│ return className, specName │
│ } │
│ │
│ // GetClassIDForSpec returns the numeric cla │
│ ss ID for a spec ID. │
│ func GetClassIDForSpec(specID int) (int, boo │
│ l) { │
│ classID, ok := specClassIDs[specID] │
│ return classID, ok │
│ } │
│ │
│ // the primary stat each spec gears for in M │
│ oP, used by the gear generator │
│ // to drop players (and individual items) wh │
│ ose primary stat doesn't match │
│ // the spec they're tagged as │
│ type PrimaryStat string │
│ │
│ const ( │
│ PrimaryStatStr PrimaryStat = "str" │
│ PrimaryStatAgi PrimaryStat = "agi" │
│ PrimaryStatInt PrimaryStat = "int" │
│ ) │
│ │
│ var specPrimaryStat = map[int]PrimaryStat{ │
│ // death knight - all str │
│ 250: PrimaryStatStr, 251: PrimaryStatStr, 2 │
│ 52: PrimaryStatStr, │
│ // druid - Balance/Resto int, Feral/Guardia │
│ n agi │
│ 102: PrimaryStatInt, 103: PrimaryStatAgi, 1 │
│ 04: PrimaryStatAgi, 105: PrimaryStatInt, │
│ // hunter - all agi │
│ 253: PrimaryStatAgi, 254: PrimaryStatAgi, 2 │
│ 55: PrimaryStatAgi, │
│ // mage - all int │
│ 62: PrimaryStatInt, 63: PrimaryStatInt, 64: │
│ PrimaryStatInt, │
│ // monk - Brewmaster/Windwalker agi, Mistwe │
│ aver int │
│ 268: PrimaryStatAgi, 269: PrimaryStatAgi, 2 │
│ 70: PrimaryStatInt, │
│ // paladin - Holy int, Prot/Ret str │
│ 65: PrimaryStatInt, 66: PrimaryStatStr, 70: │
│ PrimaryStatStr, │
│ // priest - all int │
│ 256: PrimaryStatInt, 257: PrimaryStatInt, 2 │
│ 58: PrimaryStatInt, │
│ // rogue - all agi │
│ 259: PrimaryStatAgi, 260: PrimaryStatAgi, 2 │
│ 61: PrimaryStatAgi, │
│ // shaman - Resto/Ele int, Enh agi │
│ 262: PrimaryStatInt, 263: PrimaryStatAgi, 2 │
│ 64: PrimaryStatInt, │
│ // warlock - all int │
│ 265: PrimaryStatInt, 266: PrimaryStatInt, 2 │
│ 67: PrimaryStatInt, │
│ // warrior - all str │
│ 71: PrimaryStatStr, 72: PrimaryStatStr, 73: │
│ PrimaryStatStr, │
│ } │
│ │
│ // GetPrimaryStat returns the primary stat t │
│ he given spec gears for. │
│ func GetPrimaryStat(specID int) (PrimaryStat │
│ , bool) { │
│ s, ok := specPrimaryStat[specID] │
│ return s, ok │
│ } │
└──────────────────────────────────────────────┘