1
1
from .pack import Pack
2
- from typing import Union , List
2
+ from typing import Literal , Union , List
3
3
4
4
class UserPin :
5
5
"""
@@ -11,20 +11,19 @@ class UserPin:
11
11
type (str): The type of the pin.
12
12
rarity (int): The rarity of the pin.
13
13
identifier (int): The identifier of the pin.
14
- description (str): The description of the pin.
15
- reference (str): The reference of the pin.
16
14
pack (Pack): The pack of the pin.
17
15
image_urls (List[str]): The image urls of the pin.
16
+ shiny_level (Literal['Normal', 'Golden', 'Shiny']): The shiny level of the pin.
18
17
score (int): The score of the pin.
19
- score_golden (int): The score of the golden pin.
20
18
is_recyclable (bool): Whether the pin is recyclable.
21
19
is_tradable (bool): Whether the pin is tradable.
22
20
is_counting (bool): Whether the pin is counting.
23
21
is_craftable (bool): Whether the pin is craftable.
24
22
is_invocable (bool): Whether the pin is invocable.
25
23
is_goldable (bool): Whether the pin is goldable.
26
24
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.
28
27
"""
29
28
30
29
def __init__ (self , payload ) -> None :
@@ -51,14 +50,6 @@ def rarity(self) -> int:
51
50
def identifier (self ) -> int :
52
51
return self .__item ['identifier' ]
53
52
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
-
62
53
@property
63
54
def pack (self ) -> Pack :
64
55
return Pack (self .__item ['pack' ])
@@ -68,12 +59,20 @@ def image_urls(self) -> List[str]:
68
59
return [x for x in self .__item ['urls' ]]
69
60
70
61
@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
+
74
73
@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 } ' ]
77
76
78
77
@property
79
78
def is_recyclable (self ) -> bool :
@@ -105,4 +104,8 @@ def is_upgradable(self) -> bool:
105
104
106
105
@property
107
106
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
0 commit comments