Wars
Clan War
- class coc.ClanWar
Represents a Current Clash of Clans War
- state
str
: The clan’s current war state.
- team_size
int
: The number of players on each side of the war.
- war_tag
str
: The war’s unique tag. This isNone
unless this is a Clan League War (CWL).
- league_group
ClanWarLeagueGroup
: The war’s league group. This isNone
unless this is a Clan League War.
- attacks_per_member
int
: The number of attacks each member has this war.
- clan_cls
the type war.clan and war.opponent will be of. Ensure any overriding of this inherits from
coc.WarClan
.- Type:
- property attacks: List[WarAttack]
Returns all attacks this war, sorted by attack order.
- Type:
List[
WarAttack
]
- get_attack(attacker_tag: str, defender_tag: str) Optional[WarAttack]
Return the
WarAttack
with the attacker tag and defender tag provided.If the attack was not found, this will return
None
.- Returns:
The attack with the correct attacker and defender tags
- Return type:
- get_defenses(defender_tag: str) List[WarAttack]
Return a
list
ofWarAttack
for the defender tag provided.If the player has no defenses, this will return an empty list.
- Returns:
The player’s defenses
- Return type:
List[
WarAttack
]
- get_member(tag: str) Optional[ClanWarMember]
Return a
ClanWarMember
with the tag provided. ReturnsNone
if not found.Example
war = await client.get_current_war('clan_tag') member = war.get_member('player_tag')
- Returns:
Optional[:class:`ClanWarMember`]
- Return type:
The member who matches the tag provided.
- get_member_by(**attrs) Optional[ClanWarMember]
Returns the first
WarMember
that meets the attributes passedThis will return the first member matching the attributes passed.
An example of this looks like:
member = ClanWar.get_member(tag='tag')
This search implements the
coc.utils.get()
function
- property is_cwl: bool
Returns a boolean indicating if the war is a Clan War League (CWL) war.
- Type:
bool
- property members: List[ClanWarMember]
A list of members that are in the war.
- Type:
List[
ClanWarMember
]
- property status: str
Returns the war status, based off the home clan.
Strings returned are determined by result and state, as listed below:
inWar
warEnded
winning
won
tied
tie
losing
lost
- Type:
str
- property type: Optional[str]
Returns either
friendly
,random
orcwl
.This will returns
None
if the clan is not in war, orcwl
if the clan is in a league war.Possibilities for the length of preparation time for a friendly war include: 5 minutes, 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours, 6 hours, 8 hours, 12 hours, 16 hours, 20 hours or 24 hours.
- Type:
str
Clan War Log Entry
- class coc.ClanWarLogEntry
Represents a Clash of Clans War Log Entry
Note
Please see the
WarClan
documentation for a full list of missing attributes, as the clan and opponent attributes are only partially filled by the API.If the
ClanWarLogEntry.type
iscwl
, theWarClan.attack_count
,WarClan.stars
andWarClan.destruction
are all a total which over the period of that CWL season.In addition, if it is a CWL entry,
opponent
andresult
will beNone
.- result
str
: The result of the war -win
orloss
- team_size
int
: The number of players on each side of the war.
- attacks_per_member
int
: The number of attacks each member had this war.
- property is_league_entry: bool
Boolean indicating if the entry is a Clan War League (CWL) entry.
- Type:
bool
Clan War League Group
- class coc.ClanWarLeagueGroup
Represents a Clan War League (CWL) Group
- state
str
: The current state of the league group (inWar, preparation etc.)
- season
str
: The current season of the league group
- number_of_rounds
int
: The number of rounds this league group contains.
- rounds
List[List[
str
]]: A list of lists containing all war tags for each round.Note
This only returns the current or past rounds. Any future rounds filled with #0 war tags will not appear.
To find the number of rounds in this season, use
LeagueGroup.number_of_rounds
.
- clans
Returns all participating clans.
- Type:
List[
LeagueClan
]
- get_wars(cwl_round: ~coc.enums.WarRound = WarRound.current_war, cls: ~typing.Type[~coc.wars.ClanWar] = <class 'coc.wars.ClanWar'>) AsyncIterator[ClanWar]
Returns war information for every war in a league round.
This returns a
LeagueWarIterator
which fetches all wars in parallel.Example
group = await client.get_league_group('clan_tag') async for war in group.get_wars(): print(war.clan_tag)
- Parameters:
cls (Type[
ClanWar
]: The constructor used to create the league war.) – This should inherit fromClanWar
.cwl_round (
WarRound
) – An enum detailing the type of round to get. Could becoc.WarRound.previous_war
,coc.WarRound.current_war
orcoc.WarRound.preparation
. This defaults tococ.WarRound.current_war
.
- Yields:
ClanWar
– A war in the requested round.
- get_wars_for_clan(clan_tag: str, cls: ~typing.Type[~coc.wars.ClanWar] = <class 'coc.wars.ClanWar'>) AsyncIterator[ClanWar]
Returns every war the clan has participated in this current CWL.
This returns a
LeagueWarIterator
which fetches all wars in parallel.Example
group = await client.get_league_group('#clan_tag') async for war in group.get_wars_for_clan('#clantag'): print(war.start_time)
War Round
War Attack
- class coc.WarAttack
Represents a Clash of Clans War Attack
- stars
int
- The stars achieved
- destruction
float
- The destruction achieved as a percentage (of 100)
- order
int
- The attack order in this war
- attacker_tag
str
- The attacker tag
- defender_tag
str
- The defender tag
- duration
int
- Duration of attack in seconds
- property attacker: ClanWarMember
Returns the attacking player.
- Type:
- property defender: ClanWarMember
Returns the defending player.
- Type:
- property is_fresh_attack: bool
Returns whether the attack is a fresh (first) attack on the defender.
- Type:
boolean