Aktionen 4 – Neue Aktionen (Ein besserer Würfel)

Ein paar Sachen an unserem Würfel sind noch unbefriedigend. Man kann zwar mit “take dice” alle vorhandenen Würfel nehmen, aber bei “roll dice” erhalten wir die Fehlermeldung “You can’t use multiple objects with that verb” – man kann also immer nur einen Würfel auf einmal rollen.

Das liegt an unserer Definition, die dem Parser sagt, dass die Aktion jeweils immer nur auf Objekte angewendet werden darf:

Understand "roll [something]" as rolling.

Wenn wir stattdessen schreiben:

Understand "roll [things]" as rolling.

– dann kann man auch gleich mehrere Würfel auf einmal werfen. Allerdings: die Aktion rolling gilt immer noch für genau ein Objekt auf einmal, wir können das für mehrere Objekte jetzt nur abkürzen:

>roll dice
green die: You roll the green die. When it comes to rest on the ground, it shows a 5.
red die: You roll the red die. When it comes to rest on the ground, it shows a 3.


Außerdem stört noch, dass wir nur einmal als Textausgabe erfahren, welche Zahl ein Würfel zeigt. Man möchte das aber doch zwischendurch auch mal nachschauen können. Dazu haben wir mehrere Möglichkeiten.

— Entweder wir fangen die Examine-Regel, Würfel betreffend, ab und ersetzen sie durch unsere eigene Regel:

Instead of examining a die:
	Say "[the description of the noun] Currently, the die shows a [face of the noun]."

Wenn der Beschreibungs-String allerdings leer ist, hätten wir ein unschönes Leerzeichen am Anfang des Wortes, also schreiben wir gründlicher:

Instead of examining a die:
	If the description of the noun is not "":
		Say the description of the noun;
		Say " ";
	Say  "Currently, the die shows a [face]."

The noun bezieht sich wieder auf das direkte Objekt der Regel, [the description] und [the face] sind Attribute davon. Wenn der Kontekt klar ist, kann man das of the noun auch weglassen; daas ginge hier problemlos.

— Oder wir ergänzen eine After-Examining-Regel, Würfel betreffend:

After examining a die:
	Say "Currently, the die shows a [face]."

Da gefällt mir dann allerdings die Ausgabe nicht so gut.

— Dritte Möglichkeit: wir passen das Beschreibungs-Attribut eines Würfels an, so dass zur Beschreibung auch die aktuell gewürfelte Zahl gehört. Wir schreiben einfach:

The description of the green die is "A beautiful jade die. Possibly quite valuable. Currently, it shows a [face]."

Unschön daran ist, dass man das für jeden Würfel extra machen muss. Klar kann man für alle Würfel bei der Klassendefinition festlegen:

The description usually is "Currently, it shows a [face]."

Aber dann hat man nicht mehr die Möglichkeit, den Würfeln eine weitere Beschreibung zu geben, die nichts mit der Zahl zu tun hat. Andererseits wiederum könnte man der Klasse Würfel ein weiteres Textattribut hinzufügen:

A die has a text called the other description.  The other description usually is "A simple cube."
The description of a die is usually "[the other description]  Currently, it shows a [face]."

Wenn man dann seine Objekte so anlegt:

The green die is a die in the Casino. The other description is "A beautiful jade die. Possibly quite valuable."

wird daraus das ursprüngliche Attribut description so belegt, dass es eine Nennung der aktuelle Würfelzahl enthält.

— Und zuletzt bleibt die Möglichkeit, alle Würfel prinzipiell gleich aussehen zu lassen, indem man in der Klasse den Wert des Beschreibungsattributs festlegt:

The description always is "The [printed name] is a [side number in words]-sided die. Currently, it shows a [face]." 

Aber ich bleibe hier bei meiner ersten Lösung:

"Dice 2" by Herr Rau

Chapter 1 - New Kinds

A die is a kind of thing.
It has a number called side number. The side number is usually 6.
It has a number called face. The face is usually 1.
Understand "dice" as the plural of die.

[Alternative mit zusätzlichem Attribut:]

[A die has a text called the other description.  The other description usually is "A simple cube."
The description of a die is usually "[the other description] Currently, it shows a [face]."]

Chapter 2 - New Actions

Rolling is an action applying to one carried thing and requiring light.

Understand "roll [things]" as rolling.
Understand "shake [things]" as rolling.

Check rolling:
	If the noun is not a die, say "You can do that with dice only." instead.
Carry out rolling:
	Now the face of the noun is a random number from 1 to the side number of the noun;
	now the noun is in the location of the player.
Report rolling:
	Say "You roll [the noun]. When it comes to rest on the ground, it shows a [face]."

Instead of examining a die:
	If the description of the noun is not "":
		Say the description of the noun;
		Say " ";
	Say  "Currently, the die shows a [face]."

[Alternative mit After-Regel:]

[
After examining a die:
	Say "Currently, the die shows a [face]."
]	

Chapter 3 - The World

The Casino is a room.
[Nur für Alternative:]
[The green die is a die in the Casino. The other description is "A beautiful jade die. Possibly quite valuable."]
The green die is a die in the Casino. The description is "A beautiful jade die. Possibly quite valuable."
The red die is a die in the Casino. The description is "A perfect plastic cube, sharp-edged with white dots."
The basket is a container in the Casino.

Test me with "Take dice / roll dice  / examine red die / examine green die."

Schreibe einen Kommentar