/*
full.t
FULLSCORE function and verb for TADS with Worldclass
Written by David Glasser
[email protected]
4/14/97
version 1.61

If you want the message displayed before the list of fulltexts to be different,
either use a modify command to change global.pretext and global.noptspretext to
whatever you want (the modify command must be put in after full.t) or simply change
the modify global in this document.

*NEW IN 1.6*
Change global.separate the same way as noptspretext and pretext to change the
separator between the number and the fulltext; e.g. ": ".
Now, unlike 1.0 and 1.5, if you make two fullscores with the same fulltext (i.e.,
getting sundry items), they WILL NOT be separate.

When I talk about the 'fulltext', I mean something like this:
points for killing Sauron

And the 'fullnum' is the amount of points increased.

This doesn't modify incscore or score_and_rank in any way, so it should be compatible
with other score modifications (for instance, a different notification in incscore or
different ranks in score_and_rank).

Version history
3/2/97(1.0)--first version
4/10/97(1.5)--modified for WorldClass
4/11/97(1.6)--Though you may doubt an updating of the version number just a day later,
this new version separates the number from the fulltext, so that you can group several
score changes together (e.g. 'for getting sundry items').  The text printed between
the number and the fulltext is in global.separate; it starts as " points for ".
4/14/97(1.61)--changed the "Adapt to ADV paragraph a bit.

REQUIRES WORLDCLASS!!!
However, changing the class of fullVerb to sysverb, fullVerb.soloaction(actor) to
action(actor) (i.e. deleting the letters 'solo'), and the reference to score_and_rank
to scoreRank should make it fine for ADV.T.
*/

/* This initializes the list of fulltext and their respective score numbers, and puts in
the default message to precede the list of fulltexts, the default message to precede
the list of fulltexts if there is no fulltext, and the separator of the fullnum and
fulltext.
*/
modify global
 fulllist=[]
 fullnums=[]
 pretext="You have earned these points by doing the following:\b"
 noptspretext="\b" //this is displayed if fulllist is empty, you can change it to
                 //something like You haven't done much yet.
 separate=" points for " //change this if you wish
;
/*
This is the verb players use to activate the fullscore.  It prints their score using
the normal score_and_rank function, then activates the fullScore function.
*/
fullVerb:Systemverb,Soloverb
 sdesc="full score"
 verb= 'full' 'fullscore'
 soloaction(actor)=
 {
 score_and_rank();
 fullScore();
 abort;
 }
;

/*
This is the fullAdd function.  When changing the player's score, use fullAdd instead
of incscore.  It takes two variables.  The first one is a number that is used to call
incscore normally.  The second is a single-quoted string that gets put into
global.fulllist and is printed when fullScore is called.  The string should
NOT (unlike in earler versions) include the '4 points for ' part.  For example:

oneRing:Item
..
..
doTake(actor)={
fullAdd(5,'getting the One Ring');
"\nYou feel a lot of power surrounding you.";
pass doTake;}
..
..
;

Now, the fullScore function will print as one of its lines:

5 points for getting the One ring

Note that if your incscore prints anything (as the standard WorldClass does), you
need the /n in front of the next text.
*/
fullAdd: function (amount,fulltext)
{
local x,y;
incscore(amount);
x:=(find(global.fulllist,fulltext));
if (x=nil)
{
global.fulllist :=global.fulllist + fulltext;
global.fullnums := global.fullnums + amount;
}
else
{
y := global.fullnums[x];
y += amount;
global.fullnums[x] := y;
}
}

/*
This is the fullScore function.  It is the what is summoned by the fullscore verb,
after the score_and_rank function.  It displays a message (global.pretext) followed by
the list of fulltexts, or displays global.noptspretext if global.fulllist is empty.
*/
fullScore: function()
{
if (length(global.fulllist)=0)
{global.noptspretext;}
else
{local lng:=length(global.fulllist),i;
global.pretext;
for (i:=1;i <=lng;i++)
{
 /*
 This part prints the amount of points for the fulltext that is being looked at, then
 calls global.separate (initially " points for ", but you can change this), then
 prints the text itself.
 */
say (global.fullnums[i]);
global.separate;
say (global.fulllist[i]);
"\n";
}
}
}