A system of telephones on which the player can call distant persons and have conversations.

"Four Cheeses"
Section 1 - Telephones and Connections
A telephone is a kind of thing. Understand "phone" as a telephone.
Understand "call [any telephone] on [something]" as calling it on. Understand "call [any telephone]" as calling it on. Understand the commands "dial" or "phone" or "telephone" as "call". Understand "call [any known person]" as calling it by name on.
Connection relates one thing to another (called the other party).
The verb to reach means the connection relation.
Calling it on is an action applying to one visible thing and one thing.
Check calling it on:
   if the second noun is not a telephone, say "[The second noun] is unlikely to be much use in that respect." instead;
   if the second noun is the noun, say "You get a busy signal." instead.
Carry out calling it on:
   if a person (called the listener) can see the noun, now the player reaches the listener.

Because we've said that connection is a reciprocal, one-to-one relationship, Inform will do the rest of the bookkeeping: if (for instance) we telephone someone else, the first connection will be broken automatically.

Report calling it on:
   say "'Hello?' says [the other party of the player]."

To avoid annoyance, we should also let the player use CALL #### as well as CALL #### ON TELEPHONE. A rule from the chapter on Activities comes in handy here:

Rule for supplying a missing second noun while calling something on:
   assign a phone.
To assign a phone:
   if the player can touch a telephone (called the current phone):
      say "(on [the current phone])[line break]";
      now the second noun is the current phone;
   otherwise:
      say "You don't have a phone handy."

Things might be a little more complicated if we had cell phones that could be moved around, but for right now the player can only touch a maximum of one phone at a time.

Suppose we further want to allow the player to call people up by name, but only if they've already been encountered or are familiar to the player for some reason.

A person can be known or unknown.
Understand "call [any known person]" as calling it by name on.
Understand "call [any known person] on [something]" as calling it by name on.
Rule for supplying a missing second noun while calling something by name on:
   assign a phone.
Calling it by name on is an action applying to one visible thing and one thing.
Check calling it by name on:
   if the noun is in the location, say "[The noun] is right here." instead.
Carry out calling it by name on:
   if the noun can touch a telephone (called the link), try calling the link on the second noun;
   otherwise say "You can't reach [the noun]." instead.
Before calling something on something when the player reaches someone:
   say "(first ending your conversation with [the other party of the player])[command clarification break]";
   end current conversation.
Understand "hang up [something]" as hanging up.
Hanging up is an action applying to one thing.
Check hanging up:
   if the noun is not a telephone, say "You can't hang up [the noun]." instead;
   if the player does not reach someone, say "You're not on the line with anyone." instead.
Carry out hanging up:
   now the player does not reach anyone.
Report hanging up:
   say "You put down [the noun], cutting the connection."
Before going somewhere when the player reaches someone:
   say "(first hanging up on [the other party of the player])[command clarification break]";
   end current conversation.

And finally we want to make sure that calling random other numbers produces a sensible result:

Understand "call [text]" as misdialling. Misdialling is an action applying to one topic. Carry out misdialling: say "The phone rings and rings but no one answers."
Understand "call 911" or "call 999" or "call police" or "call fire department" as a mistake ("After strict warnings, you've given up making prank calls to emergency services.").
Before misdialling when the player reaches someone:
   say "(first ending your conversation with [the other party of the player])[command clarification break]";
   end current conversation.
To end current conversation:
   let the current phone be a random telephone which can be touched by the player;
   silently try hanging up the current phone.
After deciding the scope of the player while the player reaches someone:
   place the other party of the player in scope, but not its contents.

A note about this scope addition: the player can refer to the other party whenever he has the other person on the phone. He can't, however, see or refer to anything that person might be holding or wearing, thanks to the "but not its contents" option.

Furthermore, the player can't actually do anything to that person that requires touching. That's because of the reaching inside rules, which govern whether the player can reach through intervening barriers such as rooms. (See the Advanced Actions chapter for more about changing reachability.) There are two things we might want to be careful about, though.

First, we should specifically disallow the player from looking at the person on the other end of the line. Since sight doesn't require touching, the reaching inside rules will not be consulted about a command such as EXAMINE BOSS or LOOK UNDER BOSS. We can, however, intervene in such cases using the visibility rules, which are consulted for any actions that "require light" (including EXAMINE and LOOK UNDER). Here again we borrow some options from the Advanced Actions chapter:

To decide whether acting through the line:
   if the noun is something and the location of the noun is not the location of the player:
      yes;
   if the second noun is something and the location of the second noun is not the location of the player:
      yes;
   no.
Visibility rule when acting through the line:
   there is insufficient light.
Rule for printing a refusal to act in the dark when acting through the line:
   say "You're not on a video phone, so you can only hear." instead.

Second, though the existing reaching inside rules are adequate to stop us from touching the person on the other end of the line, the response that's currently printed is a bit generic: it just says "You can't reach into [the room containing the person]." Let's add our own custom reply, instead:

A rule for reaching inside a room (called destination):
   if the other party of the player is enclosed by the destination:
      say "Though you're on the line with [the other party of the player], you can't physically reach to [the destination].";
      deny access.
Section 2 - Conversation over the Phone, In General

This portion supplies a simple method of conversation; but we could substitute some completely different conversation system if appropriate. The effect of the telephones is that we are allowed to talk to characters in distant locations under certain circumstances, after which the usual conversation rules apply.

Instead of listening to a telephone when the player reaches someone:
   say "You can hear [the other party of the player] breathing."
Before listening to someone when the player cannot touch the noun:
   say "[The noun] is waiting for you to carry on the conversation." instead.
A person has a table name called chatter.
Before telling someone about something:
   try asking the noun about it instead.
Before answering someone that something:
   say "Best to confine your conversation to questions and answers." instead.
Before asking someone about something:
   if the topic understood is a topic listed in the chatter of the noun, say "[reply entry][paragraph break]" instead;
   otherwise say "[The noun] does not reply." instead.
Section 3 - The Scenario
The Guard House is a room. "Here you spend all your nights. Bullet-proof windows offer a panoramic view of serene cliffs, palm trees, and a moonlit ocean. Occasionally someone is foolish enough to try a cliff ascent or even an attack by helicopter, but lately things have been pretty quiet.
The mansion is up the hill behind you, security lights ablaze."
The grey telephone is a telephone in the Guard House. Understand "6885" as the grey telephone. "Before you is a grey telephone. In black marker someone has written on it: MAIN OFFICE 2802."
Before going a direction in the Guard House, say "And leave your post? The boss would have you flayed. No kidding." instead.

In a game where the player could walk around, we would of course want to add a before rule so that he automatically hung up any phone he was using before leaving the room.

The Main Office is a room. The boss is a known woman in the Main Office. A telephone called the red telephone is in the Main Office. Understand "2802" as the red telephone.
The Guild is a room. The ninja is an unknown man in the Guild. A telephone called the black telephone is in the Guild. Understand "4431" as the black telephone.
Potter's Pizza is a room. The pizza delivery boy is a known man in Pizza. A telephone called the saucy telephone is in Pizza. Understand "8885" as the saucy telephone.
The chatter of the boss is the Table of Boss Conversation. The chatter of the delivery boy is the Table of Pizza Conversation. The chatter of the ninja is the Table of Ninja Conversation.
After calling the red telephone on something for the first time:
   say "'Yes?' asks the boss. Her voice is especially husky this evening. Maybe that night of passion isn't so far off after all."
Table of Boss Conversation
topicreply
"love/passion/tonight/night" or "night of passion""'...Sorry, what?' she asks. 'I wasn't listening.' Oh. Maybe she'd go for some pizza, though."
"pizza""'I'd love some. No pepperoni, though,' she says, sounding dreamy. Yes, this is definitely time for a call to your old friend, the pizza boy."
"imminent ninja attack""'Don't worry about it,' says the boss crisply. 'I have everything under control.'"
Table of Pizza Conversation
topicreply
"pizza""'Pepperoni special tonight!' he says proudly."
"pepperoni""'Pepperoni is included free on ALL our pizzas,' he says proudly."
"no pepperoni""'Well, I don't see why you'd want that,' replies the boy sniffily. 'It's free!'"
"jalapeno""'Sorry, we're out of jalapenos this evening. There was a run on them.'"
"sausage""'Sausage, sure, we can do you sausage.'"
"canadian bacon""'There's currently an embargo on Canadian pig products.'"
"cheese""'We use four kinds,' says the boy, then lowers his voice confidentially. 'Actually, two of them are the same. Nobody ever counts. The stringy one, the one that comes in dollops and the orangey one. You know.'"
"pineapple""'We could put pineapple on there, sure,' says the delivery boy, in a tone that lets you know his opinion of people who order fruit-based pizzas."
"pineapple and garlic""'What kind of crazy combination is that?' demands the delivery boy, finally losing all self-control."
"delivery""'Well, I don't know,' says the boy in a worried voice. 'Last time I came there were attack dogs. And ninjas.'"
"massive gratuity""'There's no use in a big tip you don't live to spend,' says the delivery boy quite firmly."
Table of Ninja Conversation
topicreply
"imminent attack""'Yes, still on for tonight,' confirms the voice at the other end of the line."
"pizza delivery boy""The voice, in tones of velvet, indicates that it cannot guarantee the safety of any delivery persons whomsoever."
Test me with "call 2802 / examine boss / ask boss about night of passion / ask boss about pizza / listen to telephone / call delivery boy on telephone / ask boy about cheese / tell boy about no pepperoni / ask boy about delivery / tell boy about massive gratuity / attack boy".
Test me with "call 2802 / examine boss / ask boss about night of passion / ask boss about pizza / listen to telephone / call delivery boy on telephone / ask boy about cheese / tell boy about no pepperoni / ask boy about delivery / tell boy about massive gratuity / attack boy".
Guard House
Here you spend all your nights. Bullet-proof windows offer a panoramic view of serene cliffs, palm trees, and a moonlit ocean. Occasionally someone is foolish enough to try a cliff ascent or even an attack by helicopter, but lately things have been pretty quiet.

The mansion is up the hill behind you, security lights ablaze.

Before you is a grey telephone. In black marker someone has written on it: MAIN OFFICE 2802.

>(Testing.)

>[1] call 2802
(on the grey telephone)

"Yes?" asks the boss. Her voice is especially husky this evening. Maybe that night of passion isn't so far off after all.

>[2] examine boss
You're not on a video phone, so you can only hear.

>[3] ask boss about night of passion
"...Sorry, what?" she asks. "I wasn't listening." Oh. Maybe she'd go for some pizza, though.

>[4] ask boss about pizza
"I'd love some. No pepperoni, though," she says, sounding dreamy. Yes, this is definitely time for a call to your old friend, the pizza boy.

>[5] listen to telephone
You can hear the boss breathing.

>[6] call delivery boy on telephone
(first ending your conversation with the boss)
"Hello?" says the pizza delivery boy.

>[7] ask boy about cheese
"We use four kinds," says the boy, then lowers his voice confidentially. "Actually, two of them are the same. Nobody ever counts. The stringy one, the one that comes in dollops and the orangey one. You know."

>[8] tell boy about no pepperoni
"Well, I don't see why you'd want that," replies the boy sniffily. "It's free!"

>[9] ask boy about delivery
"Well, I don't know," says the boy in a worried voice. "Last time I came there were attack dogs. And ninjas."

>[10] tell boy about massive gratuity
"There's no use in a big tip you don't live to spend," says the delivery boy quite firmly.

>[11] attack boy
Though you're on the line with the pizza delivery boy, you can't physically reach to Potter's Pizza.

…and it more or less writes itself from there.