Figure Score after player asks

Bloodsong, that’s basically what I was trying to do. At first it seemed to me like less overhead than figuring the score every time an item was removed or added.

The biggest problem was how to end the game. Unless I’m mistaken, that’s usually done with something like:

Every turn in which score = maxscore
say “You win!”
End the game in victory.

If the score is zero until someone says score and the score-figuring mechanism looks in the chest, then this type of thing never fires and you have to hope that the player says Score right after gathering that last treasure. And it has to reset to zero between looking or else it will be cumulative and add the score to the last score.

As Mike pointed out, it also caused me to have to hack the scorekeeping tally at the top of the window and some other things. Also, it means you don’t get the constant feedback while playing that adding a treasure raised your score, removing it lowered your score. Turns out it was better to keep the score up to date the whole game.

I guess you could do this:

Every turn
score = 0
score = number of items in chest

But then you aren’t saving any overhead, and you might as well do it one of the prettier ways that Mike or Emerald proposed.

So I think Mike and Emerald are correct as usual.

So there is no way to turn off score reporting (i.e. the status bar read out and score update messages) without resetting score to zero? If you could just leave the score intact but not let the PC know what that score is, wouldn’t you be able to leave in the “maxscore = game is happy end” parameter?

I only ask because this seems like something that would be useful for some genres.

Tommie

Upthread, I’ve described how you can: turn off score notification, turn off the ability of the player to turn it back on, and remove the score from the status line. That code can be used regardless of your scoring method.

No, score reporting can be turned off. That’s not what is making it necessary to reset score to zero.

Either you figure the score every turn or you figure the score when someone asks.

If you figure the score every turn, all is well. But then there’s no need to count the items in the chest every time. Just count a point when a treasure goes in or remove a point as one goes out, as others have suggested. The score is updated all the time. Why would you count the items in the chest if you’re keeping track every turn anyway?

In my mind, the advantage of counting the items in the chest vs. paying attention when someone adds and removes was getting rid of the overhead of tallying score every turn. Perhaps you had a different benefit in mind.

My thought was forget about the score until the player asks. Then say, score=0, score=items in the chest. Without the score=0 part, the first time you ask you have 10 and the second time you ask you have 20 because it counts again. That’s all. Perhaps a bigger deal has been made of that than was necessary.

If you don’t figure the score til the player asks, though, then the player goes happily bouncing along for another 50 turns even after he had won, because he forgot to ask and no one told him.

Hm, I’m using this code, which I believe was my adaptation of Emerald’s solution:

[code]After inserting a treasure into the basket:
award 1 point;
continue the action.

Before taking a treasure when the noun is in the basket:
award -1 points.

After taking the basket when a treasure is in the basket:
let x be the number of treasures in basket;
award x points;
continue the action.

After dropping the basket when a treasure is in the basket:
let x be the number of treasures in the basket;
award (x * -1) points;
continue the action.[/code]

This gave me some problems – I wish I could copy and paste the problem but I was playing my web-based version and it wouldn’t let me. Basically I collected 5 treasures, put them in the basket, dropped the basket, collected 2 more, and put them in the basket while it was on the ground. This told me my score had gone up, which I guess shouldn’t be the case since I wasn’t holding the basket. When I said Score, it told me I had a 2 instead of a 7 because it had deducted the five. When I picked up the basket, however, and said Score I had 7.

I’m not sure how to get around these difficulties, which is why I had started pursuing the real-time count thing. Though maybe I just adapted Emerald’s code wrong.

Guess I’ll investigate the other solutions offered in this thread. Or I guess I could just decide that you get the score whether you’re holding the basket or not, though it will still be nice to solve the problem.

Maybe it’s just…

[code]After inserting a treasure into the basket when the player is carrying the basket:
award 1 point;
continue the action.

Before taking a treasure when the noun is in the basket when the player is carrying the basket:
award -1 points.

After taking the basket when a treasure is in the basket:
let x be the number of treasures in basket;
award x points;
continue the action.

After dropping the basket when a treasure is in the basket:
let x be the number of treasures in the basket;
award (x * -1) points;
continue the action.[/code]

?

Haven’t tested “when the player is carrying the basket” syntax though.

Oops, yeah, my bug. Sorry. Your fix is correct.

“When the player is carrying the basket” will work as long as the player can’t put the basket into something else s/he’s holding. If that’s possible, then you’ll need to use “when the player encloses the basket” instead.

Something else I just noticed: if you get rid of the basket by putting it in or on something else, the game won’t deduct any points, so you’ll need to change the “After dropping the basket” rule to account for that. Unfortunately, I don’t have the time right now to rewrite it for you. :frowning:

Maybe it would be easier to rewrite the scoring system in this case. Unless I’m missing something major here just a couple of lines should work:

[code]Use no scoring. [disables the built-in scoring]

To decide which number is the current score:
decide on the number of treasures in the basket.

Understand the command “score” as something new. Understand the command “notify” as something new.

Requesting the current score is an action out of world. Understand “score” as requesting the current score.

Carry out requesting the current score:
say “You have [current score] point[if the current score is not 1]s[end if].”[/code]

Emerald and Nitku, both good ideas. I’ll look them over and figure out what to do.

No worries about writing the code for me Emerald! I appreciate the advice and I can investigate how to put it into action.