Added code to prevent attacking more than once per attacker per round

This commit is contained in:
Anna Rose 2011-07-04 03:09:36 -04:00
parent 06902c4377
commit c235d79dac
2 changed files with 20 additions and 7 deletions

View File

@ -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;
}

View File

@ -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();