-
Notifications
You must be signed in to change notification settings - Fork 44
Implementacion clases Queue y Stack #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #ifndef CARAVAN_HPP | ||
| #define CARAVAN_HPP | ||
|
|
||
| #include "artefactoUnico.hpp" | ||
| #include "entidadGenerica.hpp" | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| /** | ||
| * @class Caravana | ||
| * @brief Representa a los comerciantes itinerantes de artefactos únicos. | ||
| * | ||
| * La caravana viaja por el yermo ofreciendo artículos extremadamente raros a precios elevados. | ||
| */ | ||
| class Caravana : public EntidadGenerica | ||
| { | ||
| private: | ||
| std::vector<std::shared_ptr<ArtefactoUnico>> m_stock; ///< Lista de artefactos únicos disponibles | ||
| bool m_confia; ///< Confianza en el refugio | ||
|
|
||
| public: | ||
| /** | ||
| * @brief Constructor | ||
| * @param nombre Nombre de la caravana | ||
| * @param confia Indica si la caravana está dispuesta a comerciar | ||
| */ | ||
| Caravana(const std::string& nombre, bool confia) | ||
| : EntidadGenerica(nombre) | ||
| , m_confia(confia) | ||
| { | ||
| inicializarStock(); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Muestra el inventario de la caravana | ||
| */ | ||
| void showInfo() const override | ||
| { | ||
| std::cout << "🚚 Caravana: " << m_name << "\n"; | ||
| std::cout << " - Confianza: " << (m_confia ? "Sí" : "No") << "\n"; | ||
| std::cout << " - Artefactos disponibles:\n"; | ||
| for (const auto& item : m_stock) | ||
| { | ||
| item->showInfo(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Intenta comprar un artefacto | ||
| * @param nombre Nombre del artefacto | ||
| * @return Puntero al artefacto si se realizó la transacción, nullptr en caso contrario | ||
| */ | ||
| std::shared_ptr<ArtefactoUnico> comprarArtefacto(const std::string& nombre) | ||
| { | ||
| if (!m_confia) | ||
| { | ||
| std::cout << "💬 " << m_name << " >>> No confiamos lo suficiente en tu refugio para hacer negocios." | ||
| << std::endl; | ||
| return nullptr; | ||
| } | ||
|
|
||
| for (auto it = m_stock.begin(); it != m_stock.end(); ++it) | ||
| { | ||
| // if ((*it)->nombre() == nombre) | ||
| // { | ||
| // std::cout << "💬 " << m_name << " >>> Excelente elección. Espero que lo uses bien." << std::endl; | ||
| // auto item = *it; | ||
| // m_stock.erase(it); | ||
| // return item; | ||
| // } | ||
| } | ||
|
|
||
| std::cout << "💬 " << m_name << " >>> No tenemos ese artefacto en este momento." << std::endl; | ||
| return nullptr; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Simula una evaluación de confianza futura | ||
| */ | ||
| void evaluarConfianza() | ||
| { | ||
| m_confia = true; // Lógica temporal, puede depender del nivel del refugio | ||
| } | ||
|
|
||
| private: | ||
| void inicializarStock() | ||
| { | ||
| // m_stock.emplace_back(std::make_shared<ArtefactoUnico>("Detector de Radiación", "Herramienta", "Épico", 250.0)); | ||
| // m_stock.emplace_back(std::make_shared<ArtefactoUnico>("Pistola Láser Táctica", "Arma", "Legendaria", 400.0)); | ||
| // m_stock.emplace_back(std::make_shared<ArtefactoUnico>("Batería de Fusión", "Energía", "Rara", 320.0)); | ||
| } | ||
| }; | ||
|
|
||
| #endif // CARAVAN_HPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // | ||
| // Created by gvalenzuela on 3/30/25. | ||
| // | ||
|
|
||
| #ifndef CHRACTERVISITANT_HPP | ||
| #define CHRACTERVISITANT_HPP | ||
|
|
||
| #include "characters/artefactoUnico.hpp" | ||
| #include "characters/asaltante.hpp" | ||
| #include "characters/caravana.hpp" | ||
| #include "characters/enclave.hpp" | ||
| #include "characters/ghoul.hpp" | ||
| #include "characters/hermanosDeAcero.hpp" | ||
| #include "characters/mercader.hpp" | ||
| #include "characters/mercaderAgua.hpp" | ||
| #include "characters/mutantes.hpp" | ||
| #include "characters/refugiado.hpp" | ||
| #include "characters/refugio.hpp" | ||
| #include "characters/saqueador.hpp" | ||
|
|
||
| using VisitanteVariant = std::variant< | ||
| Refugiado, | ||
| Mercader, | ||
| MercaderAgua, | ||
| Saqueador, | ||
| HermanoAcero, | ||
| Enclave, | ||
| Mutante, | ||
| Asaltante, | ||
| Ghoul, | ||
| Caravana | ||
| >; | ||
|
|
||
| namespace NPC { | ||
| enum class VisitantCategory | ||
| { | ||
| REFUGEE, | ||
| BROTHER, | ||
| ENEMY, | ||
| MERCHANT, | ||
| CARAVAN | ||
| }; | ||
|
|
||
| struct VisitantChance | ||
| { | ||
| VisitantCategory type; | ||
| double weight; | ||
| }; | ||
| }; | ||
|
|
||
| #endif //CHRACTERVISITANT_HPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #ifndef HERMANO_ACERO_HPP | ||
| #define HERMANO_ACERO_HPP | ||
|
|
||
| #include "entidadGenerica.hpp" | ||
| #include <iostream> | ||
|
|
||
| /** | ||
| * @class HermanoAcero | ||
| * @brief Representa a un miembro de la Hermandad del Acero. | ||
| * | ||
| * Poseen entrenamiento militar avanzado y pueden usar artefactos únicos. | ||
| * Requieren muchos recursos y son estrictos con su permanencia en un refugio. | ||
| */ | ||
| class HermanoAcero : public EntidadGenerica | ||
| { | ||
| private: | ||
| int m_entrenamiento; ///< Nivel de entrenamiento (impacta en defensa del refugio) | ||
| double m_suministros; ///< Recursos necesarios para mantenerlo | ||
| bool m_enRefugio; ///< Si actualmente vive en un refugio | ||
| int m_consumoMinimo; ///< Cuántos recursos necesita por turno | ||
|
|
||
| public: | ||
| /** | ||
| * @brief Constructor | ||
| * @param nombre Nombre del miembro | ||
| * @param entrenamiento Nivel de habilidad (100 por defecto) | ||
| */ | ||
| HermanoAcero(const std::string& nombre, int entrenamiento = 100) | ||
| : EntidadGenerica(nombre) | ||
| , m_entrenamiento(entrenamiento) | ||
| , m_suministros(0.20f) // 20% de los suministros del refugio | ||
| , m_enRefugio(false) | ||
| , m_consumoMinimo(20) // el doble de lo estándar | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @brief Muestra información del hermano del acero | ||
| */ | ||
| void showInfo() const override | ||
| { | ||
| std::cout << "⚙️ Hermano del Acero: " << m_name << "\n" | ||
| << " - Nivel de entrenamiento: " << m_entrenamiento << "\n" | ||
| << " - Suministros actuales: " << m_suministros << "\n" | ||
| << " - En refugio: " << (m_enRefugio ? "Sí" : "No") << "\n"; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Intenta ingresar al refugio | ||
| * @param recursosDisponibles Recursos disponibles del refugio | ||
| * @return Recursos consumidos, o 0 si no fue aceptado | ||
| */ | ||
| int solicitarIngreso(int recursosDisponibles) | ||
| { | ||
| if (recursosDisponibles >= m_consumoMinimo) | ||
| { | ||
| m_enRefugio = true; | ||
| std::cout << "💬" << m_name << " >>> Por la tecnología, serviré a este refugio." << std::endl; | ||
| return m_consumoMinimo; | ||
| } | ||
| else | ||
| { | ||
| std::cout << "💬" << m_name << " >>> Sus recursos no están a la altura de la Hermandad." << std::endl; | ||
| return 0; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Consume recursos cada ciclo, si no hay suficientes abandona el refugio | ||
| */ | ||
| void consumir() | ||
| { | ||
| if (m_suministros >= m_consumoMinimo) | ||
| { | ||
| m_suministros -= m_consumoMinimo; | ||
| std::cout << "💬" << m_name << " >>> Reabastecido. Listo para defender." << std::endl; | ||
| } | ||
| else | ||
| { | ||
| m_enRefugio = false; | ||
| std::cout << "💬" << m_name << " >>> Sin suministros. Este refugio no merece protección." << std::endl; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Saber si está aún en el refugio | ||
| */ | ||
| bool estaEnRefugio() const | ||
| { | ||
| return m_enRefugio; | ||
| } | ||
| }; | ||
|
|
||
| #endif // HERMANO_ACERO_HPP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto es redundante, la línea 15 ya lo hace :)