Game Objects
Troop
- class coc.Troop
Represents a Troop object as returned by the API, optionally filled with game data.
- id
The troop’s unique ID.
- Type:
int
- name
The troop’s name.
- Type:
str
- range
The troop’s attack range.
- Type:
int
- lab_level
The required labatory level to upgrade the troop to this level.
- Type:
int
- dps
The troop’s Damage Per Second (DPS).
- Type:
int
- hitpoints
The number of hitpoints the troop has at this level.
- Type:
int
- ground_target
Whether the troop is ground-targetting.
- Type:
bool
- speed
The troop’s speed.
- Type:
int
- upgrade_cost
The amount of resources required to upgrade the troop to the next level.
- Type:
int
- training_cost
The amount of resources required to train this troop.
- Type:
int
- is_elixir_troop
Whether this troop is a regular troop from the Barracks
- Type:
bool
- is_dark_troop
Whether this troop is a dark-troop, trained in the Dark Barracks.
- Type:
bool
- is_siege_machine
Whether this troop is a Siege Machine.
- Type:
bool
- is_super_troop
Whether this troop is a Super Troop.
- Type:
bool
- cooldown
The cooldown on this super troop before being able to be reactivated [Super Troops Only].
- Type:
- min_original_level
The minimum level required of the original troop in order to boost this troop [Super Troops Only].
- Type:
int
- original_troop
The “original” counterpart troop to this super troop [Super Troops Only].
- Type:
- is_loaded
Whether the API data has been loaded for this troop.
- Type:
bool
- level
The troop’s level
- Type:
int
- max_level
The max level for this troop.
- Type:
int
- village
Either
home
orbuilderBase
, indicating which village this troop belongs to.- Type:
str
- classmethod get_max_level_for_townhall(townhall)
Get the maximum level for a troop for a given townhall level.
- Parameters:
townhall – The townhall level to get the maximum troop level for.
- Returns:
The maximum troop level, or
None
if the troop hasn’t been unlocked at that level.- Return type:
int
- property is_max_for_townhall
bool
: Returns a boolean that indicates whether the troop is the max level for the player’s townhall level.
Hero
- class coc.Hero
Represents a Hero object as returned by the API, optionally filled with game data.
- id
The hero’s unique ID.
- Type:
int
- name
The hero’s name.
- Type:
str
- range
The hero’s attack range.
- Type:
int
- dps
The hero’s Damage Per Second (DPS).
- Type:
int
- hitpoints
The number of hitpoints the troop has at this level.
- Type:
int
- ground_target
Whether the hero is ground-targetting. The Grand Warden is classified as ground targetting always.
- Type:
bool
- speed
The hero’s speed.
- Type:
int
- upgrade_cost
The amount of resources required to upgrade the hero to the next level.
- Type:
int
- ability_time
The number of milliseconds the hero’s ability lasts for.
- Type:
int
- required_th_level
The minimum required townhall to unlock this level of the hero.
- Type:
int
- regeneration_time
The time required for this hero to regenerate after being “knocked out”.
- Type:
- equipment
a list of the equipment currently used by this hero
- Type:
List[Equipment]
- is_loaded
Whether the API data has been loaded for this hero.
- Type:
bool
- level
The hero’s level
- Type:
int
- max_level
The max level for this hero.
- Type:
int
- village
Either
home
orbuilderBase
, indicating which village this hero belongs to.- Type:
str
- classmethod get_max_level_for_townhall(townhall)
Get the maximum level for a hero for a given townhall level.
- Parameters:
townhall – The townhall level to get the maximum hero level for.
- Returns:
The maximum spell level.
- Return type:
int
- property is_max_for_townhall: bool
Returns whether the hero is the max level for the player’s townhall level.
- Type:
bool
Pet
- class coc.Pet
Represents a Pet object as returned by the API, optionally filled with game data.
- id
The pet’s unique ID.
- Type:
int
- name
The pet’s name.
- Type:
str
- range
The pet’s attack range.
- Type:
int
- dps
The pet’s Damage Per Second (DPS).
- Type:
int
- ground_target
Whether the pet is ground-targetting.
- Type:
bool
- hitpoints
The number of hitpoints the troop has at this level.
- Type:
int
- speed
The pet’s speed.
- Type:
int
- upgrade_cost
The amount of resources required to upgrade the pet to the next level.
- Type:
int
- is_loaded
Whether the API data has been loaded for this pet.
- Type:
bool
- level
The pet’s level
- Type:
int
- max_level
The max level for this pet.
- Type:
int
- village
Either
home
orbuilderBase
, indicating which village this pet belongs to.- Type:
str
- required_th_level
The minimum required townhall to unlock this level of the pet.
- Type:
int
- classmethod get_max_level_for_townhall(townhall)
Get the maximum level for a hero pet for a given townhall level.
- Parameters:
townhall – The townhall level to get the maximum hero pet level for.
- Returns:
The maximum spell level.
- Return type:
int
- property is_max_for_townhall: bool
Returns whether the hero pet is the max level for the player’s townhall level.
- Type:
bool
Spell
- class coc.Spell
Represents a Spell object as returned by the API, optionally filled with game data.
- id
The spell’s unique ID.
- Type:
int
- name
The spell’s name.
- Type:
str
- range
The spell’s attack range.
- Type:
int
- upgrade_cost
The amount of resources required to upgrade the spell to the next level.
- Type:
int
- training_cost
The amount of resources required to train this spell.
- Type:
int
- is_elixir_spell
Whether this spell is a regular spell from the Barracks
- Type:
bool
- is_dark_spell
Whether this spell is a dark-spell, trained in the Dark Barracks.
- Type:
bool
- is_loaded
Whether the API data has been loaded for this spell.
- Type:
bool
- level
The spell’s level
- Type:
int
- max_level
The max level for this spell.
- Type:
int
- village
Either
home
orbuilderBase
, indicating which village this spell belongs to.- Type:
str
- classmethod get_max_level_for_townhall(townhall)
Get the maximum level for a spell for a given townhall level.
- Parameters:
townhall – The townhall level to get the maximum spell level for.
- Returns:
The maximum spell level, or
None
if the spell hasn’t been unlocked at that level.- Return type:
int
- property is_max_for_townhall
bool
: Returns a boolean that indicates whether the spell is the max level for the player’s townhall level.