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