Not every work of IF allots a numerical score to the player: for some authors, this emphasises the idea of a game rather than a narrative. The simple sentence
Use no scoring.
abolishes the concept. Otherwise, Inform will provide built-in support for a single number measuring progress ("score"), and will expect to measure this against a maximum possible ("maximum score", which can either be set by hand or worked out automatically from a table of ranks).
An especially insidious style of bug allows the player to type the same sequence of commands over and over, earning score endlessly for the same insight, and to avoid this it is usually safest to write source like:
After taking the Picasso miniature for the first time: award 10 points; say "As they say in Montmartre: dude!"
If there are many "treasure" items like this, it is best to be systematic, as in No Place Like Home. Bosch takes another approach to the same idea, by creating a table of point-earning actions that the player will be rewarded for doing; the FULL SCORE command will then play these back.
A single number does not really sum up a life, or even an afternoon, and Goat-Cheese and Sage Chicken and Panache offer more detailed citations. Works that are more story than game may prefer to offer a plot summary of the player's experience to date in lieu of more conventional scoring.
Finally, Rubies provides a scoreboard that keeps track of the ten highest-scoring players from one playthrough to the next.
| Example Bosch Creating a list of actions that will earn the player points, and using this both to change the score and to give FULL SCORE reports. | |
The trick here is that we need a table with indexed text in order to keep track of the players' names.
Part 1 largely replicates the source from "Identity Theft"; new material starts at Part 2.
"Rubies"
Part 1 - Collecting Names
The player's forename is an indexed text that varies. The player's full name is an indexed text that varies.
When play begins:
change the command prompt to "What is your name? > "
To decide whether collecting names:
if the command prompt is "What is your name? > ", yes;
no.
After reading a command when collecting names:
if the number of words in the player's command is greater than 5
begin;
say "[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let's try this again.";
reject the player's command;
end if;
change the player's full name to the player's command;
change the player's forename to word number 1 in the player's command;
change the command prompt to ">";
say "Hi, [player's forename]!";
say "[banner text]";
move the player to the location;
reject the player's command.
Instead of looking when collecting names: do nothing.
Rule for printing the banner text when collecting names: do nothing.
Rule for constructing the status line when collecting names: do nothing.
Procedural rule: if collecting names, ignore the turn sequence rules.
Part 2 - Adding the Leaderboard
File of Leaderboard is called "leaderboard".
When play begins:
if the File of Leaderboard exists
begin;
read File of Leaderboard into the Table of Leaders;
sort the Table of Leaders in reverse scored amount order;
end if;
When play ends:
choose row 10 in the Table of Leaders; [we've sorted the table, so the lowest score will be the one at the bottom]
if the score is greater than scored amount entry
begin;
change name entry to the player's forename;
change the scored amount entry to the score;
end if;
show leaderboard;
write the File of Leaderboard from the Table of Leaders.
To show leaderboard:
sort the Table of Leaders in reverse scored amount order;
say "Current leading scores: [paragraph break]";
say fixed letter spacing;
repeat through Table of Leaders
begin;
if scored amount entry is greater than 0
begin;
say " [name entry]";
let N be 25 minus the number of characters in name entry; [here we want to space out the scores so they make a neat column]
if N is less than 1, change N to 1;
say N spaces;
say "[scored amount entry][line break]";
end if;
end repeat;
say variable letter spacing.
To say (N - a number) spaces:
repeat with index running from 1 to N
begin;
say " ";
end repeat.
Table of Leaders
scored amount | name (indexed text) |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
0 | "Smithee" |
And now we introduce a scenario that allows different players to come up with different scores -- admittedly not a very interesting scenario, but it will do for now:
Part 3 - Scenario
Carry out taking something which is not handled:
increase score by 1.
The Big Treasure Chamber is a room. It contains a ruby, an emerald, a gold tooth, an antique katana, and a silver coin.
Instead of waiting, end the game in victory.
Test me with "get ruby / z".
|