Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[bin/crypt] introduced "phrases"

Customized descriptions of things.
  • Loading branch information...
commit 44ef4e38fa47a69830a54ed51f85b53c293ab56c 1 parent f1219e1
@masak authored
Showing with 45 additions and 6 deletions.
  1. +33 −6 bin/crypt
  2. +12 −0 game-data/descriptions
View
39 bin/crypt
@@ -1522,8 +1522,17 @@ inventory";
say "";
}
for .things -> $thing {
+ sub announce($thing) {
+ if %descriptions{"phrase:$thing"} -> $phrase {
+ say sprintf $phrase, $thing;
+ }
+ else {
+ say "There is a $thing here.";
+ }
+ }
+
if $thing ~~ Pair {
- say "There is a $thing.key() here.";
+ announce $thing.key;
# XXX: Needs to work for nested calls, too
say "The $thing.key() contains:";
for $thing.value.list -> $containee {
@@ -1531,7 +1540,7 @@ inventory";
}
}
else {
- say "There is a $thing here.";
+ announce $thing;
}
}
if .exits {
@@ -1624,8 +1633,17 @@ inventory";
say "";
}
for .things -> $thing {
+ sub announce($thing) {
+ if %descriptions{"phrase:$thing"} -> $phrase {
+ say sprintf $phrase, $thing;
+ }
+ else {
+ say "There is a $thing here.";
+ }
+ }
+
if $thing ~~ Pair {
- say "There is a $thing.key() here.";
+ announce $thing.key;
# XXX: Needs to work for nested calls, too
say "The $thing.key() contains:";
for $thing.value.list -> $containee {
@@ -1633,7 +1651,7 @@ inventory";
}
}
else {
- say "There is a $thing here.";
+ announce $thing;
}
}
if .exits {
@@ -1672,8 +1690,17 @@ inventory";
if .things {
say "You are carrying:";
for .things -> $thing {
+ sub announce($thing) {
+ if %descriptions{"phrase:$thing"} -> $phrase {
+ say sprintf $phrase, $thing;
+ }
+ else {
+ say "A $thing.";
+ }
+ }
+
if $thing ~~ Pair {
- say "A $thing.key().";
+ announce $thing.key;
# XXX: Needs to work for nested calls, too
say "The $thing.key() contains:";
for $thing.value.list -> $containee {
@@ -1681,7 +1708,7 @@ inventory";
}
}
else {
- say "A $thing.";
+ announce $thing;
}
}
}
View
12 game-data/descriptions
@@ -122,3 +122,15 @@ You die.
== remark:made-it-out-with-treasure
Congratulations! You found the treasure and got out with it
alive!
+
+== phrase:car
+Your %s is parked here.
+
+== phrase:leaves
+69,105 %s.
+
+== phrase:brook
+A small %s runs through the forest.
+
+== phrase:water
+Some %s.
Please sign in to comment.
Something went wrong with that request. Please try again.