From 38645e116780db70c5adb5ef926cc641d07afca3 Mon Sep 17 00:00:00 2001 From: Polivox Date: Fri, 12 Dec 2025 09:56:14 +0200 Subject: [PATCH] Fix for staffmod level requirement eval --- pkg/data/skill/skillreq_gen.go | 377 +++++++++++++++++++++++++++++++++ pkg/memory/item.go | 39 ++++ 2 files changed, 416 insertions(+) create mode 100644 pkg/data/skill/skillreq_gen.go diff --git a/pkg/data/skill/skillreq_gen.go b/pkg/data/skill/skillreq_gen.go new file mode 100644 index 0000000..0955a6e --- /dev/null +++ b/pkg/data/skill/skillreq_gen.go @@ -0,0 +1,377 @@ +package skill + +var SkillLevelReq = map[ID]int{ + 0: 1, + 1: 1, + 2: 1, + 3: 1, + 4: 1, + 5: 1, + 6: 1, + 7: 1, + 8: 1, + 9: 1, + 10: 1, + 11: 6, + 12: 6, + 13: 6, + 14: 6, + 15: 6, + 16: 12, + 17: 12, + 18: 12, + 19: 12, + 20: 12, + 21: 18, + 22: 18, + 23: 18, + 24: 18, + 25: 18, + 26: 24, + 27: 24, + 28: 24, + 29: 24, + 30: 24, + 31: 30, + 32: 30, + 33: 30, + 34: 30, + 35: 30, + 36: 1, + 37: 1, + 38: 1, + 39: 1, + 40: 1, + 41: 6, + 42: 6, + 43: 6, + 44: 6, + 45: 6, + 46: 12, + 47: 12, + 48: 12, + 49: 12, + 50: 12, + 51: 18, + 52: 18, + 53: 18, + 54: 18, + 55: 18, + 56: 24, + 57: 24, + 58: 24, + 59: 24, + 60: 24, + 61: 30, + 62: 30, + 63: 30, + 64: 30, + 65: 30, + 66: 1, + 67: 1, + 68: 1, + 69: 1, + 70: 1, + 71: 6, + 72: 6, + 73: 6, + 74: 6, + 75: 6, + 76: 12, + 77: 12, + 78: 12, + 79: 12, + 80: 12, + 81: 18, + 82: 18, + 83: 18, + 84: 18, + 85: 18, + 86: 24, + 87: 24, + 88: 24, + 89: 24, + 90: 24, + 91: 30, + 92: 30, + 93: 30, + 94: 30, + 95: 30, + 96: 1, + 97: 1, + 98: 1, + 99: 1, + 100: 1, + 101: 6, + 102: 6, + 103: 6, + 104: 6, + 105: 6, + 106: 12, + 107: 12, + 108: 12, + 109: 12, + 110: 12, + 111: 18, + 112: 18, + 113: 18, + 114: 18, + 115: 18, + 116: 24, + 117: 24, + 118: 24, + 119: 24, + 120: 24, + 121: 30, + 122: 30, + 123: 30, + 124: 30, + 125: 30, + 126: 1, + 127: 1, + 128: 1, + 129: 1, + 130: 1, + 131: 1, + 132: 6, + 133: 6, + 134: 6, + 135: 6, + 136: 6, + 137: 6, + 138: 6, + 139: 12, + 140: 12, + 141: 12, + 142: 12, + 143: 18, + 144: 18, + 145: 18, + 146: 18, + 147: 24, + 148: 24, + 149: 24, + 150: 24, + 151: 30, + 152: 30, + 153: 30, + 154: 30, + 155: 30, + 156: 1, + 157: 1, + 158: 1, + 159: 1, + 160: 1, + 161: 1, + 162: 1, + 163: 1, + 164: 1, + 165: 1, + 166: 1, + 167: 1, + 168: 1, + 169: 1, + 170: 1, + 171: 1, + 172: 1, + 173: 1, + 174: 1, + 175: 1, + 176: 1, + 177: 1, + 178: 1, + 179: 1, + 180: 1, + 181: 1, + 182: 1, + 183: 1, + 184: 1, + 185: 1, + 186: 1, + 187: 1, + 188: 1, + 189: 1, + 190: 1, + 191: 1, + 192: 1, + 193: 1, + 194: 1, + 195: 1, + 196: 1, + 197: 1, + 198: 1, + 199: 1, + 200: 1, + 201: 1, + 202: 1, + 203: 1, + 204: 1, + 205: 1, + 206: 1, + 207: 1, + 208: 1, + 209: 1, + 210: 1, + 211: 1, + 212: 1, + 213: 1, + 214: 1, + 215: 1, + 216: 1, + 217: 1, + 218: 1, + 219: 1, + 220: 1, + 221: 1, + 222: 1, + 223: 1, + 224: 1, + 225: 1, + 226: 6, + 227: 6, + 228: 6, + 229: 6, + 230: 6, + 231: 12, + 232: 12, + 233: 12, + 234: 12, + 235: 12, + 236: 18, + 237: 18, + 238: 18, + 239: 18, + 240: 18, + 241: 24, + 242: 24, + 243: 24, + 244: 24, + 245: 24, + 246: 30, + 247: 30, + 248: 30, + 249: 30, + 250: 30, + 251: 1, + 252: 1, + 253: 1, + 254: 1, + 255: 1, + 256: 6, + 257: 6, + 258: 6, + 259: 6, + 260: 6, + 261: 12, + 262: 12, + 263: 12, + 264: 12, + 265: 12, + 266: 18, + 267: 18, + 268: 18, + 269: 18, + 270: 18, + 271: 24, + 272: 24, + 273: 24, + 274: 24, + 275: 24, + 276: 30, + 277: 30, + 278: 30, + 279: 30, + 280: 30, + 281: 1, + 282: 1, + 283: 1, + 284: 1, + 285: 1, + 286: 1, + 287: 1, + 288: 1, + 289: 1, + 290: 1, + 291: 1, + 292: 1, + 293: 1, + 294: 1, + 295: 1, + 296: 1, + 297: 1, + 298: 1, + 299: 1, + 300: 1, + 301: 1, + 302: 1, + 303: 1, + 304: 1, + 305: 1, + 306: 1, + 307: 1, + 308: 1, + 309: 1, + 310: 1, + 311: 1, + 312: 1, + 313: 1, + 314: 1, + 315: 1, + 316: 1, + 317: 1, + 318: 1, + 319: 1, + 320: 1, + 321: 1, + 322: 1, + 323: 1, + 324: 1, + 325: 1, + 326: 1, + 327: 1, + 328: 1, + 329: 1, + 330: 1, + 331: 1, + 332: 1, + 333: 1, + 334: 1, + 335: 1, + 336: 1, + 337: 1, + 338: 1, + 339: 1, + 340: 1, + 341: 1, + 342: 1, + 343: 1, + 344: 1, + 345: 1, + 346: 1, + 347: 1, + 348: 1, + 349: 1, + 350: 1, + 351: 1, + 352: 1, + 353: 1, + 354: 1, + 355: 1, + 356: 1, + 357: 1, + 358: 1, + 359: 1, + 360: 1, + 361: 0, + 362: 0, + 363: 0, + 364: 0, + 365: 18, + 366: 6, + 367: 18, + 368: 6, + 369: 24, + 370: 1, + 371: 1, + 372: 1, +} diff --git a/pkg/memory/item.go b/pkg/memory/item.go index 80e3f05..4c79d2f 100644 --- a/pkg/memory/item.go +++ b/pkg/memory/item.go @@ -7,6 +7,7 @@ import ( "github.com/hectorgimenez/d2go/pkg/data" "github.com/hectorgimenez/d2go/pkg/data/item" + "github.com/hectorgimenez/d2go/pkg/data/skill" "github.com/hectorgimenez/d2go/pkg/data/stat" "github.com/hectorgimenez/d2go/pkg/data/state" "github.com/hectorgimenez/d2go/pkg/utils" @@ -633,6 +634,39 @@ func updateMaxReqFromAffixes(currentMax int, affixes data.ItemAffixes) int { } return maxReq } + +func staffModLevelRequirement(itm *data.Item, baseDesc item.Description) int { + eligibleTypes := map[string]bool{ + item.TypeScepter: true, + item.TypeWand: true, + item.TypeStaff: true, + item.TypeHandtoHand: true, + item.TypeHandtoHand2: true, + item.TypePelt: true, + item.TypePrimalHelm: true, + } + + if !eligibleTypes[baseDesc.Type] { + return 0 + } + + maxReq := 0 + checkStats := func(stats stat.Stats) { + for _, s := range stats { + if s.ID == stat.SingleSkill { + if req, ok := skill.SkillLevelReq[skill.ID(s.Layer)]; ok && req > maxReq { + maxReq = req + } + } + } + } + + checkStats(itm.BaseStats) + checkStats(itm.Stats) + + return maxReq +} + func calculateItemLevelReq(itm *data.Item, baseDesc item.Description) int { // Start with base item's requirement maxReq := baseDesc.RequiredLevel @@ -735,5 +769,10 @@ func calculateItemLevelReq(itm *data.Item, baseDesc item.Description) int { } } } + + if staffModReq := staffModLevelRequirement(itm, baseDesc); staffModReq > maxReq { + maxReq = staffModReq + } + return maxReq }