Added code to prevent attacking more than once per attacker per round
This commit is contained in:
parent
06902c4377
commit
c235d79dac
12
gamedata.cpp
12
gamedata.cpp
|
@ -71,6 +71,13 @@ void GameData::toggle_turn()
|
|||
}
|
||||
}
|
||||
|
||||
for (list<Vertex*>::iterator cursor = vertices.begin();
|
||||
cursor != vertices.end(); cursor++)
|
||||
{
|
||||
GameVertex* v = dynamic_cast<GameVertex*>(*cursor);
|
||||
v->attacked = false;
|
||||
}
|
||||
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
|
@ -245,17 +252,22 @@ int GameData::get_range(GameVertex* node)
|
|||
|
||||
|
||||
void GameData::attack_vertex(GameVertex* target)
|
||||
{
|
||||
if (!current->attacked)
|
||||
{
|
||||
float atk = current->calculate_attack();
|
||||
float armor = target->calculate_armor();
|
||||
int damage = (int)(atk / armor);
|
||||
target->score -= damage;
|
||||
if (target->score <= 0) remove_vertex(target);
|
||||
current->attacked = true;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "debug: GameData::attack_vertex(): atk=%.2f, armor=%.2f, damage=%d\n", atk, armor, damage);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
mode = MODE_SELECT;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class GameVertex : public Vertex
|
|||
|
||||
VertexType type;
|
||||
Player* player;
|
||||
bool attacked; // only applicable for a VERTEX_ATTACKER
|
||||
|
||||
float calculate_attack();
|
||||
float calculate_armor();
|
||||
|
|
Loading…
Reference in New Issue
Block a user