@@ -223,17 +223,18 @@ class Player(ClanMember):
223223 "_spells" ,
224224 "_home_troops" ,
225225 "_builder_troops" ,
226- "__iter_achievements" ,
227- "__iter_heroes" ,
228- "__iter_labels" ,
229- "__iter_spells" ,
230- "__iter_troops" ,
231226 "achievement_cls" ,
232227 "hero_cls" ,
233228 "label_cls" ,
234229 "spell_cls" ,
235230 "troop_cls" ,
236231
232+ "_iter_achievements" ,
233+ "_iter_heroes" ,
234+ "_iter_labels" ,
235+ "_iter_spells" ,
236+ "_iter_troops" ,
237+
237238 "_cs_labels" ,
238239 "_cs_achievements" ,
239240 "_cs_troops" ,
@@ -285,11 +286,11 @@ def _from_data(self, data: dict) -> None:
285286 hero_cls = self .hero_cls
286287 spell_cls = self .spell_cls
287288
288- self .__iter_labels = (label_cls (data = ldata , client = self ._client ) for ldata in data_get ("labels" , []))
289- self .__iter_achievements = (achievement_cls (data = adata ) for adata in data_get ("achievements" , []))
290- self .__iter_troops = (troop_cls (data = tdata ) for tdata in data_get ("troops" , []))
291- self .__iter_heroes = (hero_cls (data = hdata ) for hdata in data_get ("heroes" , []))
292- self .__iter_spells = (spell_cls (data = sdata ) for sdata in data_get ("spells" , []))
289+ self ._iter_labels = (label_cls (data = ldata , client = self ._client ) for ldata in data_get ("labels" , []))
290+ self ._iter_achievements = (achievement_cls (data = adata ) for adata in data_get ("achievements" , []))
291+ self ._iter_troops = (troop_cls (data = tdata ) for tdata in data_get ("troops" , []))
292+ self ._iter_heroes = (hero_cls (data = hdata ) for hdata in data_get ("heroes" , []))
293+ self ._iter_spells = (spell_cls (data = sdata ) for sdata in data_get ("spells" , []))
293294
294295 def _inject_clan_member (self , member ):
295296 if member :
@@ -299,14 +300,14 @@ def _inject_clan_member(self, member):
299300 @cached_property ("_cs_labels" )
300301 def labels (self ) -> typing .List [Label ]:
301302 """List[:class:`Label`]: A :class:`List` of :class:`Label` that the player has."""
302- return list (self .__iter_labels )
303+ return list (self ._iter_labels )
303304
304305 @cached_property ("_cs_achievements" )
305306 def achievements (self ) -> typing .List [Achievement ]:
306307 """List[:class:`Achievement`]: A list of the player's achievements."""
307308 # at the time of writing, the API presents achievements in the order
308309 # added to the game which doesn't match in-game order.
309- achievement_dict = {a .name : a for a in self .__iter_achievements }
310+ achievement_dict = {a .name : a for a in self ._iter_achievements }
310311 sorted_achievements = {}
311312 for name in ACHIEVEMENT_ORDER :
312313 try :
@@ -349,7 +350,7 @@ def troops(self) -> typing.List[Troop]:
349350 Troops are **not** ordered in this attribute. Use either :attr:`Player.home_troops`
350351 or :attr:`Player.builder_troops` if you want an ordered list.
351352 """
352- troops = list (self .__iter_troops )
353+ troops = list (self ._iter_troops )
353354 self ._home_troops = {t .name : t for t in troops if t .is_home_base }
354355 self ._builder_troops = {t .name : t for t in troops if t .is_builder_base }
355356 return troops
@@ -451,7 +452,7 @@ def heroes(self) -> typing.List[Hero]:
451452
452453 This will return heroes in the order found in the store and labatory in-game.
453454 """
454- heroes_dict = {h .name : h for h in self .__iter_heroes }
455+ heroes_dict = {h .name : h for h in self ._iter_heroes }
455456 sorted_heroes = {}
456457 for name in HERO_ORDER :
457458 # have to do it this way because it's less expensive than removing None's if they don't have a troop.
@@ -480,7 +481,7 @@ def get_hero(self, name: str, default_value=None) -> typing.Optional[Hero]:
480481 """
481482 dict_heroes = self ._heroes
482483 if dict_heroes is None :
483- dict_heroes = self ._heroes = {h .name : h for h in self .__iter_heroes }
484+ dict_heroes = self ._heroes = {h .name : h for h in self ._iter_heroes }
484485
485486 try :
486487 return dict_heroes [name ]
@@ -493,7 +494,7 @@ def spells(self) -> typing.List[Spell]:
493494
494495 This will return spells in the order found in both spell factory and labatory in-game.
495496 """
496- dict_spells = self ._spells = {s .name : s for s in self .__iter_spells }
497+ dict_spells = self ._spells = {s .name : s for s in self ._iter_spells }
497498 order = {k : v for v , k in enumerate (SPELL_ORDER )}
498499 return list (sorted (dict_spells .values (), key = lambda s : order .get (s .name )))
499500
@@ -514,7 +515,7 @@ def get_spell(self, name: str, default_value=None) -> typing.Optional[Spell]:
514515 """
515516 dict_spells = self ._spells
516517 if dict_spells is None :
517- dict_spells = self ._spells = {s .name : s for s in self .__iter_spells }
518+ dict_spells = self ._spells = {s .name : s for s in self ._iter_spells }
518519
519520 try :
520521 return dict_spells [name ]
0 commit comments