View difference between Paste ID: QA2wxC5g and BShiBayT
SHOW: | | - or go back to the newest paste.
1-
Version 2/130613 of Possession and Ownership by Shadow Wolf begins here.
1+
Version 4/130619 of Possession and Ownership by Shadow Wolf begins here.
2
3-
[NOTE: Superceded by version 3 here: http://pastebin.com/QA2wxC5g ]
3+
"Allows the player to refer to items via either legal ownership or physical possession, e.g. X ALICE'S NECKLACE or ENTER GEORGE'S HOUSE."
4
5-
Section 1 - Possessions
5+
"based on code from vaporware on r.a.i.f (6 Jan 2008)"
6
7-
[Option - ignore physical possession]
7+
Section 1 - Reparsing possessives
8-
Use legal possession translates as (- Constant ONLY_LEGAL_POSSESSION; -).
8+
9
After reading a command (this is the mangle possessives in the players command rule):
10-
Definition: A thing is possessed if a person is holding it.
10+
	let N be indexed text;
11-
To decide which person is the possessor of (T - a thing):
11+
	let N be the player's command;
12-
	if T is held by a person (called the holder), decide on the holder;
12+
	replace the regular expression "(\w)[']s" in N with "\1 [']s";
13-
	decide on nothing;
13+
	replace the regular expression "s['](\W)" in N with "s [']s\1"; [Cheat to handle possessives]
14
	change the text of the player's command to N.
15
16
Section 2 - Possession
17-
Every thing has an indexed text called the possessive name. The possessive name of a thing is usually "". Understand the possessive name property as referring to a thing.
17+
18
Understand "[something related by reversed possession] 's" as a thing. 
19-
The last when play begins rule: if the legal possession option is inactive, update possessions.
19+
Understand "[something related by reversed incorporation] 's" as a thing.
20-
Every turn: if the legal possession option is inactive, update possessions.
20+
21
22-
To update possessions:
22+
Section 3 - Ownership
23-
	repeat with item running through possessed things:
23+
24-
		now the possessive name of the item is "[possessive form of the possessor of the item]";
24+
25
			
26-
To say possessive form of (X - a thing):
26+
27-
	if X is the player:
27+
28-
		say "your";
28+
Understand "[something related by reversed ownership] 's" as a thing.
29-
	otherwise if X is plural-named:
29+
30-
		say "[X][apostrophe]";
30+
31-
	otherwise:
31+
32-
		say "[X][apostrophe]s".
32+
33
34
"Possession and Ownership" allows the player to use possessives to refer to items which are either physically held by a particular individual, or notionally owned by an individual.
35
36-
Section 2 - Ownership
36+
37
38
With this extension, a player can automatically use commands like "EXAMINE BOB'S PANTS" or "DROP MY PENCIL" or "ALICE, GIVE ME YOUR NECKLACE" - as long as the appropriate person (Bob, the player, and Alice respectively) is holding the item in question. 
39
40
Some items may be notionally owned by a particular individual, even if they are currently held by someone else, or are fixed in place (and thus not holdable at all.) The ownership relation handles this. 
41
42
	Bob carries a gun. The gun is owned by Annie. [or "Annie owns the gun."]
43-
Every thing has an indexed text called the owners name. The owners name of a thing is usually "". Understand the owners name property as referring to a thing.
43+
44
This allows:
45-
The last when play begins rule: update ownership.
45+
46-
Every turn: update ownership.
46+
47
	> BOB, DROP ANNIE'S GUN
48-
To update ownership:
48+
49-
	repeat with item running through things owned by a person:
49+
50-
		now the owners name of the item is "[possessive form of the owner of the item]";
50+
51
52
Naturally, ownership of an item can change during play:
53
54
	Oak Street is a room. The red house is scenery on Oak Street. The house is owned by Bob.
55
	
56
	Signing the Deed is a scene. When Signing the Deed ends: Now the house is owned by the player.
57
	
58
Section - Caveats and Issues
59
60
Version 3 is a near-total rewrite. Instead of manually updating an indexed text property every turn, we mangle the player's command (so that apostrophe-s is a separate word), and use the "[something related by reversed relation]" construct. The game will understand items related by possession or incorporation, which covers assemblies, and also ownership.
61-
With this extension, a player can automatically use commands like "EXAMINE BOB'S PANTS" or "DROP MY PENCIL" or "ALICE, GIVE ME YOUR NECKLACE" - as long as the appropriate person (Bob, the player, and Alice respectively) is holding the item in question. Possession in this case lasts until another person picks up the item - so "ALICE, DROP YOUR NECKLACE" can be followed by "TAKE ALICE'S NECKLACE". (Of course, once the player picks it up, it no longer belongs to Alice by this rule, so "X ALICE'S NECKLACE" would subsequently fail.
61+
62
The alteration of the player's command also tries to handle plural possessives (e.g. WITCHES' ) - S followed by apostrophe becomes S-space-apostrophe-S. 
63
64
Avoid setting ownership relations in which one person owns an assembly that's part of another person - this will cause disambiguation issues. (e.g. don't try "A nose is part of every person. George owns Bob's nose.", or X GEORGE'S NOSE won't be able to tell which one you mean.) 
65
66
If an actor only has a single thing (via possession or incorporation), then a command like "X LOIS'S GLASSES" (where Lois does not have the glasses) will result in the parser error "I only understood you as far as wanting to examine Lois." As a workaround, you can define two assemblies so that every person has at least two items at all times. (e.g "An xxxx is a kind of thing. A yyyy is a kind of thing. An xxxx and a yyyy are part of every person .") Ideally, of course, these should be assemblies that are actually of use in the game.
67
68
It has been suggested that possession-by-enclosure should be available as an option (allowing "Lois is wearing a hat. A tassel is part of the hat. Test me with 'x Lois's tassel'. ") This may become available in a future version, but currently I don't wish to add the necessary option test on every "Understand" line. If a future version of Inform allows sections to be conditionally incorporated (similar to "For use with Extension X"), then I will definitely add this.