Defense unit. Only choice to get yourself armed to the teeth.
More...
#include <common.hpp>
|
| 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.
|
|
|
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.
|
|
Defense unit. Only choice to get yourself armed to the teeth.
◆ 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. |
◆ action()
void Tower::action |
( |
Ant & |
ant | ) |
const |
|
inline |
Cause real damage and other effects on the target.
- Parameters
-
ant | Reference to the attacked ant. |
◆ attack()
Try to attack ants around, and update CD time.
- Parameters
-
ants | Reference 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()
Find all ants affected by this attack based on given targets.
- Parameters
-
ants | Reference to all ants on the map, holding in a vector. |
target_idxs | Indexes 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()
Find certain amount of targets and return its reference by index in order.
- Parameters
-
ants | Reference to all ants on the map, holding in a vector. |
target_num | How 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()
Find all attackable ants based on given position and range.
- Parameters
-
ants | Reference to all ants on the map, holding in a vector. |
x | The x-coordinate of the position. |
y | The y-coordinate of the position. |
range | Radius 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
-
type | The target type of upgrading. |
- Returns
- Whether the tower can be upgraded to target type.
◆ upgrade()
Upgrade tower to new type and reset CD, without checking validness.
- Parameters
-
new_type | Type to be upgraded into. |
The documentation for this struct was generated from the following file: