I am in the planning phase of a small RPG style game.
The character will have have a set of attributes, like strength, agility, etc which are represented as integers. The character also will have a set of attacks represented as an attack class.
On each attack I want it to do damage based on the characters attributes, eg: the attack "sword slash" will do 10 dmg + the value of the characters strength.
The way I was thinking to do this is to have an abstract attack class, which has an abstract Attack method, and for each attack I create one class that implements the Attack method.
public class SwordSlash:Attack
{
public void Attack(Character attacker, Character defender)
{
defender.DoDamage(10 + attacker.Strength);
}
}
I see that this will make it a nightmare to maintain.
Does anyone have an idea of how I can accomplish this in a nicer way?
What I think is the main problem is how to input the correct attribute, based on the attack.