I wasn't able to use the fengshui thing with MSN, but I think I grasp
what you are aiming for.
But why do you want to keep track of wrong guesses or total guesses
for? Does it decide how many points are distributed? If you aren't
interested in the actual strings of the wrong guesses, the problem
becomes much simpler.
Here'd be the struct for just the above, not including round stuff:
struct wordtwist
{
int guesses;
char first;
char last;
char *word;
};
Then as people guess wrong, just increment totalguesses by 1:
void wt_check_word (CHAR_DATA *ch, char *argument)
{
if (!ch || !argument || argument[0] == '\0')
return;
if (!str_cmp(argument, wordtwist.word))
{
//blahblah ch wins points!
wt_reset();
}
else
wordtwist.guesses++;
}
If you are additionally concerned with how many times a single person
guesses for point purposes, It may actually be easier to add a variable
to the 'pc_data' or 'char_data' struct:
struct pc_data
{
PC_DATA * next;
BUFFER * buffer;
COLOUR_DATA * code; /* Data for color configuration */
bool valid;
...
int wt_guesses;
...
}
(I'd recommend setting wt_guesses to 0 in new_pcdata)
If you go this route, you could either brute-force and roll through the
players in the game and reset all their wt_guesses to 0 for the next
round (recommended, as a person can switch on the channel mid-round) or
just set to 0 those with the COMM_WTWIST channel currently turned on, eg:
void wt_reset (void)
{
DESCRIPTOR_DATA *d = NULL;
/*
*<new round stuff>
*/
...
for (d = descriptor_list; d != NULL; d = d->next)
{
if (d->character != NULL && d->connected == CON_PLAYING &&
IS_SET(d->character->comm, COMM_WTWIST))
{
d->character->pcdata->wt_guesses = 0;
}
}
...
}
I may be missing some of the mechanics behind the game, though.
Tristan M wrote:
From: "Tristan M" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: RE: a problem with checking if a word has been entered already
Date: Sun, 22 Aug 2004 01:23:28 +0000
gah, sorry for spamming the list, but ive arrived at a problem that
ive no idea what could be the problem...
the function where it checks correct answers now looks like this:
void do_wtcorrect(CHAR_DATA *ch, char *argument)
{
int points;
int length;
char announce[MAX_INPUT_LENGTH];
char log_buf[MAX_STRING_LENGTH];
DESCRIPTOR_DATA *d;
if ( is_exact_name(argument,wordtwist.word) )
return;
strcat(wordtwist.word," ");
strcat(wordtwist.name," ");
strcat(wordtwist.word,argument);
strcat(wordtwist.name,ch->name);
sprintf(log_buf,"%s",wordtwist.word);
log_string(log_buf);
my input:
------------
[WordTwist] Orlis scores 7 points for 'malaria'
[WordTwist] You 'malaria'
<20hp 100m 100mv> wt malaria
[WordTwist] Orlis scores 7 points for 'malaria'
[WordTwist] You 'malaria'
-------
what it spits out on the log looks like this:
Sat Aug 21 19:22:40 2004 :: malariaOrlis malariaOrlis
From: "Tristan M" <[EMAIL PROTECTED]>
To: [email protected]
Subject: RE: a problem with checking if a word has been entered already
Date: Sat, 21 Aug 2004 23:55:42 +0000
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*.
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom
_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented
Microsoft® SmartScreen Technology.
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*.
_________________________________________________________________
Designer Mail isn't just fun to send, it's fun to receive. Use special
stationery, fonts and colors.
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*.