ahh, yeah i figured rom had something like that already in, but im having a
little problem using it, after a person successfully guesses it adds their
guess and name right in front of the prompt, and prefixs any commands they
send, eg:
<20hp 100m 100mv> wt on
[WordTwist] Orlis scores 2 points for 'on'
[WordTwist] You 'on'
<20hp 100m 100mv> onOrlisnod
Huh?
<20hp 100m 100mv> onOrliswordtwist
Huh?
<20hp 100m 100mv> onOrliswt
Huh?
<20hp 100m 100mv> onOrlis
45 seconds left...
Find words that:
Begin with the letter 'O'
End with 'N'
this is what im doing to check if its correct(this is executed if the guess
matches the criteria, no problems with that)
void do_wtcorrect(CHAR_DATA *ch, char *argument)
{
int points;
int length;
char announce[MAX_INPUT_LENGTH];
DESCRIPTOR_DATA *d;
if ( is_exact_name(argument,wordtwist.word) )
return;
strcat(wordtwist.word,argument);
strcat(wordtwist.name,ch->name);
....
i use this to clear the string when a new round is started:
wordtwist.word = str_dup( "" );
wordtwist.name = str_dup( "" );
From: "Richard Lindsey" <[EMAIL PROTECTED]>
To: "Tristan M" <[EMAIL PROTECTED]>,<[email protected]>
Subject: RE: a problem with checking if a word has been entered already
Date: Sat, 21 Aug 2004 08:01:57 -0500
You could try something like the following, using ROM's built-in
is_exact_name boolean... it would probably cut down a lot on memory
allocation as well...
Change that char *word[1000] to a simple char *word... i assume at the end
of the round you're cycling through a loop of 1000 and freeing all those
strings, but you could simply make it 1 string and each time a guess is
made, do something like this:
strcat(word," ");
strcat(word,argument);
and then when another guess is made you can say:
if ( is_exact_name(argument,word) )
which should just check the newly entered word against the whole list of
words held by word, just like when a player walks up to a "standard merc
guard cityguard midgaard" (or whatever the name is) and types "look
guard"... you'll want to use is_exact_name instead of is_name because if
someone guesses a word that's part of another word that's been guessed,
like if some wise guy guesses horsee when the letters are orshe, the code
simply sees that the first and last letter are correct and logs it, and
then someone guesses horse, which is_name would return as having been tried
already because it uses str_prefix instead of str_cmp, which reminds me,
you may want to do a strlen check also before logging previous word
attempts... hope this helps....
wavewave
Richard Lindsey.
p.s. you may also want to change the char *first and char *last to simply
char first and char last, since they only hold 1 letter apiece... and you
can do the same thing to char *name[1000] that you do to char *word and
make it a list of names inside of one char * variable, but in order to
correlate who said which word, you can loop through them with something
like one_argument until you find the word you're looking for, and where the
current pointer is in name, or you could loop through it looking for
strstr(word," ") and strstr(name," ") until you find the right word, and
then look at the current pointer to name... you'd want to initialize
another char * variable to both of those first, however, to hold the
pointer to the beginnings of the strings, or else make it a separate
function like find_match("blah",word,name) so that the word and name
pointers are still in the original locations when it returns from
find_match...
struct wordtwist_data
{
int totalguesses; //how many guesses people have made so far(total
for
everyone)
int turns_left; //how many turns are left before the round is over
char *first; //letter that correct phrases begin with
char *last; //letter that correct phrases end with
char dict[MAX_STRING_LENGTH]; //the word list file
char *word[1000]; //these are the words guessed(i think this is where
my problem is)
char *name[1000]; //these are who guessed which words
bool newround; //newround? yes or no?
};
_________________________________________________________________
Scan and help eliminate destructive viruses from your inbound and outbound
e-mail and attachments.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSNĀ® Premium right now and get the
first two months FREE*.