ANTWAR C++ SDK
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Tower Struct Reference

Defense unit. Only choice to get yourself armed to the teeth. More...

#include <common.hpp>

Public Member Functions

 Tower (int id, int player, int x, int y, TowerType type=TowerType::Basic, int cd=-1)
 Construct a new tower with given information.
 
std::vector< int > attack (std::vector< Ant > &ants)
 Try to attack ants around, and update CD time.
 
std::vector< int > find_targets (const std::vector< Ant > &ants, int target_num) const
 Find certain amount of targets and return its reference by index in order.
 
std::vector< int > find_attackable (const std::vector< Ant > &ants, const std::vector< int > &target_idxs) const
 Find all ants affected by this attack based on given targets.
 
void action (Ant &ant) const
 Cause real damage and other effects on the target.
 
std::vector< int > get_attackable_ants (const std::vector< Ant > &ants, int x, int y, int range) const
 Find all attackable ants based on given position and range.
 
bool is_ready () const
 Check if the tower is ready to attack.
 
void reset_cd ()
 Reset CD value.
 
void upgrade (TowerType new_type)
 Upgrade tower to new type and reset CD, without checking validness.
 
bool is_upgrade_type_valid (int type) const
 Check if the tower can be upgraded to a certain type.
 
void downgrade ()
 Downgrade tower to new type and reset CD, without checking validness.
 
bool is_downgrade_valid () const
 Check if the tower can be downgraded.
 

Public Attributes

int id
 
int player
 
int x
 
int y
 
TowerType type
 
int damage
 
int range
 
int cd
 Time remaining until next attack (Possibly negative)
 
double speed
 Number of rounds required for an attack.
 

Detailed Description

Defense unit. Only choice to get yourself armed to the teeth.

Constructor & Destructor Documentation

◆ Tower()

Tower::Tower ( int  id,
int  player,
int  x,
int  y,
TowerType  type = TowerType::Basic,
int  cd = -1 
)
inline

Construct a new tower with given information.

Parameters
type(Optional) Type of the tower, with TowerType::Basic as default.
cd(Optional) CD time of the tower.

Member Function Documentation

◆ action()

void Tower::action ( Ant ant) const
inline

Cause real damage and other effects on the target.

Parameters
antReference to the attacked ant.

◆ attack()

std::vector< int > Tower::attack ( std::vector< Ant > &  ants)
inline

Try to attack ants around, and update CD time.

Parameters
antsReference to all ants on the map, holding in a vector.
Returns
The indexes of attacked ants without repeat (i.e. an ant that is attacked multiple times only appears once when returned).
See also
Tower::find_targets for target searching process.

◆ find_attackable()

std::vector< int > Tower::find_attackable ( const std::vector< Ant > &  ants,
const std::vector< int > &  target_idxs 
) const
inline

Find all ants affected by this attack based on given targets.

Parameters
antsReference to all ants on the map, holding in a vector.
target_idxsIndexes of all targets.
Returns
Indexes of all ants involved, with possible duplication (i.e. an ant that is attacked multiple times appears a corresponding number of times when returned).
See also
Tower::find_targets for more information on the term "targets".

◆ find_targets()

std::vector< int > Tower::find_targets ( const std::vector< Ant > &  ants,
int  target_num 
) const
inline

Find certain amount of targets and return its reference by index in order.

Parameters
antsReference to all ants on the map, holding in a vector.
target_numHow many targets to find.
Returns
The indexes of targets.
Note
Terminology: "targets" refers to all the ants discovered by the tower when searching enemy, which is only a SUBSET of all the ants affected by this tower. For example, towers with range attack ability will find some targets and fire directly at them, which may cause damage to ants around the targets.

◆ get_attackable_ants()

std::vector< int > Tower::get_attackable_ants ( const std::vector< Ant > &  ants,
int  x,
int  y,
int  range 
) const
inline

Find all attackable ants based on given position and range.

Parameters
antsReference to all ants on the map, holding in a vector.
xThe x-coordinate of the position.
yThe y-coordinate of the position.
rangeRadius of the area to search.
Returns
Indexes of all ants involved without repeat.

◆ is_downgrade_valid()

bool Tower::is_downgrade_valid ( ) const
inline

Check if the tower can be downgraded.

Returns
Whether the tower can be downgraded.

◆ is_ready()

bool Tower::is_ready ( ) const
inline

Check if the tower is ready to attack.

Returns
Whether the tower is ready.

◆ is_upgrade_type_valid()

bool Tower::is_upgrade_type_valid ( int  type) const
inline

Check if the tower can be upgraded to a certain type.

Parameters
typeThe target type of upgrading.
Returns
Whether the tower can be upgraded to target type.

◆ upgrade()

void Tower::upgrade ( TowerType  new_type)
inline

Upgrade tower to new type and reset CD, without checking validness.

Parameters
new_typeType to be upgraded into.

The documentation for this struct was generated from the following file: