>Hi all > >I'm getting immensly tired of writing one line pr. Spell Pr. Class, >seems to be a bit overhand, what I would like to do is this : > >spell_level(SPELL_SOMENAME, {ARRAY OF LEVELS]); > >But somehow I'm stuck. The Easy solution is of course to do : > >spell_level(SPELL_SOMENAME, LVL_WI, LVL_CL, LVL_TH, LVL_WA); > >And yes, it would suit the needs I have, but it would be cool to be able >to go something like : > >spell_level(SPELL_SOMENAME, {"WI", 1, "CL", 2, -1, -1}); Or something >like that.. > >So that Every spell only needs one line to be spell_levelled, Problem is >I'm stuck here, The Idea is there, but somehow my knowledge in about >arrays and pointers have gone somewhere. Anyone with an idea to how this >could be made, the easiest way, so that if a new class is added, you can >just add "NEWCLASS", LEVEL to the spells they need. > >Hope to hear something from someone. :) > >S. P. Skou > > > +------------------------------------------------------------+ > | Ensure that you have read the CircleMUD Mailing List FAQ: | > | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | > +------------------------------------------------------------+ you could probably do this with an int array. This code is just off the top of my head but it would look something like: spell_level(SPELL_SPELLNAME, {'W', 1, 'M', 2, ...}); if would be defined with an int pointer: void spell_level(int spell, int *lvls); then have in spell_level int *s, class,lvl; for (s = lvls;(class = *s);s += 2) { if (!(lvl = *(s + 1))) /* give some error */ switch (tolower(class)) { case 'w': ... } } +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST