Im creating a class that has all of my data in and can see it would quickly become messy.
I feel that there must be a way of making it neater rather than making a new method each time
For example. I have a character that out of the huge skill list each with different values for different things, they just have 1h weapon and shield. I declare this by
Character character = new Character();
character.Skills.Add(Skill.OneHanded());
character.Skills.Add(Skill.Shield());
it also makes it fairly easy if they level up and learn a new skill as i can just do
character.Skills.Add(Skill.Polearm());
however currently my Skill class looks like a mess. (note that there will be many more skills (about 30 in total) and each one will have more attributes such as applicable weapons, level requirements etc, but not currently coded.
public class Skill
{
public string Description { get; set; }
public bool Advanced{ get; set; }
public int PointsToLearn{ get; set; }
public static Skill OneHanded()
{
return new Skill
{
Description = "Skill needed for the use of one handed weapons",
Advanced = false,
PointsToLearn= 1
};
}
public static Skill TwoHanded()
{
return new Skill
{
Description = "Skill needed for use of two handed weapons.",
Advanced= false,
PointsToLearn = 2
};
}
public static Skill Polearm()
{
return new Skill
{
Description = "Skill needed for use of polearms",
Advanced = false,
PointsToLearn = 3
};
}
public static Skill Shield()
{
return new Skill
{
Description = "Skill needed to use shields",
Advanced = false,
PointsToLearn = 1
};
}
public static Skill ResistMagic()
{
return new Skill
{
Description = "Negates the first spell cast at the character",
Advanced = true,
PointsToLearn = 0
};
}
}
As requested the Character class is
class Character
{
public List<Skill> Skills = new List<Skill>();
public int Level { get; set; }
public string Name { get; set; }
public int Command { get; set; }
public int Coordination { get; set; }
public int Reflex { get; set; }
}
There are many characters (i guess think fire emblem if you have ever played that) each one can be skilled and levelled (and die) independently . The class is mostly to keep a record of all characters that have joined the players mercenary company, with their current skills, attributes, level etc etc.
It will called when ever a new character joins the company and added to a character list and then remain in the list ready to be called with the attributes of the character when needing to know information about them.
is there a way to simply this? I also got advised I could do
public class Skill
{
public enum Skills{ OneHanded,TwoHanded,Polearm,Shield};
}
which opens up using Skill.Skills."Skill" but I'm not sure how I would set the data against each of the options.
Character
? How is it implemented? \$\endgroup\$ – t3chb0t Apr 27 '18 at 14:37