Skip to content

Commit

Permalink
merge con main
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianCuneo committed Nov 15, 2024
2 parents ea80880 + e6abb4a commit 5583db9
Show file tree
Hide file tree
Showing 18 changed files with 450 additions and 322 deletions.
4 changes: 2 additions & 2 deletions src/Library/Domain/Domain/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Game(Player player1, Player player2)
Player1.SetOpponent(Player2);
Player2.SetOpponent(Player1);
}

/// <summary>
/// Verifica si el juego debe terminar revisando si todos los Pokémon de alguno de los jugadores tienen 0 puntos de vida.
/// Si un jugador pierde todos sus Pokémon, el juego termina y se declara un ganador.
Expand All @@ -81,7 +81,7 @@ public void CheckIfGameEnds()
todosSonCeroPlayer1 = false;
}
}

// Verificamos si todos los Pokémon del jugador 2 tienen 0 puntos de vida
bool todosSonCeroPlayer2 = true; // Player2.AvailablePokemons.All(pokemon => pokemon.HealthPoints == 0);
foreach (Pokemon pokemon in Player2.AvailablePokemons)
Expand Down
3 changes: 1 addition & 2 deletions src/Library/Domain/Domain/UserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ public class UserInterface
public static string ShowMessagePokemonCatalog()
{
PokemonCatalogBuilder pokemons = new PokemonCatalogBuilder();
List<Pokemon> pokemonList = pokemons.GetPokemonList();

StringBuilder catalogo = new StringBuilder();
catalogo.AppendLine("📜 Catálogo de Pokémon:\n");

foreach (Pokemon pokemon in pokemonList)
foreach (Pokemon pokemon in pokemons.PokemonList)
{
catalogo.AppendLine($"{pokemon.Name}");
}
Expand Down
25 changes: 24 additions & 1 deletion src/Library/Domain/Move/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ public string Name
}
}


/// <summary>
/// Obtiene o establece el tipo del Ataque.
/// </summary>

private Type _moveType;

public Type MoveType
{
get => _moveType;
set
{
if (!Enum.IsDefined(typeof(Type), value))
{
throw new ArgumentException("El tipo de movimiento no es válido.");
}

_moveType = value;
}
}


/// <summary>
/// Valor del ataque del movimiento.
/// </summary>
Expand Down Expand Up @@ -61,8 +83,9 @@ public double Accuracy
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de precisión del movimiento.</param>
public Move(string name, int attackValue, double accuracy)
public Move(string name, int attackValue, double accuracy, Type moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand Down
5 changes: 3 additions & 2 deletions src/Library/Domain/Move/MoveBurn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class MoveBurn: Move
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de la precisión del movimiento.</param>
public MoveBurn(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
public MoveBurn(string name, int attackValue, double accuracy, Type moveType): base(name, attackValue, accuracy, moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand All @@ -40,7 +41,7 @@ public override void ExecuteMove(Pokemon attacker, Pokemon target, double critic
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
double typeEffectiveness = EffectivenessTable.GetEffectiveness(this.MoveType, target.PokemonType);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Library/Domain/Move/MoveNormal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public class MoveNormal: Move
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de la precisión del movimiento.</param>
public MoveNormal(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
public MoveNormal(string name, int attackValue, double accuracy, Type moveType): base(name, attackValue, accuracy, moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand All @@ -35,7 +36,7 @@ public override void ExecuteMove(Pokemon attacker, Pokemon target, double critic
if (this.AttackValue <= 0)
throw new InvalidOperationException("El valor de ataque debe ser mayor que cero.");

double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
double typeEffectiveness = EffectivenessTable.GetEffectiveness(this.MoveType, target.PokemonType);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));

target.HealthPoints -= calculatedDamage;
Expand Down
5 changes: 3 additions & 2 deletions src/Library/Domain/Move/MoveParalize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ public class MoveParalize: Move
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de la precisión del movimiento.</param>
public MoveParalize(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
public MoveParalize(string name, int attackValue, double accuracy, Type moveType): base(name, attackValue, accuracy, moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand All @@ -41,7 +42,7 @@ public override void ExecuteMove(Pokemon attacker, Pokemon target, double critic
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
double typeEffectiveness = EffectivenessTable.GetEffectiveness(this.MoveType, target.PokemonType);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Library/Domain/Move/MovePoison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public class MovePoison: Move
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de la precisión del movimiento.</param>

public MovePoison(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
public MovePoison(string name, int attackValue, double accuracy, Type moveType): base(name, attackValue, accuracy, moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand All @@ -43,7 +44,7 @@ public override void ExecuteMove(Pokemon attacker, Pokemon target, double critic
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
double typeEffectiveness = EffectivenessTable.GetEffectiveness(this.MoveType, target.PokemonType);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Library/Domain/Move/MoveSleep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class MoveSleep: Move
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
/// <param name="accuracy">El valor de la precisión del movimiento.</param>
public MoveSleep(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
public MoveSleep(string name, int attackValue, double accuracy, Type moveType): base(name, attackValue, accuracy, moveType)
{
this.MoveType = moveType;
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
Expand All @@ -43,7 +44,7 @@ public override void ExecuteMove(Pokemon attacker, Pokemon target, double critic
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
double typeEffectiveness = EffectivenessTable.GetEffectiveness(this.MoveType, target.PokemonType);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
namespace ClassLibrary;

using System.Collections.Generic;


/// <summary>
/// Enumeración que define los tipos de Pokémon.
/// </summary>
public enum Type
{
Water, Bug, Dragon, Electric, Ghost, Fire,
Ice, Fighting, Normal, Grass, Psychic, Rock,
Ground, Poison, Flying
}

/// <summary>
/// La clase <c>PokemonType</c> es responsable de gestionar los tipos de Pokémon y su efectividad en combates.
/// Aplica el principio de responsabilidad única (SRP) al enfocarse exclusivamente en la lógica de tipos y
Expand All @@ -12,19 +24,8 @@ namespace ClassLibrary;
/// La robustez y seguridad de esta clase se aseguran al validar la existencia de combinaciones de tipos y evitar
/// estados inválidos, facilitando la detección y manejo de errores en el uso de esta clase.
/// </summary>

public static class PokemonType
public static class EffectivenessTable
{
/// <summary>
/// Enumeración que define los tipos de Pokémon.
/// </summary>
public enum Type
{
Water, Bug, Dragon, Electric, Ghost, Fire,
Ice, Fighting, Normal, Grass, Psychic, Rock,
Ground, Poison, Flying
}

private static Dictionary<(Type, Type), double> typeEffectiveness = new Dictionary<(Type, Type), double>()
{
// Water defender
Expand Down
Loading

0 comments on commit 5583db9

Please sign in to comment.