eliminades referencies antigues

This commit is contained in:
2026-04-07 10:06:42 +02:00
parent 158affe1f9
commit 39170a086e
13 changed files with 28 additions and 1302 deletions

View File

@@ -19,7 +19,6 @@
#include "core/system/global_events.hpp" // Para check
#include "game/defaults.hpp" // Para Defaults::Game
#include "game/game_control.hpp" // Para GameControl
#include "game/gameplay/cheevos.hpp" // Para Cheevos
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
#include "game/gameplay/room.hpp" // Para Room, RoomData
#include "game/gameplay/room_tracker.hpp" // Para RoomTracker
@@ -39,7 +38,7 @@
// Constructor
Game::Game(Mode mode)
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks(), Options::cheats.jail_is_open == Options::Cheat::State::ENABLED)),
: scoreboard_data_(std::make_shared<Scoreboard::Data>(0, 9, 0, true, 0, SDL_GetTicks())),
scoreboard_(std::make_shared<Scoreboard>(scoreboard_data_)),
room_tracker_(std::make_shared<RoomTracker>()),
mode_(mode),
@@ -69,13 +68,9 @@ Game::Game(Mode mode)
demoInit();
room_ = std::make_shared<Room>(current_room_, scoreboard_data_);
initPlayer(spawn_data_, room_);
total_items_ = getTotalItems();
game_backbuffer_surface_ = std::make_shared<Surface>(Options::game.width, Options::game.height);
changeRoom(current_room_);
Cheevos::get()->enable(!Options::cheats.enabled()); // Deshabilita los logros si hay trucos activados
Cheevos::get()->clearUnobtainableState();
#ifdef _DEBUG
Console::get()->setScope("debug");
@@ -335,8 +330,7 @@ void Game::updatePlaying(float delta_time) {
checkPlayerAndItems();
checkPlayerAndEnemies();
checkIfPlayerIsAlive();
checkEndGame();
checkSomeCheevos();
// Avanzar transición
if (transitioning_) {
@@ -884,9 +878,6 @@ void Game::killPlayer() {
--scoreboard_data_->lives;
}
// Invalida el logro de pasarse el juego sin morir
Cheevos::get()->setUnobtainable(11);
// Sonido
Audio::get()->playSound("death.wav", Audio::Group::GAME);
@@ -906,41 +897,6 @@ void Game::setScoreBoardColor() { // NOLINT(readability-convert-member-function
scoreboard_data_->color = IS_BLACK || IS_BRIGHT_BLACK ? 14 : BORDER_COLOR;
}
// Comprueba si ha finalizado el juego
auto Game::checkEndGame() -> bool {
const bool IS_ON_THE_ROOM = room_->getNumber() == Defaults::Game::Room::END_ROOM; // Estar en la habitación que toca
const bool HAVE_THE_ITEMS =
scoreboard_data_->items >= int(total_items_ * Defaults::Game::Items::PERCENT_TO_OPEN_THE_JAIL) ||
Options::cheats.jail_is_open == Options::Cheat::State::ENABLED; // Con mas del 90% de los items recogidos
const bool IS_ON_THE_DOOR = player_->getRect().x <= 128; // Y en la ubicación que toca (En la puerta)
scoreboard_data_->jail_is_open = HAVE_THE_ITEMS;
if (HAVE_THE_ITEMS && IS_ON_THE_ROOM && IS_ON_THE_DOOR) {
// Comprueba los logros de completar el juego
checkEndGameCheevos();
// Iniciar transición de fade en vez de cambio inmediato de escena
transitionToState(State::FADE_TO_ENDING);
Audio::get()->fadeOutMusic(1000); // Fade out de música en 1 segundo
return true;
}
return false;
}
// Obtiene la cantidad total de items que hay en el mapeado del juego
auto Game::getTotalItems() -> int {
int items = 0;
auto rooms = Resource::Cache::get()->getRooms();
for (const auto& room : rooms) {
items += room.room->items.size();
}
return items;
}
// Pone el juego en pausa
void Game::togglePause() {
paused_ = !paused_;
@@ -950,63 +906,6 @@ void Game::togglePause() {
scoreboard_->setPaused(paused_);
}
// Comprueba algunos logros
void Game::checkSomeCheevos() { // NOLINT(readability-convert-member-functions-to-static)
auto* cheevos = Cheevos::get();
// Logros sobre la cantidad de items
if (scoreboard_data_->items == total_items_) {
cheevos->unlock(4);
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.75F) {
cheevos->unlock(3);
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.5F) {
cheevos->unlock(2);
cheevos->unlock(1);
} else if (scoreboard_data_->items >= total_items_ * 0.25F) {
cheevos->unlock(1);
}
// Logros sobre las habitaciones visitadas
if (scoreboard_data_->rooms >= 60) {
cheevos->unlock(7);
cheevos->unlock(6);
cheevos->unlock(5);
} else if (scoreboard_data_->rooms >= 40) {
cheevos->unlock(6);
cheevos->unlock(5);
} else if (scoreboard_data_->rooms >= 20) {
cheevos->unlock(5);
}
}
// Comprueba los logros de completar el juego
void Game::checkEndGameCheevos() { // NOLINT(readability-convert-member-functions-to-static)
auto* cheevos = Cheevos::get();
// "Complete the game"
cheevos->unlock(8);
// "Complete the game without entering the jail"
cheevos->unlock(9);
// "Complete the game with all items"
if (scoreboard_data_->items == total_items_) {
cheevos->unlock(10);
}
// "Complete the game without dying"
cheevos->unlock(11);
// "Complete the game in under 30 minutes"
if (scoreboard_->getMinutes() < 30) {
cheevos->unlock(12);
}
}
// Inicializa al jugador
void Game::initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room) { // NOLINT(readability-convert-member-functions-to-static)