Skip to main content

D2 nip-eval is a package aimed to help in providing an API for converting nip expressions into python eval statements

Project description

D2 nip-eval

D2 nip-eval is a package aimed to help in providing an API for converting nip expressions into python eval statements

  • transpile_nip_expressions(expressions: list[str]) -> list[str]
  • transpile_nip_expression(expression: str) -> str
  • keep_item(expressions: list[str], item_data: HoveredItem)

HoveredItem

class HoveredItem:
    Name: str # e.g., DAGGER, SPIRIT, CHILLING GRAND CHARM OF VITA
    Quality: str # e.g., gray, normal, magic, rare, set, unique, runeword, rune
    Text: str
    BaseItem: dict
    Item: Union[dict, None]
    NTIPAliasType: int
    NTIPAliasClassID: int
    NTIPAliasClass: Union[int, None]
    NTIPAliasQuality: int
    NTIPAliasStat: Union[dict, None]
    NTIPAliasFlag: dict

Usage


Python Example:

import requests
from d2_nip_to_eval import lexer

data = requests.get(url='https://raw.githubusercontent.com/blizzhackers/kolbot/master/d2bs/kolbot/pickit/kolton.nip').text
expressions = lexer.transpile_nip_expressions(data.split('\n'))
for expression in expressions:
    print(expression)

hovered_item = {
    "Name": "War Traveler",
    "Quality": "unique",
    "Text": "WAR TRAVELER|BATTLE BOOTS|DEFENSE: 139|DURABILITY: 13 OF 48|REQUIRED STRENGTH: 95|REQUIRED LEVEL: 42|+25% FASTER RUN/WALK|ADDS 15-25 DAMAGE|+190% ENHANCED DEFENSE|+10 TO STRENGTH|+10 TO VITALITY|40% SLOWER STAMINA DRAIN|ATTACKER TAKES DAMAGE OF 10|50% BETTER CHANCE OF GETTING MAGIC ITEMS",
    "BaseItem":
    {
        "DisplayName": "Battle Boots",
        "NTIPAliasClassID": 388,
        "NTIPAliasType": 15,
        "NTIPAliasStatProps":
        {
            "72": 18,
            "73": 18,
            "31":
            {
                "min": 39,
                "max": 47
            },
            "0x400000":
            {
                "min": 0,
                "max": 1
            }
        },
        "dimensions": [2, 2],
        "sets": ["ALDURSADVANCE"],
        "uniques": ["WARTRAVELER"],
        "NTIPAliasClass": 1
    },
    "Item":
    {
        "DisplayName": "War Traveler",
        "NTIPAliasClassID": 388,
        "NTIPAliasType": 15,
        "NTIPAliasStatProps":
        {
            "3":
            {
                "min": 10,
                "max": 10
            },
            "0":
            {
                "min": 10,
                "max": 10
            },
            "80":
            {
                "min": 30,
                "max": 50
            },
            "72": 30,
            "73": 30,
            "96":
            {
                "min": 25,
                "max": 25
            },
            "16,0":
            {
                "min": 150,
                "max": 190
            },
            "21": 15,
            "22": 25,
            "78":
            {
                "min": 5,
                "max": 10
            },
            "154":
            {
                "min": 40,
                "max": 40
            }
        }
    },
    "NTIPAliasType": 15,
    "NTIPAliasClassID": 388,
    "NTIPAliasClass": None,
    "NTIPAliasQuality": 7,
    "NTIPAliasStat":
    {
        "21": 15,
        "22": 25,
        "78": 10,
        "31": 139,
        "72": 13,
        "73": 48,
        "80": 50,
        "0": 10,
        "3": 10,
        "16": 190,
        "96": 25,
        "154": 40
    },
    "NTIPAliasFlag":
    {
        "0x10": True,
        "0x400000": False,
        "0x4000000": False
    }
}
should_keep_item = lexer.keep_item(expressions, hovered_item)
print(should_keep_item)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d2-nip-eval-0.0.1.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

d2_nip_eval-0.0.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file d2-nip-eval-0.0.1.tar.gz.

File metadata

  • Download URL: d2-nip-eval-0.0.1.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for d2-nip-eval-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e14c85a16a0de6eef2150adee8bc68abb7c6ae49ccbc7c6e3829638eccb27b92
MD5 ef13cda080e39d7f32a5220098a79915
BLAKE2b-256 42765f7126e06b2140fcda2cc797c1dd290088ceec2f0bd277e7eb9fe7670710

See more details on using hashes here.

File details

Details for the file d2_nip_eval-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: d2_nip_eval-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for d2_nip_eval-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36edd5d9916a0afdc7a7f2727ed3bbf7bc873af959ff44fdd8090fa3bd327d13
MD5 554039ee8044459df650e9ab16cdff09
BLAKE2b-256 eb8e13b1d297f61269800fc047c769072570446d5848720941218a62d72a7f74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page