I have a group of powers that all fall under one category for the MUD. Each one individually can be raised from 0 - 5. I see two ways I could do this, and was wondering opinions as to which way would be better.
Option 1:
Create a variable for each individual power. The plus side to this is that it would be rather easy for me to do as I have gotten the hang of manipulating variables. The downside is that it is a lot of different variables to write.
Option 2:
Create an array for a table for each power name. The plus side is that they will be grouped together, and it would be a lot less variables to write out for reading/writing to files. The downside is that I am still learning my way around creating/manipulating tables.
Take for example if I had a group of powers: Elemental Powers (earth, fire, wind, water). I could read/write this to the pfiles in both options.
1 (multiple variables):
int ch->elemental_earth;
int ch->elemental_fire;
int ch->elemental_wind;
int ch->elemental_water;
2 (as an array):
struct elemental_power
{
int earth;
int fire;
int wind;
int water;
}
struct elemental_power elements[3];
and in merc.h have my defines:
#define EP_EARTH 0
#define EP_FIRE 1
#define EP_WIND 2
#define EP_WATER 3
Sorry this got longer than I thought it would when I started. Anyway, my question stands is there any advantage to using one method over another? I can see some pros and cons, but since I am still rather new at this I'd rather hear a little feedback from experienced users/programmers. Also, is one way more memory intensive over the other? Of course, if there is another option that is better than either way, I am completely open to possibilities. Thanks again!
Option 1:
Create a variable for each individual power. The plus side to this is that it would be rather easy for me to do as I have gotten the hang of manipulating variables. The downside is that it is a lot of different variables to write.
Option 2:
Create an array for a table for each power name. The plus side is that they will be grouped together, and it would be a lot less variables to write out for reading/writing to files. The downside is that I am still learning my way around creating/manipulating tables.
Take for example if I had a group of powers: Elemental Powers (earth, fire, wind, water). I could read/write this to the pfiles in both options.
1 (multiple variables):
int ch->elemental_earth;
int ch->elemental_fire;
int ch->elemental_wind;
int ch->elemental_water;
2 (as an array):
struct elemental_power
{
int earth;
int fire;
int wind;
int water;
}
struct elemental_power elements[3];
and in merc.h have my defines:
#define EP_EARTH 0
#define EP_FIRE 1
#define EP_WIND 2
#define EP_WATER 3
Sorry this got longer than I thought it would when I started. Anyway, my question stands is there any advantage to using one method over another? I can see some pros and cons, but since I am still rather new at this I'd rather hear a little feedback from experienced users/programmers. Also, is one way more memory intensive over the other? Of course, if there is another option that is better than either way, I am completely open to possibilities. Thanks again!