diff --git a/gamedata.cpp b/gamedata.cpp index 3af9f37..6474bac 100644 --- a/gamedata.cpp +++ b/gamedata.cpp @@ -93,7 +93,7 @@ bool GameData::add_vertex(int x, int y, int r, int colour) { Graph::add_vertex(x, y, r, colour, 10); #ifdef DEBUG - fprintf(stderr, "debug: GameData::add_vertex(): strength=%f\n", + fprintf(stderr, "debug: GameData::add_vertex(): strength=%2.f\n", calculate_strength(*(vertices.rbegin()))); #endif if (player == PLAYER1) player1_played = true; @@ -107,7 +107,7 @@ bool GameData::add_vertex(int x, int y, int r, int colour) if (Graph::add_vertex(x, y, r, colour, 10, current)) { #ifdef DEBUG - fprintf(stderr, "debug: GameData::add_vertex(): strength=%f\n", + fprintf(stderr, "debug: GameData::add_vertex(): strength=%.2f\n", calculate_strength(*(vertices.rbegin()))); #endif @@ -192,6 +192,8 @@ int GameData::get_range(Vertex* node) Vertex* v = *cursor; range -= 100 - MathUtils::distance(v->x, v->y, node->x, node->y); } + if (range < 0) range = 0; + return range; } } @@ -209,7 +211,7 @@ void GameData::attack_vertex(Vertex* target) if (target->score <= 0) remove_vertex(target); #ifdef DEBUG - fprintf(stderr, "debug: GameData::attack_vertex(): atk_str=%2.f, def_str=%2.f, armor=%2.f, damage=%d\n", atk_str, def_str, armor, damage); + fprintf(stderr, "debug: GameData::attack_vertex(): atk_str=%.2f, def_str=%.2f, armor=%.2f, damage=%d\n", atk_str, def_str, armor, damage); #endif toggle_turn();