Skip to content

Commit c7b89ea

Browse files
committed
fix: pins
1 parent 6f392fb commit c7b89ea

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

pyZUnivers/pins.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .pack import Pack
2-
from typing import Union, List
2+
from typing import Literal, Union, List
33

44
class UserPin:
55
"""
@@ -11,20 +11,19 @@ class UserPin:
1111
type (str): The type of the pin.
1212
rarity (int): The rarity of the pin.
1313
identifier (int): The identifier of the pin.
14-
description (str): The description of the pin.
15-
reference (str): The reference of the pin.
1614
pack (Pack): The pack of the pin.
1715
image_urls (List[str]): The image urls of the pin.
16+
shiny_level (Literal['Normal', 'Golden', 'Shiny']): The shiny level of the pin.
1817
score (int): The score of the pin.
19-
score_golden (int): The score of the golden pin.
2018
is_recyclable (bool): Whether the pin is recyclable.
2119
is_tradable (bool): Whether the pin is tradable.
2220
is_counting (bool): Whether the pin is counting.
2321
is_craftable (bool): Whether the pin is craftable.
2422
is_invocable (bool): Whether the pin is invocable.
2523
is_goldable (bool): Whether the pin is goldable.
2624
is_upgradable (bool): Whether the pin is upgradable.
27-
is_golden (bool): Whether the pin is golden.
25+
is_golden (bool): Whether the pin is golden or not.
26+
is_shiny (bool): Whether the pin is shiny or not.
2827
"""
2928

3029
def __init__(self, payload) -> None:
@@ -51,14 +50,6 @@ def rarity(self) -> int:
5150
def identifier(self) -> int:
5251
return self.__item['identifier']
5352

54-
@property
55-
def description(self) -> Union[str, None]:
56-
return self.__item['description']
57-
58-
@property
59-
def reference(self) -> Union[str, None]:
60-
return self.__item['reference']
61-
6253
@property
6354
def pack(self) -> Pack:
6455
return Pack(self.__item['pack'])
@@ -68,12 +59,20 @@ def image_urls(self) -> List[str]:
6859
return [x for x in self.__item['urls']]
6960

7061
@property
71-
def score(self) -> int:
72-
return self.__item['score']
73-
62+
def shiny_level(self) -> Literal['Normal', 'Golden', 'Shiny']:
63+
self.__shiny_index = self.__payload['shinyLevel']
64+
65+
match self.__shiny_index:
66+
case 0:
67+
return 'Normal'
68+
case 1:
69+
return 'Golden'
70+
case 2:
71+
return 'Shiny'
72+
7473
@property
75-
def score_golden(self) -> int:
76-
return self.__item['scoreGolden']
74+
def score(self) -> int:
75+
return self.__item['scores'][f'{self.__shiny_index}']
7776

7877
@property
7978
def is_recyclable(self) -> bool:
@@ -105,4 +104,8 @@ def is_upgradable(self) -> bool:
105104

106105
@property
107106
def is_golden(self) -> bool:
108-
return self.__payload['isGolden']
107+
return self.__shiny_index == 1
108+
109+
@property
110+
def is_shiny(self) -> bool:
111+
return self.__shiny_index == 2

tests/test_user_overview.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ def test_pins(self) -> None:
2323
self.assertIsInstance(pin.type, str)
2424
self.assertIsInstance(pin.rarity, int)
2525
self.assertIsInstance(pin.identifier, int)
26-
self.assertIsInstance(pin.description, Union[str, None])
27-
self.assertIsInstance(pin.reference, Union[str, None])
2826
self.assertIsInstance(pin.pack, Pack)
2927
self.assertIsInstance(pin.image_urls, List)
3028
for url in pin.image_urls:
3129
self.assertIsInstance(url, str)
30+
self.assertIsInstance(pin.shiny_level, str)
3231
self.assertIsInstance(pin.score, int)
33-
self.assertIsInstance(pin.score_golden, int)
3432
self.assertIsInstance(pin.is_recyclable, bool)
3533
self.assertIsInstance(pin.is_tradable, bool)
3634
self.assertIsInstance(pin.is_counting, bool)
@@ -39,6 +37,7 @@ def test_pins(self) -> None:
3937
self.assertIsInstance(pin.is_goldable, bool)
4038
self.assertIsInstance(pin.is_upgradable, bool)
4139
self.assertIsInstance(pin.is_golden, bool)
40+
self.assertIsInstance(pin.is_shiny, bool)
4241

4342
def test_invocations_before_pity(self) -> None:
4443
self.assertIsInstance(self.overview_powaza.invocations_before_pity, int)

0 commit comments

Comments
 (0)