Look at it

You typed buy energy right? so prize_lookup is getting the word energy.

now is name[0] the same as prize_table[i].name[0]

name[0] = e and prize_table[i].name[0] would be s

you would need to change that check to do if (is_name(prize_table[i].name,
name))

And hope you don't have anything else with the words energy or suit in them.
I would suggest having it display a number and then you buy 1 then do
number - 1 (unless you put someone empty for start of the table)


----- Original Message ----- 
From: "Matt Foltz" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 24, 2003 12:43 PM
Subject: Buying items from autoquestor


> Hey list,
>
> I'm converting the "quest buy" command into table format, so
> it's a lot shorter and easier to update.  Before I changed
> anything you could type "quest buy suit" or "quest buy energy"
> to buy the same item.  It used the is_name function to compare
> the argument to the list of keywords for the item.  So now I
> have made a table like this:
>
> const struct prize_type prize_table[] =
> {
>    { "suit energy",                   QUEST_ITEM_SUIT_ENERGY,
>    25000 },
>    { "flame darkness",                QUEST_ITEM_FLAME_DARKNESS,
>    20000 },
> --cut--
>
> And a prize_lookup function:
>
> int prize_lookup (char *name)
> {
>     int type;
>
>     for (type = 0; prize_table[type].name != NULL; type++)
>     {
>         if (LOWER(name[0]) == LOWER(prize_table[type].name[0])
>         &&  strstr( name, prize_table[type].name ) )
>     return type;
>     }
>
>     return -1;
> }
>
> Now the problem I'm encountering is that I can type "quest buy
> suit" and buy the suit, but not "quest buy energy".  So it's not
> recognizing any of the keywords in the table after the first
> one.  What am I doing wrong in the prize_lookup function?  Or if
> it isn't that, what could it be?  Thanks.
>
>
> =====
> -Matt Foltz
> [Neoterra MUD] telnet://neoterra.is-a-geek.com:4000
> [Car Audio Resources homepage] http://www.car-audio.net
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
>
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>


Reply via email to