@@ -96,14 +96,12 @@ def __init__(self, data):
9696 self .legendary = data .get ('legendaryPos' )
9797 self .epic = data .get ('epicPos' )
9898
99- class Card :
99+ class CardInfo :
100100 '''Represents a Clash Royale card'''
101101 def __init__ (self , data ):
102+ self .raw_data = data
102103 self .name = data .get ('name' )
103104 self .rarity = data .get ('rarity' )
104- self .level = data .get ('level' )
105- self .count = data .get ('count' )
106- self .to_upgrade = data .get ('requiredForUpgrade' )
107105 self .id = data .get ('card_id' )
108106 self .elixir = data .get ('elixir' )
109107 self .type = data .get ('type' )
@@ -114,6 +112,15 @@ def __init__(self, data):
114112 def __repr__ (self ):
115113 return '<Card id={0.id}>' .format (self )
116114
115+ class PlayerCard (CardInfo ):
116+
117+ def __init__ (self , data ):
118+ super ().__init__ (data )
119+ self .level = data .get ('level' )
120+ self .count = data .get ('count' )
121+ self .to_upgrade = data .get ('requiredForUpgrade' )
122+
123+
117124class Member :
118125 '''Represents a member of a clan'''
119126 def __init__ (self , client , clan , data ):
@@ -180,19 +187,6 @@ def __init__(self, data):
180187 def __str__ (self ):
181188 return self .name
182189
183- class CardInfo :
184- def __init__ (self , data ):
185- self .name = data .get ('name' )
186- self .rarity = data .get ('rarity' )
187- self .id = data .get ('card_id' )
188- self .elixir = data .get ('elixir' )
189- self .type = data .get ('type' )
190- self .arena = data .get ('arena' )
191- self .description = data .get ('description' )
192- self .decklink = data .get ('decklink' )
193-
194- def __repr__ (self ):
195- return '<Card id={0.id}>' .format (self )
196190
197191class ClanInfo :
198192 def __init__ (self , client , data ):
@@ -280,7 +274,7 @@ def from_data(self, data):
280274 self .arena = Arena (data .get ('arena' ))
281275 self .shop_offers = Shop (data .get ('shopOffers' ))
282276 self .chest_cycle = Cycle (data .get ('chestCycle' ))
283- self .deck = [Card (c ) for c in data .get ('currentDeck' )]
277+ self .deck = [PlayerCard (c ) for c in data .get ('currentDeck' )]
284278 if clan is None :
285279 self .clan_tag = None
286280 self .clan_name = None
@@ -290,8 +284,6 @@ def from_data(self, data):
290284 self .clan_name = clan .get ('name' )
291285 self .clan_role = clan .get ('role' )
292286
293-
294-
295287 @property
296288 def clan_badge_url (self ):
297289 '''Returns clan badge url'''
@@ -328,7 +320,7 @@ def from_data(self, data):
328320 self .chest_cycle = [c for c in data .get ('chestCycle' ).get ('order' )]
329321 self .country_codes = [Country (c ) for c in data .get ('countryCodes' )]
330322 self .rarities = [Rarity (c ) for c in data .get ('rarities' )]
331- self .card = [CardInfo (c ) for c in data .get ('rarities ' )]
323+ self .card = [CardInfo (c ) for c in data .get ('cards ' )]
332324
333325 def __repr__ (self ):
334326 return '<Clash Royale Constants Object>'
0 commit comments