Skip to content

Commit

Permalink
Merge pull request #7 from offish/v2.0.3
Browse files Browse the repository at this point in the history
v2.0.3
  • Loading branch information
offish authored Oct 10, 2023
2 parents 35c9caa + cbc1b68 commit 8fc8e9a
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/tf2_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = "tf2-utils"
__author__ = "offish"
__version__ = "2.0.2"
__version__ = "2.0.3"
__license__ = "MIT"

from .schema import Schema, IEconItems
Expand Down
56 changes: 44 additions & 12 deletions src/tf2_utils/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,40 @@ def is_tf2(self) -> bool:
def has_name(self, name: str) -> bool:
return self.name == name

def has_description(self, description: str) -> bool:
def has_description(
self, description: str, color: str = "756b5e", exact: bool = True
) -> bool:
for i in self.descriptions:
if i["value"] == description:
desc = i["value"]

if color != i.get("color", ""):
continue

if (description == desc) or (description in desc and not exact):
return True

return False

def get_description(self, description: str, color: str = "756b5e") -> str:
for i in self.descriptions:
desc = i["value"]

if color != i.get("color", ""):
continue

if description not in desc:
continue

return desc

return ""

def get_description_and_replace(
self, description: str, color: str = "756b5e"
) -> str:
desc = self.get_description(description, color)
return desc.replace(description, "")

def has_tag(self, tag: str, exact: bool = True) -> bool:
for i in self.tags:
item_tag = i["localized_tag_name"]
Expand Down Expand Up @@ -117,16 +144,10 @@ def get_defindex(self) -> int:
return -1 # could not find

def get_effect(self) -> str:
if not self.is_unusual():
return ""

string = "★ Unusual Effect: "

for i in self.descriptions:
if string in i["value"]:
return i["value"].replace(string, "")
return self.get_description_and_replace("\u2605 Unusual Effect: ", "ffd700")

return "" # could not find
def get_paint(self) -> str:
return self.get_description_and_replace("Paint Color: ")

def get_killstreak_id(self) -> int:
if not self.is_killstreak():
Expand Down Expand Up @@ -176,14 +197,25 @@ def is_decorated_weapon(self) -> bool:
return self.has_tag("Decorated Weapon")

def is_craftable(self) -> bool:
return not self.has_description("( Not Usable in Crafting )")
# has no color
return not self.has_description("( Not Usable in Crafting )", "")

def is_uncraftable(self) -> bool:
return not self.is_craftable()

def is_non_craftable(self) -> bool:
return self.is_uncraftable()

def is_painted(self) -> bool:
return self.has_description("Paint Color: ", exact=False)

def has_spell(self) -> bool:
return self.has_description("(spell only active during event)", "7ea9d1", False)

def is_special(self) -> bool:
return self.is_painted() or self.has_spell()
# or self.has_strange_part()

def is_festivized(self) -> bool:
return "Festivized" in self.name

Expand Down
43 changes: 43 additions & 0 deletions src/tf2_utils/json/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,35 @@
"291": "Fireflies",
"Mountain Halo": 292,
"292": "Mountain Halo",
"Celestial Summit": 293,
"293": "Celestial Summit",
"Stellar Ascent": 294,
"294": "Stellar Ascent",
"Sapped": 296,
"295": "Sapped",
"296": "Sapped",
"Hellspawned Horns": 298,
"297": "Hellspawned Horns",
"298": "Hellspawned Horns",
"Demonic Impaler": 299,
"299": "Demonic Impaler",
"Revenant's Rack": 300,
"300": "Revenant's Rack",
"Sixth Sense": 302,
"301": "Sixth Sense",
"302": "Sixth Sense",
"Amygdala": 303,
"303": "Amygdala",
"The Bone Zone": 304,
"304": "The Bone Zone",
"Arachne's Web": 305,
"305": "Arachne's Web",
"Acidic Climate": 306,
"306": "Acidic Climate",
"Otherworldly Weather": 307,
"307": "Otherworldly Weather",
"Nightmarish Storm": 308,
"308": "Nightmarish Storm",
"Hot": 701,
"701": "Hot",
"Isotope": 702,
Expand Down Expand Up @@ -789,6 +818,20 @@
"3122": "Pastel Trance",
"Wildflower Meadows": 3123,
"3123": "Wildflower Meadows",
"Deep-sea Devourer": 3124,
"3124": "Deep-sea Devourer",
"Eldritch Horror": 3125,
"3125": "Eldritch Horror",
"Autumn Leaves": 3126,
"3126": "Autumn Leaves",
"Dead Man's Party": 3127,
"3127": "Dead Man's Party",
"Potion Explosion": 3128,
"3128": "Potion Explosion",
"Haunted Cremation": 3129,
"3129": "Haunted Cremation",
"Cremation": 3130,
"3130": "Cremation",
"Attrib_Particle22001": 22001,
"22001": "Attrib_Particle22001",
"Attrib_Particle22002": 22002,
Expand Down
155 changes: 155 additions & 0 deletions src/tf2_utils/json/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"result": {
"status": 1,
"items_game_url": "http://media.steampowered.com/apps/440/scripts/items/items_game.bf0a50a382dcc1d005b89951b557847df7295eea.txt",
"qualities": {
"Normal": 0,
"rarity1": 1,
Expand Down Expand Up @@ -10602,6 +10603,118 @@
"attachment": "unusual",
"name": "Mountain Halo"
},
{
"system": "unusual_risingstar_green_parent",
"id": 293,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Celestial Summit"
},
{
"system": "unusual_risingstar_purple_parent",
"id": 294,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Stellar Ascent"
},
{
"system": "unusual_sapper_teamcolor_red",
"id": 295,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Sapped"
},
{
"system": "unusual_sapper_teamcolor_blue",
"id": 296,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Sapped"
},
{
"system": "unusual_devilish_teamcolor_red",
"id": 297,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Hellspawned Horns"
},
{
"system": "unusual_devilish_teamcolor_blue",
"id": 298,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Hellspawned Horns"
},
{
"system": "unusual_devilish_green_parent",
"id": 299,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Demonic Impaler"
},
{
"system": "unusual_devilish_purple_parent",
"id": 300,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Revenant's Rack"
},
{
"system": "unusual_sixthsense_teamcolor_red",
"id": 301,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Sixth Sense"
},
{
"system": "unusual_sixthsense_teamcolor_blue",
"id": 302,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Sixth Sense"
},
{
"system": "unusual_sixthsense_pink_parent",
"id": 303,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Amygdala"
},
{
"system": "unusual_skullhead_parent",
"id": 304,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "The Bone Zone"
},
{
"system": "unusual_spiderweb_parent",
"id": 305,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Arachne's Web"
},
{
"system": "unusual_deepsmoke_green_parent",
"id": 306,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Acidic Climate"
},
{
"system": "unusual_deepsmoke_purple_parent",
"id": 307,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Otherworldly Weather"
},
{
"system": "unusual_deepsmoke_orange_parent",
"id": 308,
"attach_to_rootbone": true,
"attachment": "unusual",
"name": "Nightmarish Storm"
},
{
"system": "weapon_unusual_hot",
"id": 701,
Expand Down Expand Up @@ -11404,6 +11517,48 @@
"attach_to_rootbone": false,
"name": "Wildflower Meadows"
},
{
"system": "utaunt_krakenmouth_green_parent",
"id": 3124,
"attach_to_rootbone": false,
"name": "Deep-sea Devourer"
},
{
"system": "utaunt_krakenmouth_purple_parent",
"id": 3125,
"attach_to_rootbone": false,
"name": "Eldritch Horror"
},
{
"system": "utaunt_leaftaunt_parent",
"id": 3126,
"attach_to_rootbone": false,
"name": "Autumn Leaves"
},
{
"system": "utaunt_graveparty_parent",
"id": 3127,
"attach_to_rootbone": false,
"name": "Dead Man's Party"
},
{
"system": "utaunt_spellsplash_parent",
"id": 3128,
"attach_to_rootbone": false,
"name": "Potion Explosion"
},
{
"system": "utaunt_cremation_purple_parent",
"id": 3129,
"attach_to_rootbone": false,
"name": "Haunted Cremation"
},
{
"system": "utaunt_cremation_black_parent",
"id": 3130,
"attach_to_rootbone": false,
"name": "Cremation"
},
{
"system": "killstreak_eyeglow_4_teamcolor_red",
"id": 22001,
Expand Down
Loading

0 comments on commit 8fc8e9a

Please sign in to comment.