Beispiel #1
0
    async def search_and_fetch_and_price(mod):
        results_entry = {
            "mod_str": str(mod),
            "mod_json": json.dumps(mod.json())
        }
        mod_stat_filters = StatFilters(filters=mod.to_query_stat_filters())
        query = OfficialApiQuery(
            category=item_class_value,
            corrupted=False,
            indexed="1week",
            mirrored=False,
            rarity="nonunique",
            stat_filters=[mod_stat_filters],
        ).json()

        results = await search_and_fetch_async(query)
        print(results_entry["mod_str"])
        for idx, result in enumerate(results):
            parsed_result = OfficialApiResult(result)
            results_entry[f"price_{idx:02}"] = estimate_price_in_chaos(
                parsed_result.price)

        global results_df
        results_df = results_df.append(results_entry, ignore_index=True)
        return results_entry
def search(query: OfficialApiQuery = None) -> requests.Response:
    query_json = {} if query is None else query.json()
    return requests.post(
        f"{API_SEARCH}/{league_id}",
        headers=USER_AGENT_HEADER,
        json=query_json,
        cookies=dict(POESESSID=poesessid),
    )
def test_default():

    search_json = {
        "query": {
            "status": {"option": "any"},
            "stats": [{"type": "and", "filters": []}],
            "filters": {
                "misc_filters": {"filters": {"alternate_art": {"option": "false"}}}
            },
        },
        "sort": {"price": "asc"},
    }
    assert OfficialApiQuery().json() == search_json
Beispiel #4
0
def create_item_query(option_idx,
                      ilvl,
                      passive_count_min=None,
                      passive_count_max=None):
    return OfficialApiQuery(
        stat_filters=[
            StatFilters(filters=[
                StatFilter("enchant.stat_3948993189", option=option_idx),
                StatFilter(
                    "enchant.stat_3086156145",
                    min=passive_count_min,
                    max=passive_count_max,
                ),
            ]),
        ],
        ilvl_min=ilvl,
        mirrored=False,
        corrupted=False,
        rarity="nonunique",
    )
Beispiel #5
0
def bisect_count_two_mod(query: OfficialApiQuery) -> List[OfficialApiQuery]:
    """"""

    if len(query.stat_filters) == 1:
        assert (query.stat_filters[0].type == "count"
                and query.stat_filters[0].min == 2
                and query.stat_filters[0].max
                == None), "bisect_count_two_mod expects a count filter"

        count_stat_filters = query.stat_filters[0]
        n_filters = len(count_stat_filters.filters)

        if n_filters > 2:
            logging.info(f"Bisecting {n_filters} mods")
            filters = sorted(count_stat_filters.filters,
                             key=lambda x: json.dumps(x.json()))
            left_filters = filters[:n_filters // 2]
            right_filters = filters[n_filters // 2:]

            left_query_copy, right_query_copy = deepcopy(query), deepcopy(
                query)
            left_query_copy.stat_filters[0].filters = left_filters
            right_query_copy.stat_filters[0].filters = right_filters

            cross_query_copy = deepcopy(query)
            cross_query_copy.stat_filters.append(
                StatFilters(filters=deepcopy(left_filters),
                            type="count",
                            min=1))
            cross_query_copy.stat_filters.append(
                StatFilters(filters=deepcopy(right_filters),
                            type="count",
                            min=1))

            return [left_query_copy, cross_query_copy, right_query_copy]
    elif len(query.stat_filters) == 3:
        assert all([
            stat_filter.type == "count" for stat_filter in query.stat_filters
        ])
        assert [stat_filter.min
                for stat_filter in query.stat_filters] == [1, 2, 1]
        assert all(
            [stat_filter.max == None for stat_filter in query.stat_filters])

        left_filters = query.stat_filters[0].filters
        right_filters = query.stat_filters[2].filters

        if len(right_filters) == len(left_filters) == 1:
            return []
        elif len(right_filters) > len(left_filters):
            query.stat_filters[0], query.stat_filters[2] = (
                query.stat_filters[2],
                query.stat_filters[0],
            )

        split_filters = sorted(query.stat_filters[0].filters,
                               key=lambda x: json.dumps(x.json()))
        left_split_filters = split_filters[:len(split_filters) // 2]
        right_split_filters = split_filters[len(split_filters) // 2:]

        left_query = deepcopy(query)
        right_query = deepcopy(query)

        left_query.stat_filters[0].filters = left_split_filters
        right_query.stat_filters[0].filters = right_split_filters

        return [left_query, right_query]
    else:
        raise ValueError("Not a valid bisect partition")
Beispiel #6
0
        "id": 49,
        "text": "+12% to Chaos Resistance"
    },
    {
        "id": 50,
        "text": "1% chance to Dodge Attack Hits"
    },
]

mods = find_affixes(
    OfficialApiQuery(
        stat_filters=[
            StatFilters(filters=[
                StatFilter("enchant.stat_3948993189", option=18),
                StatFilter("enchant.stat_3086156145"),
            ])
        ],
        mirrored=False,
        corrupted=False,
        rarity="nonunique",
    ),
    affix_type="explicit",
)

query = OfficialApiQuery(
    stat_filters=[
        StatFilters(filters=[
            StatFilter("enchant.stat_3948993189", option=18),
            StatFilter("enchant.stat_3086156145"),
        ]),
        StatFilters(
Beispiel #7
0
                    SHIELD="armour.shield",
                    QUIVER="armour.quiver",
                    AMULET="accessory.amulet",
                    BELT="accessory.belt",
                    RING="accessory.ring",
                    BASE_JEWEL="jewel.base",
                    ABYSS_JEWEL="jewel.abyss",
                    CLUSTER_JEWEL="jewel.cluster")

output_str = ""
for item_class_name, item_class_str in item_classes.items():
    print(item_class_name)
    corrupted_implicits = find_affixes(OfficialApiQuery(
        category=item_class_str,
        quality_max=0,
        rarity="unique",
        talisman_tier_max=0,
        synthesised=False,
        corrupted=True,
        stat_filters=[triple_implicit_stat_filter]),
                                       affix_type="implicit")
    uncorrupted_implicits = find_affixes(OfficialApiQuery(
        category=item_class_str,
        quality_max=0,
        rarity="unique",
        talisman_tier_max=0,
        synthesised=False,
        corrupted=False),
                                         affix_type="implicit")
    output_str += item_class_name + "\n"
    for mod in corrupted_implicits.difference(uncorrupted_implicits):
        output_str += str(mod) + "\n"
Beispiel #8
0
    "Titanium Glennach Cairns Watchstone",
    "Titanium Haewark Hamlet Watchstone",
    "Titanium Lex Ejoris Watchstone",
    "Titanium Lex Proxima Watchstone",
    "Titanium Lira Arthain Watchstone",
    "Titanium New Vastir Watchstone",
    "Titanium Tirn's End Watchstone",
    "Titanium Valdo's Rest Watchstone",
]

t = tqdm(watchstones)
for type in t:
    t.set_description(desc=f"watchstone - {type}")

    mods = find_affixes(
        OfficialApiQuery(type=type, identified=True, rarity="nonunique"),
        affix_type="explicit",
    )
    all_query = OfficialApiQuery(
        type=type,
        # identified=True,
        rarity="nonunique",
        # mirrored=False,
        # enchanted=False,
        # corrupted=False,
        indexed="2weeks",
        stat_filters=[
            StatFilters(
                [
                    stat_filter for mod in mods
                    for stat_filter in mod.to_query_stat_filters()
Beispiel #9
0
        ).json()

        results = await search_and_fetch_async(query)
        print(results_entry["mod_str"])
        for idx, result in enumerate(results):
            parsed_result = OfficialApiResult(result)
            results_entry[f"price_{idx:02}"] = estimate_price_in_chaos(
                parsed_result.price)

        global results_df
        results_df = results_df.append(results_entry, ignore_index=True)
        return results_entry

    mods = find_affixes(
        OfficialApiQuery(
            category=item_class_value,
            corrupted=False,
            synthesised=True,
            quality_max=0,
            rarity="nonunique",
        ),
        affix_type="implicit",
    )

    async def main():
        await asyncio.gather(
            *[search_and_fetch_and_price(mod) for mod in mods])
        results_df.to_csv(f"data/synth_prices/{item_class_key}.csv")

    asyncio.run(main())
Beispiel #10
0
results_df = DataFrame()

attr_mod = Mod({
    "name":
    "",
    "tier":
    "",
    "magnitudes": [{
        "hash": "explicit.stat_1379411836",
        "min": 25,
        "max": 30
    }],
})
mods = find_affixes(
    OfficialApiQuery(name="Forbidden Shako",
                     type="Great Crown",
                     identified=True),
    affix_type="explicit",
    exclude_affixes=[attr_mod],
    use_added_filter_for_speed=False,
)

for mod in tqdm(mods):
    results_entry = {"mod_str": str(mod), "mod_json": json.dumps(mod.json())}
    mod_stat_filters = StatFilters(filters=mod.to_query_stat_filters())
    fetch_ids, total, query = search_query(
        OfficialApiQuery(
            name="Forbidden Shako",
            type="Great Crown",
            identified=True,
            corrupted=False,
Beispiel #11
0
    BELT="accessory.belt",
    RING="accessory.ring",
    BASE_JEWEL="jewel.base",
    ABYSS_JEWEL="jewel.abyss",
    CLUSTER_JEWEL="jewel.cluster",
)

t = tqdm(item_classes.items())
for item_class_key, item_class_value in t:
    t.set_description(desc=f"item_classes - {item_class_key}")

    mods = find_affixes(
        OfficialApiQuery(
            category=item_class_value,
            corrupted=False,
            fractured=True,
            quality_max=0,
            rarity="nonunique",
        ),
        affix_type="fractured",
    )

    queries = []
    for mod in mods:
        mod_stat_filters = StatFilters(filters=mod.to_query_stat_filters())
        query = OfficialApiQuery(
            category=item_class_value,
            corrupted=False,
            indexed="2week",
            mirrored=False,
            rarity="nonunique",
Beispiel #12
0
})

unique_watchstones = {
    "The Builder": "Platinum Glennach Cairns Watchstone",
    "The Walls": "Platinum Haewark Hamlet Watchstone",
    "Atop the Atlas": "Platinum Lex Ejoris Watchstone",
    "The Closest Peak": "Platinum Lex Proxima Watchstone",
    "The False Hope": "Platinum Lira Arthain Watchstone",
    "The Vast Horizon": "Platinum New Vastir Watchstone",
    "The Claim": "Platinum Tirn's End Watchstone",
    "Restless Cycles": "Platinum Valdo's Rest Watchstone",
}
for name, type in unique_watchstones.items():
    print(name, type)
    mods = find_affixes(
        OfficialApiQuery(name=name, type=type, identified=True),
        affix_type="explicit",
        exclude_affixes=[remaining_use_mod],
    )
    for mod in mods:
        print(mod, mod.json())
    for mod in tqdm(mods):
        results_entry = {
            "mod_str": str(mod),
            "mod_json": json.dumps(mod.json())
        }
        mod_stat_filters = StatFilters(filters=mod.to_query_stat_filters())
        fetch_ids, total, query = search_query(
            OfficialApiQuery(
                name=name,
                type=type,
query1 = OfficialApiQuery(
    stat_filters=[
        StatFilters(
            filters=[
                StatFilter(
                    id="fractured.stat_1671376347",
                    min=18.0,
                    max=29.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_1290399200",
                    min=21.0,
                    max=50.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_1037193709",
                    min=10.5,
                    max=52.5,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_821021828", min=4.0, max=5.0, disabled=False
                ),
                StatFilter(
                    id="fractured.stat_2843100721", min=1.0, max=1.0, disabled=False
                ),
                StatFilter(
                    id="fractured.stat_4220027924",
                    min=6.0,
                    max=35.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_2517001139",
                    min=11.0,
                    max=35.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_2923486259",
                    min=5.0,
                    max=10.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_210067635",
                    min=17.0,
                    max=25.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_829382474", min=1.0, max=1.0, disabled=False
                ),
                StatFilter(
                    id="fractured.stat_789117908",
                    min=40.0,
                    max=49.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_3261801346",
                    min=8.0,
                    max=32.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_691932474",
                    min=21.0,
                    max=325.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_1509134228",
                    min=20.0,
                    max=64.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_3695891184",
                    min=11.0,
                    max=14.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_3556824919",
                    min=15.0,
                    max=29.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_709508406", min=2.0, max=48.0, disabled=False
                ),
                StatFilter(
                    id="fractured.stat_3639275092",
                    min=-18.0,
                    max=-18.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_3336890334",
                    min=36.0,
                    max=85.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_1940865751",
                    min=6.0,
                    max=27.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_1050105434",
                    min=40.0,
                    max=109.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_328541901", min=8.0, max=37.0, disabled=False
                ),
                StatFilter(
                    id="fractured.stat_795138349",
                    min=20.0,
                    max=30.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_3372524247",
                    min=12.0,
                    max=29.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_2375316951",
                    min=10.0,
                    max=29.0,
                    disabled=False,
                ),
                StatFilter(
                    id="fractured.stat_387439868",
                    min=11.0,
                    max=36.0,
                    disabled=False,
                ),
            ],
            type="not",
        ),
        StatFilters(),
    ],
    name=None,
    type=None,
    corrupted=False,
    mirrored=None,
    synthesised=None,
    alternate_art=False,
    talisman_tier_max=None,
    quality_max=0,
    rarity="nonunique",
    category="weapon.claw",
    indexed=None,
    sale_type=None,
    identified=None,
    enchanted=None,
    fractured=True,
    crafted=None,
    sockets_b=None,
    sockets_g=None,
    sockets_r=None,
    sockets_w=None,
    links_b=None,
    links_g=None,
    links_r=None,
    links_w=None,
)
import pytest  # type: ignore

item_ids = [
    "388785b8862730a8f112bfa62e6e207d44d39c7585de5cc7f81f18c21d5498e9",
    "2d0d4561e3074cfe7e1b7a836108248bab54902b1c8f3fc04e407d8e4b679703",
    "269a8332f4af43ee2c244486d9e5f84d7b0e0319a758ca86e5f8cca5250fbc7c",
    "859de7bbf3724b20b5ed1a07d15c1ef29bdad613b0d4904e5857d199e898bcab",
    "d3be0b726851c592597a0d188d75e258e41a54796c77fa9cb02d70b69cabdd30",
    "43e3ebf23e01d98d3ffc1622a470359f6300ff32c78d9174475e213768a8cbc3",
    "9db224474ff9183e70c1ddefa4e8c0bd6a0fa6e4cf053bb83f9017d1642367ed",
    "26ecb874399777d4a28e314b0773f87205997ea60bf0c49cf73b1e65b0661226",
    "8293b6469e1f2f983def6835f179264d45752bd538113ce3612a3f6e90c732a1",
    "ac26f737f496ea4140ebefbb727bd3466530afa704b65085a07f4fa5d78c28a1",
]

query = OfficialApiQuery()


def test_endpoints():
    asyncio.run(search(query))
    asyncio.run(fetch_batched(item_ids))

    asyncio.run(characters("Havoc6"))
    passive_tree("Havoc6", "Havoc_TwitchPrime")
    asyncio.run(items("Havoc6", "Havoc_TwitchPrime"))


@pytest.mark.parametrize("use_cached", [True, False])
def test_async_gather(use_cached):
    N = 10
Beispiel #15
0
        for _ in range(seconds):
            sleep(1)
            yield

    for _ in tqdm(_sleep_timer(), total=seconds):
        pass


# sleep_timer(1500)

t = tqdm(uniques)
results = []
edges = defaultdict(list)
for unique in t:
    t.set_description(desc=f"unique - {unique}")
    query = OfficialApiQuery(ultimatum_input=unique)
    results += search_and_fetch_batched([query])[0]

    for result in search_and_fetch_batched([query])[0]:
        in_v = result["item"]["properties"][2]["values"][0][0]
        out_v = result["item"]["properties"][3]["values"][0][0]
        edges[in_v].append(out_v)
    if len(search_and_fetch_batched([query])[0]) == 10:
        print(query)
unique_to_tier = {"Leer Cast": 0}
to_visit = ["Leer Cast"]

while to_visit:
    next_unique = to_visit.pop()
    tier = unique_to_tier[next_unique]
    for out_v in edges[next_unique]: