@@ -66,6 +66,9 @@ class ClanWar:
6666 :class:`ClanWarLeagueGroup`: The war's league group. This is ``None`` unless this is a Clan League War.
6767 attacks_per_member:
6868 :class:`int`: The number of attacks each member has this war.
69+ clan_cls: :class:`WarClan`
70+ the type `war.clan` and `war.opponent` will be of.
71+ Ensure any overriding of this inherits from :class:`coc.WarClan`.
6972 """
7073
7174 __slots__ = (
@@ -81,6 +84,7 @@ class ClanWar:
8184 "opponent" ,
8285 "league_group" ,
8386 "attacks_per_member" ,
87+ "clan_cls" ,
8488 "_response_retry" ,
8589 "_raw_data"
8690 )
@@ -90,6 +94,7 @@ def __init__(self, *, data, client, **kwargs):
9094 self ._client = client
9195 self ._raw_data = data if client and client .raw_attribute else None
9296 self .clan_tag = kwargs .pop ("clan_tag" , None )
97+ self .clan_cls = kwargs .pop ('clan_cls' , WarClan )
9398 self ._from_data (data )
9499
95100 self .clan_tag = self .clan and self .clan .tag or self .clan_tag
@@ -117,14 +122,14 @@ def _from_data(self, data: dict) -> None:
117122 # depending on the way the game stores it internally. This isn't very helpful as we always want it
118123 # from the perspective of the tag we provided, so switch them around if it isn't correct.
119124 if clan_data and clan_data .get ("tag" , self .clan_tag ) == self .clan_tag :
120- self .clan = try_enum (WarClan , data = clan_data , client = self ._client ,
125+ self .clan = try_enum (self . clan_cls , data = clan_data , client = self ._client ,
121126 war = self )
122- self .opponent = try_enum (WarClan , data = data_get ("opponent" ),
127+ self .opponent = try_enum (self . clan_cls , data = data_get ("opponent" ),
123128 client = self ._client , war = self )
124129 else :
125- self .clan = try_enum (WarClan , data = data_get ("opponent" ),
130+ self .clan = try_enum (self . clan_cls , data = data_get ("opponent" ),
126131 client = self ._client , war = self )
127- self .opponent = try_enum (WarClan , data = clan_data ,
132+ self .opponent = try_enum (self . clan_cls , data = clan_data ,
128133 client = self ._client , war = self )
129134
130135 @property
0 commit comments