Runescape-like trainable skills, enums or something else?

Hey all - I just have a structure / organization question. I’m working on a very basic RPG auto battler that has trainable skills like the game Runescape. E.g., Attack, Mining, Fishing, etc. Each skill can be trained individually and needs to have an experience integer to track the players progress. Image you choose a skill to train, an enemy spawns that provides XP in that skill if defeated, rinse and repeat.

Currently I have a list of enums that designate the skills, and I’m keeping a separate list of int’s to track experience.

E.g.,

{
Attack,
Mining,
Hitpoints
}```

public int miningExperience;
public int attackExperience;

public int miningLevel;
public int attackLevel;


etc. etc.

I'm using the enums to select which skill to train, then updating the experience int in a separate script. This feels inefficient because the skill enums and experience ints are separate are not really tied to each other.

If I'm only having a dozen or so skills, I don't want to overengineer some complex yet scalable system. Should I be approaching the tracking of skills differently or does anyone think the route I'm taking is fine?

Thanks

Look at this thread: Enum & inventory

Long story short, denote the skill types with a scriptable object. You could define your skills as serialisable classes, and have a collection of these. Need to modify a skill? Run down the collection and find the one with the type you’re looking for.

You can also define information about the types in these scriptable objects as well.

Remember, enums are an anti-pattern. C# is an object oriented programming language. Be sure to leverage that.

2 Likes

Thank you :slight_smile: This is exactly the type of feedback I was looking for. Much appreciated!