Skip to content

Commit

Permalink
Marge con main
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinProcofio committed Nov 7, 2024
2 parents 86212cb + e8a3723 commit 7c6f37e
Show file tree
Hide file tree
Showing 32 changed files with 1,813 additions and 991 deletions.
748 changes: 405 additions & 343 deletions src/Library/Domain/Facade.cs

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/Library/Domain/GameList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,11 @@ public Player FindOpponentOfDisplayName(string playerDisplayName)
return null;
}

public Game FindGame(string playerDisplayName)
public Game FindGameByPlayerDisplayName(string playerDisplayName)
{
foreach ( Game game in games)
{
if (playerDisplayName == game.Player1.DisplayName)
{
return game;
}
else if (playerDisplayName == game.Player2.DisplayName)
if (game.Player1.DisplayName == playerDisplayName || game.Player2.DisplayName == playerDisplayName)
{
return game;
}
Expand Down
18 changes: 18 additions & 0 deletions src/Library/Domain/Item/CompleteCure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace ClassLibrary
{
public class CuraTotal : Item
{
public CuraTotal() : base("Cura total") { }

public override string ApplyEffect(Pokemon pokemon)
{
if (pokemon == null)
{
return "No hay un Pokémon activo para curar.";
}

pokemon.HealthPoints = 100;
return $"{pokemon.Name} ha sido curado completamente.";
}
}
}
23 changes: 23 additions & 0 deletions src/Library/Domain/Item/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ClassLibrary;

public class Item
{
public string Name { get; }

public Item(string name)
{
this.Name = name;
}
/// <summary>
/// Aplica el efecto del ítem en el Pokémon especificado.
/// Este método será sobrescrito por las subclases.
/// </summary>
/// <param name="pokemon">El Pokémon al que se le aplicará el efecto.</param>
/// <returns>Un mensaje con el resultado de aplicar el efecto.</returns>
public virtual string ApplyEffect(Pokemon pokemon)
{
return $"{Name} no tiene ningún efecto.";
}
}


25 changes: 25 additions & 0 deletions src/Library/Domain/Item/Revive.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace ClassLibrary
{
public class Revivir : Item
{
private const int ReviveHealth = 50;

public Revivir() : base("Revivir") { }

public override string ApplyEffect(Pokemon pokemon)
{
if (pokemon == null)
{
return "No hay un Pokémon para revivir.";
}

if (pokemon.HealthPoints > 0)
{
return $"{pokemon.Name} no puede ser revivido.";
}

pokemon.HealthPoints = ReviveHealth;
return $"{pokemon.Name} ha sido revivido con {ReviveHealth} puntos de vida.";
}
}
}
23 changes: 23 additions & 0 deletions src/Library/Domain/Item/SuperPocion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ClassLibrary
{
public class SuperPocion : Item
{
private const int HealingAmount = 70;

public SuperPocion() : base("Super pocion") { }

public override string ApplyEffect(Pokemon pokemon)
{
if (pokemon == null)
{
return "No hay un Pokémon activo para curar.";
}

int previousHealth = pokemon.HealthPoints;
pokemon.HealthPoints += HealingAmount;
int healthRestored = pokemon.HealthPoints - previousHealth;

return $"{pokemon.Name} ha recuperado {healthRestored} puntos de vida.";
}
}
}
49 changes: 0 additions & 49 deletions src/Library/Domain/Move.cs

This file was deleted.

39 changes: 39 additions & 0 deletions src/Library/Domain/Moves/Move.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace ClassLibrary;

public abstract class Move
{
/// <summary>
/// Nombre del movimiento.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Valor del ataque del movimiento.
/// </summary>
public int AttackValue { get; set; }

/// <summary>
/// El valor de precisión define la probabilidad de que el ataque se ejecute.
/// </summary>
public double Accuracy { get; set; }

/// <summary>
/// Constructor de la clase.
/// </summary>
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>
public Move(string name, int attackValue, double accuracy)

Check warning on line 25 in src/Library/Domain/Moves/Move.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'Move.Move(string, int, double)' (but other parameters do)

Check warning on line 25 in src/Library/Domain/Moves/Move.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'Move.Move(string, int, double)' (but other parameters do)
{
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;
}

/// <summary>
/// Método para aplicar el ataque considerando ambos pokemones.
/// </summary>
/// <param name="attacker">El pokemon que está atacando.</param>
/// <param name="target">El pokemon que está siendo atacado.</param>
///
public abstract void ExecuteMove(Pokemon attacker, Pokemon target, double criticalHit);

Check warning on line 38 in src/Library/Domain/Moves/Move.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'Move.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)

Check warning on line 38 in src/Library/Domain/Moves/Move.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'Move.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)
}
46 changes: 46 additions & 0 deletions src/Library/Domain/Moves/MoveBurn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ClassLibrary;


/// <summary>
/// La clase <c>MoveSleep</c> tiene la responsabilidad de almacenar y gestionar los valores de ataque, su nombre, y método de ejecución de un movimiento especial.
/// Esto sigue el principio de responsabilidad única (SRP) ya que su única función es representar los atributos de un movimiento en el juego.
/// </summary>
///
public class MoveBurn: Move
{
/// <summary>
/// Constructor de la clase <c>MoveBurn</c>. Inicializa los valores de nombre, ataque, defensa y curación.
/// Esto sigue el principio de Liskov Substitution Principle (LSP) porque permite que cualquier clase derivada de <c>MoveSleep</c> (si la hubiera)
/// pueda sustituirse sin alterar el comportamiento de la lógica del juego.
/// </summary>
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>

public MoveBurn(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)

Check warning on line 19 in src/Library/Domain/Moves/MoveBurn.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'MoveBurn.MoveBurn(string, int, double)' (but other parameters do)

Check warning on line 19 in src/Library/Domain/Moves/MoveBurn.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'MoveBurn.MoveBurn(string, int, double)' (but other parameters do)
{
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;

}

/// <summary>
/// Método para aplicar el ataque del <c>IMove</c> en particular, considerando ambos pokemones.
/// </summary>
/// <param name="attacker">El pokemon que está atacando.</param>
/// <param name="target">El pokemon que está siendo atacado.</param>
///
public override void ExecuteMove(Pokemon attacker, Pokemon target, double criticalHit)

Check warning on line 33 in src/Library/Domain/Moves/MoveBurn.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'MoveBurn.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)

Check warning on line 33 in src/Library/Domain/Moves/MoveBurn.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'MoveBurn.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)
{
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}

//Aplica al pokemon ataque de quemado
target.IsPoisoned= true;
}
}
29 changes: 29 additions & 0 deletions src/Library/Domain/Moves/MoveNormal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace ClassLibrary
{
/// <summary>
/// La clase <c>NormalMove</c> tiene la responsabilidad de almacenar y gestionar los valores de ataque, su nombre, y método de ejecución de un movimiento común.
/// Esto sigue el principio de responsabilidad única (SRP) ya que su única función es representar los atributos de un movimiento en el juego.
/// </summary>
public class MoveNormal: Move
{
public MoveNormal(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
{
this.Name = name;
this.AttackValue = attackValue;
}

/// <summary>
/// Método para aplicar el ataque considerando ambos pokemones.
/// </summary>
/// <param name="attacker">El pokemon que está atacando.</param>
/// <param name="target">El pokemon que está siendo atacado.</param>
///
public override void ExecuteMove(Pokemon attacker, Pokemon target, double criticalHit)

Check warning on line 21 in src/Library/Domain/Moves/MoveNormal.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'MoveNormal.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)

Check warning on line 21 in src/Library/Domain/Moves/MoveNormal.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'criticalHit' has no matching param tag in the XML comment for 'MoveNormal.ExecuteMove(Pokemon, Pokemon, double)' (but other parameters do)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));

target.HealthPoints -= calculatedDamage;
}
}
}
48 changes: 48 additions & 0 deletions src/Library/Domain/Moves/MoveParalize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace ClassLibrary;

/// <summary>
/// La clase <c>MoveParalize</c> tiene la responsabilidad de almacenar y gestionar los valores de ataque, su nombre, y método de ejecución de un movimiento especial.
/// Esto sigue el principio de responsabilidad única (SRP) ya que su única función es representar los atributos de un movimiento en el juego.
/// </summary>
///
public class MoveParalize: Move
{
/// <summary>
/// Constructor de la clase <c>MoveParalize</c>. Inicializa los valores de nombre, ataque, defensa y curación.
/// Esto sigue el principio de Liskov Substitution Principle (LSP) porque permite que cualquier clase derivada de <c>Move</c> (si la hubiera)
/// pueda sustituirse sin alterar el comportamiento de la lógica del juego.
/// </summary>
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>

public MoveParalize(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)

Check warning on line 18 in src/Library/Domain/Moves/MoveParalize.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'MoveParalize.MoveParalize(string, int, double)' (but other parameters do)

Check warning on line 18 in src/Library/Domain/Moves/MoveParalize.cs

View workflow job for this annotation

GitHub Actions / build-test-generate-docs

Parameter 'accuracy' has no matching param tag in the XML comment for 'MoveParalize.MoveParalize(string, int, double)' (but other parameters do)
{
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;

}

/// <summary>
/// Método para aplicar el ataque del <c>IMove</c> en particular, considerando ambos pokemones.
/// </summary>
/// <param name="attacker">El pokemon que está atacando.</param>
/// <param name="target">El pokemon que está siendo atacado.</param>
///
public override void ExecuteMove(Pokemon attacker, Pokemon target, double criticalHit)
{
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}

//Aplica al pokemon ataque de paralizar
if (!target.IsParalyzed)
{
target.IsParalyzed = true;
}
}
}
46 changes: 46 additions & 0 deletions src/Library/Domain/Moves/MovePoison.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace ClassLibrary;


/// <summary>
/// La clase <c>MovePoison</c> tiene la responsabilidad de almacenar y gestionar los valores de ataque, su nombre, y método de ejecución de un movimiento especial.
/// Esto sigue el principio de responsabilidad única (SRP) ya que su única función es representar los atributos de un movimiento en el juego.
/// </summary>
///
public class MovePoison: Move
{
/// <summary>
/// Constructor de la clase <c>MovePoison</c>. Inicializa los valores de nombre, ataque, defensa y curación.
/// Esto sigue el principio de Liskov Substitution Principle (LSP) porque permite que cualquier clase derivada de <c>MoveSleep</c> (si la hubiera)
/// pueda sustituirse sin alterar el comportamiento de la lógica del juego.
/// </summary>
/// <param name="name">El nombre del movimiento.</param>
/// <param name="attackValue">El valor de ataque del movimiento.</param>

public MovePoison(string name, int attackValue, double accuracy): base(name, attackValue, accuracy)
{
this.Name = name;
this.AttackValue = attackValue;
this.Accuracy = accuracy;

}

/// <summary>
/// Método para aplicar el ataque del <c>IMove</c> en particular, considerando ambos pokemones.
/// </summary>
/// <param name="attacker">El pokemon que está atacando.</param>
/// <param name="target">El pokemon que está siendo atacado.</param>
///
public override void ExecuteMove(Pokemon attacker, Pokemon target, double criticalHit)
{
//Aplica el ataque común
if (this.AttackValue > 0)
{
double typeEffectiveness = PokemonType.GetEffectiveness(attacker.Type, target.Type);
int calculatedDamage = (int)((this.AttackValue * typeEffectiveness)*(criticalHit));
target.HealthPoints -= calculatedDamage;
}

//Aplica al pokemon ataque de envenenado
target.IsPoisoned= true;
}
}
Loading

0 comments on commit 7c6f37e

Please sign in to comment.