You’re touching on one of Inform’s great weaknesses. The strong typing system makes it very difficult to refer to properties in the abstract; the assumption seems to be that authors will write spaghetti code when situations like these arise.
Anyway, here’s a solution that uses spaghetti in only one place: an “initialize property correspondences rule” that assigns texts (“Strength”, “Agility”, etc.) to the number that defines the property internally. Basically, we typecast the property to a number and assign the text description of the property to the same number. We can then grab the number from either side and typecast to the value we’re after.
[code]A person has a number called Strength. A person has a number called Agility.
The strength of the player is 12. The agility of the player is 15.
Table of Skill Difficulties
Skill Ability Difficulty
“Brawl” “Strength” 4
“Dodge” “Agility” 4
Test is a room.
To decide what number is (P - a property) converted to a number: (- {P} -).
To decide what property is (N - a number) as a property: (- {N} -).
To decide what number is the skill value associated with (P - a number) of (target - a person):
(- {target}.{P} -).
Property-naming relates one text to one number. The verb to property-name (he property-names, they property-name) implies the property-naming relation.
After starting the virtual machine (this is the initialize property numbers rule):
now “Strength” property-names strength converted to a number;
now “Agility” property-names agility converted to a number.
When play begins:
choose a random row in the Table of Skill Difficulties;
let diff be difficulty entry;
say “[skill entry] tests [ability entry].”;
let P be the number to which the ability entry relates by the property-naming relation;
let V be skill value associated with P of the player;
say “Your [ability entry] score is [V].”[/code]
Related issues can be found in these threads:
https://intfiction.org/t/i7-tables-and-functional-programming/2045/1
https://intfiction.org/t/i7-typecasting-and-phrases/2080/1