forked from jaildesigner-jailgames/jaildoctors_dilemma
Pos estava ci fent arreglos varios i m'han obligat a fer commit
This commit is contained in:
@@ -15,13 +15,13 @@
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
||||
#include "game/gameplay/scoreboard.hpp" // Para ScoreboardData
|
||||
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data
|
||||
#include "game/options.hpp" // Para Options, OptionsStats, options
|
||||
#include "utils/defines.hpp" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH
|
||||
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
|
||||
|
||||
// Constructor
|
||||
Room::Room(const std::string& room_path, std::shared_ptr<ScoreboardData> data)
|
||||
Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
||||
: data_(std::move(std::move(data))) {
|
||||
auto room = Resource::get()->getRoom(room_path);
|
||||
initializeRoom(*room);
|
||||
@@ -808,35 +808,35 @@ void Room::initRoomSurfaces() {
|
||||
}
|
||||
|
||||
// Asigna variables a una estructura RoomData
|
||||
auto Room::setRoom(Data* room, const std::string& key, const std::string& value) -> bool {
|
||||
auto Room::setRoom(Data& room, const std::string& key, const std::string& value) -> bool {
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
|
||||
try {
|
||||
if (key == "tileMapFile") {
|
||||
room->tile_map_file = value;
|
||||
room.tile_map_file = value;
|
||||
} else if (key == "name") {
|
||||
room->name = value;
|
||||
room.name = value;
|
||||
} else if (key == "bgColor") {
|
||||
room->bg_color = value;
|
||||
room.bg_color = value;
|
||||
} else if (key == "border") {
|
||||
room->border_color = value;
|
||||
room.border_color = value;
|
||||
} else if (key == "itemColor1") {
|
||||
room->item_color1 = value;
|
||||
room.item_color1 = value;
|
||||
} else if (key == "itemColor2") {
|
||||
room->item_color2 = value;
|
||||
room.item_color2 = value;
|
||||
} else if (key == "tileSetFile") {
|
||||
room->tile_set_file = value;
|
||||
room.tile_set_file = value;
|
||||
} else if (key == "roomUp") {
|
||||
room->upper_room = value;
|
||||
room.upper_room = value;
|
||||
} else if (key == "roomDown") {
|
||||
room->lower_room = value;
|
||||
room.lower_room = value;
|
||||
} else if (key == "roomLeft") {
|
||||
room->left_room = value;
|
||||
room.left_room = value;
|
||||
} else if (key == "roomRight") {
|
||||
room->right_room = value;
|
||||
room.right_room = value;
|
||||
} else if (key == "autoSurface") {
|
||||
room->conveyor_belt_direction = (value == "right") ? 1 : -1;
|
||||
room.conveyor_belt_direction = (value == "right") ? 1 : -1;
|
||||
} else if (key.empty() || key.substr(0, 1) == "#") {
|
||||
// No se realiza ninguna acción para estas claves
|
||||
} else {
|
||||
@@ -851,37 +851,37 @@ auto Room::setRoom(Data* room, const std::string& key, const std::string& value)
|
||||
}
|
||||
|
||||
// Asigna variables a una estructura EnemyData
|
||||
auto Room::setEnemy(Enemy::Data* enemy, const std::string& key, const std::string& value) -> bool {
|
||||
auto Room::setEnemy(Enemy::Data& enemy, const std::string& key, const std::string& value) -> bool {
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
|
||||
try {
|
||||
if (key == "animation") {
|
||||
enemy->animation_path = value;
|
||||
enemy.animation_path = value;
|
||||
} else if (key == "x") {
|
||||
enemy->x = std::stof(value) * TILE_SIZE;
|
||||
enemy.x = std::stof(value) * TILE_SIZE;
|
||||
} else if (key == "y") {
|
||||
enemy->y = std::stof(value) * TILE_SIZE;
|
||||
enemy.y = std::stof(value) * TILE_SIZE;
|
||||
} else if (key == "vx") {
|
||||
enemy->vx = std::stof(value);
|
||||
enemy.vx = std::stof(value);
|
||||
} else if (key == "vy") {
|
||||
enemy->vy = std::stof(value);
|
||||
enemy.vy = std::stof(value);
|
||||
} else if (key == "x1") {
|
||||
enemy->x1 = std::stoi(value) * TILE_SIZE;
|
||||
enemy.x1 = std::stoi(value) * TILE_SIZE;
|
||||
} else if (key == "x2") {
|
||||
enemy->x2 = std::stoi(value) * TILE_SIZE;
|
||||
enemy.x2 = std::stoi(value) * TILE_SIZE;
|
||||
} else if (key == "y1") {
|
||||
enemy->y1 = std::stoi(value) * TILE_SIZE;
|
||||
enemy.y1 = std::stoi(value) * TILE_SIZE;
|
||||
} else if (key == "y2") {
|
||||
enemy->y2 = std::stoi(value) * TILE_SIZE;
|
||||
enemy.y2 = std::stoi(value) * TILE_SIZE;
|
||||
} else if (key == "flip") {
|
||||
enemy->flip = stringToBool(value);
|
||||
enemy.flip = stringToBool(value);
|
||||
} else if (key == "mirror") {
|
||||
enemy->mirror = stringToBool(value);
|
||||
enemy.mirror = stringToBool(value);
|
||||
} else if (key == "color") {
|
||||
enemy->color = value;
|
||||
enemy.color = value;
|
||||
} else if (key == "frame") {
|
||||
enemy->frame = std::stoi(value);
|
||||
enemy.frame = std::stoi(value);
|
||||
} else if (key == "[/enemy]" || key == "tileSetFile" || key.substr(0, 1) == "#") {
|
||||
// No se realiza ninguna acción para estas claves
|
||||
} else {
|
||||
@@ -896,21 +896,21 @@ auto Room::setEnemy(Enemy::Data* enemy, const std::string& key, const std::strin
|
||||
}
|
||||
|
||||
// Asigna variables a una estructura ItemData
|
||||
auto Room::setItem(Item::Data* item, const std::string& key, const std::string& value) -> bool {
|
||||
auto Room::setItem(Item::Data& item, const std::string& key, const std::string& value) -> bool {
|
||||
// Indicador de éxito en la asignación
|
||||
bool success = true;
|
||||
|
||||
try {
|
||||
if (key == "tileSetFile") {
|
||||
item->tile_set_file = value;
|
||||
item.tile_set_file = value;
|
||||
} else if (key == "counter") {
|
||||
item->counter = std::stoi(value);
|
||||
item.counter = std::stoi(value);
|
||||
} else if (key == "x") {
|
||||
item->x = std::stof(value) * TILE_SIZE;
|
||||
item.x = std::stof(value) * TILE_SIZE;
|
||||
} else if (key == "y") {
|
||||
item->y = std::stof(value) * TILE_SIZE;
|
||||
item.y = std::stof(value) * TILE_SIZE;
|
||||
} else if (key == "tile") {
|
||||
item->tile = std::stof(value);
|
||||
item.tile = std::stof(value);
|
||||
} else if (key == "[/item]") {
|
||||
// No se realiza ninguna acción para esta clave
|
||||
} else {
|
||||
@@ -1017,7 +1017,7 @@ auto Room::loadRoomFile(const std::string& file_path, bool verbose) -> Data {
|
||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||
else {
|
||||
auto [key, value] = parseKeyValue(line);
|
||||
if (!setRoom(&room, key, value)) {
|
||||
if (!setRoom(room, key, value)) {
|
||||
logUnknownParameter(FILE_NAME, key, verbose);
|
||||
}
|
||||
}
|
||||
@@ -1064,7 +1064,7 @@ auto Room::loadEnemyFromFile(std::istream& file, const std::string& file_name, b
|
||||
}
|
||||
auto [key, value] = parseKeyValue(line);
|
||||
|
||||
if (!setEnemy(&enemy, key, value)) {
|
||||
if (!setEnemy(enemy, key, value)) {
|
||||
logUnknownParameter(file_name, key, verbose);
|
||||
}
|
||||
} while (line != "[/enemy]");
|
||||
@@ -1088,7 +1088,7 @@ auto Room::loadItemFromFile(std::istream& file, const std::string& file_name, bo
|
||||
}
|
||||
auto [key, value] = parseKeyValue(line);
|
||||
|
||||
if (!setItem(&item, key, value)) {
|
||||
if (!setItem(item, key, value)) {
|
||||
logUnknownParameter(file_name, key, verbose);
|
||||
}
|
||||
} while (line != "[/item]");
|
||||
|
||||
Reference in New Issue
Block a user