| Chapter 9: Time |

| 9.5. Every turn

The passage of time in interactive fiction is broken up into a succession of turns, in each of which the player types a request and is given a response. Usually each such request triggers one action, but sometimes a whole sequence are fired off, as when the player types "get all" in a cluttered room.

One of the last things to happen in each turn is that Inform will apply any rules which have been set to occur "every turn", like so:

> Every turn, say "The summer breeze shakes the apple-blossom."

This is equivalent to writing:

> An every turn rule: say "The summer breeze shakes the apple-blossom."

Note that the text about blossom, which will quickly become tiresome, is said at the end of every turn, not at the beginning, and in particular not before the player's first opportunity to type a command.

As usual when defining rules, we can add stipulations: any condition can be attached using "when".

> Every turn when in the Orchard, say "The summer breeze shakes the apple-blossom."

> Every turn when the player can see the rotting fish, say "Your nose twitches involuntarily."

111
| Example Witnessed 1 A kind of battery which can be put into different devices, and which will lose power after extended use.

112
| Example Text Foosball A game of foosball which relies heavily on every-turn rules.

Suppose we want a game of foosball in which our opponent acts every turn, but does different things depending on where the ball currently lies. We can put together a sequence of every-turn rules to account for this, as follows: "Text Foosball" The Lounge is a room. "The Lounge is appointed with everything necessary to rest and relaxation: a vending machine, a potted palm, a stack of Entertainment Weekly issues from 1993, and -- your pride and joy -- a foosball game." The foosball game is scenery in the Lounge. Understand "table" or "football" or "foozball" or "fussball" or "soccer" as the foosball game. The game is a supporter. On the game is a small white ball. The ball can be still, approaching, receding, or unreachable. The description of the ball is "Currently [small white ball condition]." After printing the name of the small white ball, say " ([small white ball condition])". When play begins: change left hand status line to "You: [score]"; change right hand status line to "Joey: [Joey's score]". Some tiny men on sticks are part of the game. Understand "handles" as the men. The description is "Okay, a couple of the tiny men have had their feet broken off, and the table surface itself is a bit warped, and the ball resembles a quail egg in respect of shape and color. This makes for a game of unusual randomness, but skill is overrated." Instead of attacking or pulling or pushing the game when the ball is unreachable: say "You give the table a good shove, and the ball moves ever-so-slightly."; now the ball is still. Instead of taking the white ball: say "You'd forfeit the game if you did that." Instead of turning the tiny men when the ball is unreachable: say "The ball has somehow gotten to a mystical point on the table where it cannot be reached, no matter what. Close inspection reveals that this point has been marked in chalk with a tiny X. Not that that does any good." Instead of turning the tiny men when the ball is approaching: if a random chance of 2 in 3 succeeds begin; if a random chance of 1 in 2 succeeds, now the ball is receding; otherwise now the ball is still; say "[if the ball is still]Thunk. [otherwise]Thwack! [end if]You keep the ball from reaching its goal! Now it is [small white ball condition]."; otherwise; let Joey score; end if. To let Joey score: now the ball is still; change Joey's score to Joey's score + 1; say "The ball rolls neatly into your goal, despite your efforts. "; if Joey's score < score, say "You put the ball back in the center with a snap. No reason to worry yet; you're still ahead. Joey looks determined, though."; otherwise say "After allowing a moment or two for Joey's gloating to pass, you replace it at the center." Instead of turning the tiny men when a random chance of 1 in 13 succeeds: if the ball is unreachable, continue the action; now the ball is unreachable; say "You hit the ball off-center and it rolls sluggishly into a little dip in the surface of the foosball table. "; if Joey's score > 7, say "'You did that on purpose!' Joey exclaims indignantly."; otherwise say "You and Joey exchange glances. This is never good." Instead of turning the tiny men: say "You madly rotate the tiny men on sticks! "; if a random chance of 1 in 2 succeeds begin; say "Hoorah! You hit the ball!"; now the ball is receding; otherwise; say "Somehow you fail to bring your monopodal player into contact with the ball."; end if. Joey is a man in the Lounge. "Joey is hunkered over the foosball handles on his side of the table." Joey can be active or inactive. Joey's score is a number that varies. Every turn: now Joey is active. Every turn when the ball is approaching and Joey is active: let total be Joey's score + score; if total > 9, make no decision; now Joey is inactive; let Joey score; rule succeeds. Every turn when the ball is unreachable and Joey is active: let total be Joey's score + score; if total > 9, make no decision; now Joey is inactive; say "Joey glares angrily at the stuck ball." Every turn when the ball is receding and Joey is active: let total be Joey's score + score; if total > 9, make no decision; if the ball is unreachable, make no decision; now Joey is inactive; if a random chance of 1 in 2 succeeds begin; if a random chance of 1 in 2 succeeds, now the ball is still; otherwise now the ball is approaching; say "Joey connects with your shot. Now the ball is [small white ball condition]!"; otherwise; now the ball is still; say "Joey tries to block, but misses! Back it goes in the center, where it is [small white ball condition]."; change score to score + 1; end if. Every turn when the ball is still and Joey is active: let total be Joey's score + score; if total > 9, make no decision; if the ball is unreachable, make no decision; now Joey is inactive; if a random chance of 1 in 2 succeeds begin; now the ball is approaching; say "Joey hits the ball solidly down towards your goal. Now it is [small white ball condition]."; otherwise; say "Joey fails to hit the ball in your direction. It remains [small white ball condition]."; end if. Every turn: let total be Joey's score + score; if total > 9 begin; if Joey's score > score, end the game saying "Rats! Joey wins!"; if Joey's score < score, end the game saying "Victory is yours!"; if Joey's score is score, end the game saying "A perfect tie."; end if.

Previous | Contents | Next