neteja cppcheck: inicialitza Menu::h_, renomena macro PAUSE a DEBUG_PAUSE, const*
This commit is contained in:
+13
-15
@@ -63,8 +63,8 @@ Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo
|
||||
// Pasa variables
|
||||
this->demo_.enabled = demo;
|
||||
this->num_players_ = num_players;
|
||||
#ifdef PAUSE
|
||||
this->currentStage = 3;
|
||||
#ifdef DEBUG_PAUSE
|
||||
this->current_stage_ = 3;
|
||||
#else
|
||||
this->current_stage_ = current_stage;
|
||||
#endif
|
||||
@@ -106,7 +106,7 @@ Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Game'
|
||||
init();
|
||||
#ifdef PAUSE
|
||||
#ifdef DEBUG_PAUSE
|
||||
pause = false;
|
||||
#endif
|
||||
}
|
||||
@@ -270,10 +270,8 @@ void Game::init() {
|
||||
balloons_popped_ += stage_[i].power_to_complete;
|
||||
}
|
||||
|
||||
total_power_to_complete_game_ = 0;
|
||||
for (auto &i : stage_) {
|
||||
total_power_to_complete_game_ += i.power_to_complete;
|
||||
}
|
||||
total_power_to_complete_game_ = std::accumulate(std::begin(stage_), std::end(stage_), 0,
|
||||
[](int acc, const auto &s) { return acc + s.power_to_complete; });
|
||||
|
||||
// Modo demo
|
||||
demo_.recording = false;
|
||||
@@ -1321,7 +1319,7 @@ void Game::setHiScore(Uint32 score) {
|
||||
// Actualiza el valor de hiScore en caso necesario
|
||||
void Game::updateHiScore() {
|
||||
// Si la puntuación actual es mayor que la máxima puntuación
|
||||
for (auto *player : players_) {
|
||||
for (const auto *player : players_) {
|
||||
if (player->getScore() > hi_score_) {
|
||||
// Actualiza la máxima puntuación
|
||||
hi_score_ = player->getScore();
|
||||
@@ -1511,7 +1509,7 @@ void Game::updateStage() {
|
||||
void Game::updateDeath() {
|
||||
// Comprueba si todos los jugadores estan muertos
|
||||
bool all_dead = true;
|
||||
for (auto *player : players_) {
|
||||
for (const auto *player : players_) {
|
||||
all_dead &= (!player->isAlive());
|
||||
}
|
||||
|
||||
@@ -2185,7 +2183,7 @@ void Game::updateDeathSequence() {
|
||||
|
||||
// Calcula y establece el valor de amenaza en funcion de los globos activos
|
||||
void Game::evaluateAndSetMenace() {
|
||||
menace_current_ = std::accumulate(balloons_.begin(), balloons_.end(), Uint8(0), [](Uint8 acc, Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; });
|
||||
menace_current_ = std::accumulate(balloons_.begin(), balloons_.end(), Uint8(0), [](Uint8 acc, const Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; });
|
||||
}
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
@@ -2732,7 +2730,7 @@ void Game::iterate() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PAUSE
|
||||
#ifdef DEBUG_PAUSE
|
||||
if (!pause)
|
||||
update();
|
||||
#else
|
||||
@@ -2761,7 +2759,7 @@ void Game::handleEvent(const SDL_Event *event) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PAUSE
|
||||
#ifdef DEBUG_PAUSE
|
||||
if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
if (event->key.scancode == SDL_SCANCODE_P) {
|
||||
pause = !pause;
|
||||
@@ -3044,7 +3042,7 @@ auto Game::canPowerBallBeCreated() -> bool {
|
||||
|
||||
// Calcula el poder actual de los globos en pantalla
|
||||
auto Game::calculateScreenPower() -> int {
|
||||
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int acc, Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; });
|
||||
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int acc, const Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; });
|
||||
}
|
||||
|
||||
// Inicializa las variables que contienen puntos de ruta para mover objetos
|
||||
@@ -3121,7 +3119,7 @@ void Game::updateGameCompleted() {
|
||||
void Game::updateHelper() {
|
||||
// Solo ofrece ayuda cuando la amenaza es elevada
|
||||
if (menace_current_ > 15) {
|
||||
for (auto *player : players_) {
|
||||
for (const auto *player : players_) {
|
||||
helper_.need_coffee = player->getCoffees() == 0;
|
||||
|
||||
helper_.need_coffee_machine = !player->isPowerUp();
|
||||
@@ -3135,7 +3133,7 @@ void Game::updateHelper() {
|
||||
// Comprueba si todos los jugadores han muerto
|
||||
auto Game::allPlayersAreDead() -> bool {
|
||||
bool success = true;
|
||||
for (auto *player : players_) {
|
||||
for (const auto *player : players_) {
|
||||
success &= (!player->isAlive());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user