C
C#4w ago
Manu

Pokemon Game SRP

Sorry I have a question about a game, I am making project for my uni about a pokemon game, the question is the next, I want to do the SRP principle of solid but I don't find a another posibility that make takedamage a method of each pokemon, is that bad? my setters are private because I don´t want them to be public, but I find that makeing and takeing damage should be a game mechanics class responsability
12 Replies
TheRanger
TheRanger4w ago
What did you try so far, can you show some code?
Omnissiah
Omnissiah4w ago
also i believe it depends on what the rules for taking damage are
Manu
ManuOP4w ago
This is my pokemon
namespace ClassLibrary;

public class Pokemon : IPokemon
{
public string Name { get; private set; }
public int Damage { get; private set; }
public int Defense { get; private set; }
public int Health { get; private set; }
public int Estado { get; private set; } // 0 es normal, 1 burn, 2 poison, 3 paralyze , 4 sleep
public string Tipo { get; private set; }


public void DecreseHealth(int valueAfterCalculation) // Resta de vida despues del calculo de daño.
{
Health -= valueAfterCalculation;
if (Health < 0) Health = 0;
}
public Pokemon(string name, int damage, int defense, int health, string tipo)
{
Name = name;
Damage = damage;
Defense = defense;
Health = health;
Tipo = tipo;
Estado = 0; // Por d el Estado es normal.
}

}
namespace ClassLibrary;

public class Pokemon : IPokemon
{
public string Name { get; private set; }
public int Damage { get; private set; }
public int Defense { get; private set; }
public int Health { get; private set; }
public int Estado { get; private set; } // 0 es normal, 1 burn, 2 poison, 3 paralyze , 4 sleep
public string Tipo { get; private set; }


public void DecreseHealth(int valueAfterCalculation) // Resta de vida despues del calculo de daño.
{
Health -= valueAfterCalculation;
if (Health < 0) Health = 0;
}
public Pokemon(string name, int damage, int defense, int health, string tipo)
{
Name = name;
Damage = damage;
Defense = defense;
Health = health;
Tipo = tipo;
Estado = 0; // Por d el Estado es normal.
}

}
some word are in spanish I reached this, not find another to make damage to my pokemon, but I find it should be a game mechanics thing
TheRanger
TheRanger4w ago
yeah there are formulas online on how to calculate a pokemon taking damage
TheRanger
TheRanger4w ago
Bulbapedia
Damage
Damage (Japanese: ダメージ damage) is a loss of a Pokémon's HP that happens as the result of a physical or special attack used against it by another Pokémon.
TheRanger
TheRanger4w ago
atleast make Estado an enum, this way you can have named integers
Manu
ManuOP4w ago
I mean if it should be a method of the pokemon I assume that yes because I don't find another way
TheRanger
TheRanger4w ago
yes it should be only a single method, you can call it TakeDamage or something that has a parameter of Pokemon or if u want to apply SRP you could put it in a class called DamageCalculator
Manu
ManuOP4w ago
Thanks you so much I am doing a uni project we should be a team but Only two of us are workings we are four so it is a very hard time
tisky1964
tisky19644w ago
@Manu what year are you I just started a c# class my first year
Manu
ManuOP4w ago
first year too
tisky1964
tisky19644w ago
@Manu Im guessing ur at uni im just taking a community class to recover from injury but we haven’t gone over constructors yet 😭
Want results from more Discord servers?
Add your server