wow-prof-calculator.py

mail@pastecode.io avatar
unknown
python
a month ago
11 kB
3
Indexable
Never
#!/usr/bin/python
import math
import sys

MODES = ["ench", "tailor", "faid"]

recipes = {
    #####################################################
    "ench": [
        {
            "name": "Bracer - Minor Stamina",
            "dfty": " 50  100  120  140",
            "cost": 15,
            "item-name": "[Strange Dust]",
        },
        {
            "name": "Bracer - Minor Deflect",
            "dfty": "1 80  100  120",
            "cost": 12,
            "item-name": "[Strange Dust]",
        },
        {
            "name": "Bracer - Minor Health",
            "dfty": "1 70  90  110",
            "cost": 5,
            "item-name": "[Strange Dust]",
        },
        {
            "name": "Greater Magic Wand",
            "dfty": "70  110  130  150",
            "cost": 17,
            "item-name": "[G. Astral]",
        },
        {
            "name": "Bracer - Lesser Strength",
            "dfty": "140  165  185  205",
            "cost": 2,
            "item-name": "[Soul Dust]",
        },
        {
            "name": "Bracer +5 STR",
            "dfty": "180  200  220  240",
            "cost": 1,
            "item-name": "[Vision Dust]",
        },
        {
            "name": "Cloak +50 DEF",
            "dfty": "205  225  245  265",
            "cost": 3,
            "item-name": "[Vision Dust]",
        },
        {
            "name": "Boots +5 STAM",
            "dfty": "215 235 255 275",
            "cost": 5,
            "item-name": "[Vision Dust]",
        },
        {
            "name": "Chest +50 Health",
            "dfty": "220 240 260 280",
            "cost": 6,
            "item-name": "[Vision Dust]",
        },
        ######################## Dream Dust ############################
        {
            "name": "Bracer - Greater Stamina",
            "dfty": "245  265  285  305",
            "cost": 5,
            "item-name": "[Dream Dust]",
        },
        {
            "name": "Lesser Mana Oil",
            "dfty": "250  260  270  280",
            "cost": 4.5,
            "item-name": "[Dream Dust]",
        },
        {
            "name": "Boots - Greater Stamina",
            "dfty": "260  280  300  320",
            "cost": 10,
            "item-name": "[Dream Dust]",
        },
        {
            "name": "Shield - Greater Stamina",
            "dfty": "265  285  305  325",
            "cost": 10,
            "item-name": "[Dream Dust]",
        },
        {
            "name": "Wizard Oil",
            "dfty": "275  285  295  305",
            "cost": 3,
            "item-name": "[Illusion Dust]",
        },
        {
            "name": "Cloak - Superior Defense",
            "dfty": "285  305  325  345",
            "cost": 8,
            "item-name": "[Illusion Dust]",
        },
        {
            "name": "Runed Arcanite Rod",
            "dfty": "290 310 330 350",
            "cost": 100,
            "item-name": "[MATS]",
        },
    ],
    #####################################################
    "tailor": [
        {
            "name": "Brown Linen Shirt",
            "dfty": "1 35 47 60",
            "cost": 1,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Brown Linen Vest",
            "dfty": "10 45 57 70",
            "cost": 1,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Linen Belt",
            "dfty": "15 50 67 85",
            "cost": 1,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Reinforced Linen Cape",
            "dfty": "60 85 102 120",
            "cost": 2,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Green Linen Bracers",
            "dfty": "60  85  102  120",
            "cost": 3,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Handstitched Linen Britches",
            "dfty": "70  95  112  130",
            "cost": 4,
            "item-name": "[Bolt of Linen]",
        },
        {
            "name": "Simple Kilt",
            "dfty": "75  100  117  135",
            "cost": 4,
            "item-name": "[Bolt of Linen]",
        },
        ######################## WOOL ############################
        {
            "name": "Woolen Cape",
            "dfty": "75  100  117  135",
            "cost": 1,
            "item-name": "[Bolt of Wool]",
        },
        {
            "name": "Gray Woolen Shirt",
            "dfty": "100  110  120  130",
            "cost": 2,
            "item-name": "[Bolt of Wool]",
        },
        {
            "name": "Double-stitched Woolen Shoulders",
            "dfty": " 110  135  152  170",
            "cost": 3,
            "item-name": "[Bolt of Wool]",
        },
        {
            "name": "Azure Silk Hood",
            "dfty": "145  155  160  165",
            "cost": 2,
            "item-name": "[Bolt of Silk]",
        },
        {
            "name": "Long Silken Cloak",
            "dfty": "185  205  220  235",
            "cost": 4,
            "item-name": "[Bolt of Silk]",
        },
        {
            "name": "White Bandit Mask",
            "dfty": "215 220 225 230",
            "cost": 1,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Black Mageweave Leggings",
            "dfty": "205 220 235 250",
            "cost": 2,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Black Mageweave Vest",
            "dfty": "205 220 235 250",
            "cost": 2,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Black Mageweave Gloves",
            "dfty": "215 230 245 260",
            "cost": 2,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Red Mageweave Gloves",
            "dfty": " 225  240  255  270",
            "cost": 3,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Black Mageweave Headband",
            "dfty": "230 245 260 275",
            "cost": 3,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Black Mageweave Shoulders",
            "dfty": "230 245 260 275",
            "cost": 3,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Red Mageweave Bag",
            "dfty": "235  250  265  280",
            "cost": 4,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Tuxedo Pants",
            "dfty": "245 250 255 260",
            "cost": 4,
            "item-name": "[Bolt of Mageweave]",
        },
        {
            "name": "Tuxedo Jacket",
            "dfty": "250  265  280  295",
            "cost": 5,
            "item-name": "[Bolt of Mageweave]",
        },
        ######################## RUNECLOTH ############################
        {
            "name": "Runecloth Belt",
            "dfty": "255  270  285  300",
            "cost": 3,
            "item-name": "[Bolt of Runecloth]",
        },
        {
            "name": "Runecloth Bag",
            "dfty": "260  275  290  305",
            "cost": 5,
            "item-name": "[Bolt of Runecloth]",
        },
        {
            "name": "Brightcloth Gloves",
            "dfty": "270  285  300  315",
            "cost": 4,
            "item-name": "[Bolt of Runecloth]",
        },
        {
            "name": "Runecloth Gloves",
            "dfty": "275  290  305  320",
            "cost": 4,
            "item-name": "[Bolt of Runecloth]",
        },
        {
            "name": "Frostweave Pants",
            "dfty": "280  295  310  325",
            "cost": 6,
            "item-name": "[Bolt of Runecloth]",
        },
        ######################## FELCLOTH ############################
        {
            "name": "Mooncloth",
            "dfty": "250  290  305  320",
            "cost": 2,
            "item-name": "[Felcloth]",
        },
    ],
    "faid": [
        {
            "name": "Linen",
            "dfty": "1  30  45  60",
            "cost": 1,
            "item-name": "[Linen]",
        },
        {
            "name": "Heavy Linen",
            "dfty": "40  50  75  100",
            "cost": 2,
            "item-name": "[Linen]",
        },
    ],
}

# fix string-list into int-list
for rs in recipes.values():
    for r in rs:
        s = r['dfty'].split(" ")
        l = []
        for i in s:
            if not i.isdecimal():
                for si in i.split(","):
                    if si.isdecimal():
                        l.append(int(si))
            else:
                l.append(int(i))
        r['dfty'] = l

SKILL = 232
TARGET_SKILL = 250
#MIN_CHANCE = 74
MIN_CHANCE = None
total = 0
mch = 1

if len(sys.argv) == 1:
    print("Usage: ./calculator <prof> <start> <end>")
    exit()

MODE = [m for m in MODES if m.startswith(sys.argv[1])][0]

if len(sys.argv) > 2:
    ns = int(sys.argv[2])
    if not 1 <= ns <= 299:
        print(f"Bad starting skill ({ns}), using {SKILL}")
    else:
        SKILL = ns

if len(sys.argv) > 3:
    ns = int(sys.argv[3])
    if not 2 <= ns <= 300:
        print(f"Bad final skill ({ns}), using {TARGET_SKILL}")
    else:
        TARGET_SKILL = ns

recipes = recipes[MODE]
for r in recipes:
    print(f"[{r['cost']}] {r['name']}: {' / '.join(str(i) for i in r['dfty'])}")

print("==========================================")

for s in range(SKILL, TARGET_SKILL):
    mc = 10000
    mi = -1
    bc = -1

    for i, r in enumerate(recipes):
        if s < r['dfty'][0] or s >= r['dfty'][3]:
            #print(f"[{s}] {r['name']} not possible anymore")
            continue

        chance = ((r['dfty'][3]-s) / (r['dfty'][3]-r['dfty'][1]))
        if not 0 <= chance <= 100:
            print("========== BUG WTF ==============")
            exit()

        if MIN_CHANCE != None and chance < MIN_CHANCE/100:
            #print(f"[{s}] {r['name']} below min chance")
            continue

        cost = 1 / chance * r['cost']
        if s < r['dfty'][1]:
            cost = r['cost']
            chance = 1

        if cost < mc or (cost == mc and chance > bc):
            mc = cost
            mi = i
            bc = chance

        print(f"Cost @ {s} for {r['name']} is: {round(cost,2)}, chance: {round(chance*100)}%")
    if bc < mch:
        mch = bc

    print(f"[{s}] {recipes[mi]['name']}, cost: {round(mc,2)} ({round(bc*100)}%)")
    print("-----")
    total += mc

print(f"Total cost: {math.ceil(total)} x {recipes[0]['item-name']}")
if not MIN_CHANCE:
    MIN_CHANCE = int(mch * 100)
print(f"Min chance: {MIN_CHANCE}%")
Leave a Comment