Re: Agility, Power, & if (!str_cmp("argument", buf))

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 11/23/01


On Fri, 23 Nov 2001, David Cole wrote:

> ...and agility is a rogue, and handler related stat.

Consider this design carefully.  For instance, can you provide clear
answers to the following questions:

  * What quality does agility represent?
  * What quality does dexterity represent?
  * What does dexterity quantify that agility does not?
  * What does agility quantify that dexterity does not?
  * Is there overlap between the stats?
  * Will my players know the difference?  (Is it obvious?)

You should probably write down the answers to these questions (or any
others that occur to you about your game design) somewhere.  Asking
questions of yourself is a good way to generate depth and soundness in
your designs.


> I'm having lots of problems like this with ASCII pfiles, anything I try
> adding doesn't save in them, and I add them to all the proper places, I
> think?

You'll have to show us some code for what you're doing.  It's nearly
impossible to guess.


>     if (FIGHTING(d->character)) {
>       if (PRF_FLAGGED(d->character, PRF_TANKNAME)) {
>         [... snip ...]
>           sprintf(prompt + strlen(prompt), " T: %s ",
>                   GET_NAME(d->character));
>       }
>     }

I think you want to GET_NAME the person d->character is fighting, here,
rather than d->character.  There are a few other improvements you can
make.  My reworking in the traditionally terse style of a C programmer:

  if (PRF_FLAGGED(d->character, PRF_TANKNAME) && FIGHTING(d->character))
    sprintf(prompt + strlen(prompt), " T: %s%s%s ",
            CCRED(d->character, C_CMP),
            GET_NAME(FIGHTING(d->character)),
            CCNRM(d->character, C_CMP));

As a sidenote: I don't know if this is due to your mailer, the way you
pasted the code, or something else entirely, but proper indentation of
your code can save you a *ton* of debugging time.  If you're not indenting
your code, start.  If you don't like CircleMUD's style of indentation,
transform it using the indent(1) program.


> ...I know its been done, and atm its just not hitting me but what else
> can I use to make it accept sort term arguments instead of complete?

CircleMUD does not include a function explicitly for prefix matching, but
it's easy enough to do with strn_cmp(A, B, n) which is like str_cmp(A, B)
except that only the first n characters of A are checked (at most), e.g.,
given,

  if (!strn_cmp("ascii", arg, strlen(arg))) {
    /* ... */
  }

if arg were "asc", then strlen(arg) is 3, and arg is compared against only
the first three characters of "ascii"; they match.  This is useful and
verbose enough that a convenience macro might be in order to save your
wrists:

  /* Returns TRUE if 'a' is a (case-insensitive) prefix match for 'b'. */
  #define str_prefix(a, b)      (!strn_cmp((b), (a), strlen((a))))

which would be used like,

  if (str_prefix(arg, "ascii")) {
    /* ... */
  }


-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST