Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[bin/crypt] introduced "phrases"

Customized descriptions of things.
  • Loading branch information...
commit 44ef4e38fa47a69830a54ed51f85b53c293ab56c 1 parent f1219e1
Carl Mäsak authored July 30, 2012
39  bin/crypt
@@ -1522,8 +1522,17 @@ inventory";
1522 1522
                             say "";
1523 1523
                         }
1524 1524
                         for .things -> $thing {
  1525
+                            sub announce($thing) {
  1526
+                                if %descriptions{"phrase:$thing"} -> $phrase {
  1527
+                                    say sprintf $phrase, $thing;
  1528
+                                }
  1529
+                                else {
  1530
+                                    say "There is a $thing here.";
  1531
+                                }
  1532
+                            }
  1533
+
1525 1534
                             if $thing ~~ Pair {
1526  
-                                say "There is a $thing.key() here.";
  1535
+                                announce $thing.key;
1527 1536
                                 # XXX: Needs to work for nested calls, too
1528 1537
                                 say "The $thing.key() contains:";
1529 1538
                                 for $thing.value.list -> $containee {
@@ -1531,7 +1540,7 @@ inventory";
1531 1540
                                 }
1532 1541
                             }
1533 1542
                             else {
1534  
-                                say "There is a $thing here.";
  1543
+                                announce $thing;
1535 1544
                             }
1536 1545
                         }
1537 1546
                         if .exits {
@@ -1624,8 +1633,17 @@ inventory";
1624 1633
                             say "";
1625 1634
                         }
1626 1635
                         for .things -> $thing {
  1636
+                            sub announce($thing) {
  1637
+                                if %descriptions{"phrase:$thing"} -> $phrase {
  1638
+                                    say sprintf $phrase, $thing;
  1639
+                                }
  1640
+                                else {
  1641
+                                    say "There is a $thing here.";
  1642
+                                }
  1643
+                            }
  1644
+
1627 1645
                             if $thing ~~ Pair {
1628  
-                                say "There is a $thing.key() here.";
  1646
+                                announce $thing.key;
1629 1647
                                 # XXX: Needs to work for nested calls, too
1630 1648
                                 say "The $thing.key() contains:";
1631 1649
                                 for $thing.value.list -> $containee {
@@ -1633,7 +1651,7 @@ inventory";
1633 1651
                                 }
1634 1652
                             }
1635 1653
                             else {
1636  
-                                say "There is a $thing here.";
  1654
+                                announce $thing;
1637 1655
                             }
1638 1656
                         }
1639 1657
                         if .exits {
@@ -1672,8 +1690,17 @@ inventory";
1672 1690
                         if .things {
1673 1691
                             say "You are carrying:";
1674 1692
                             for .things -> $thing {
  1693
+                                sub announce($thing) {
  1694
+                                    if %descriptions{"phrase:$thing"} -> $phrase {
  1695
+                                        say sprintf $phrase, $thing;
  1696
+                                    }
  1697
+                                    else {
  1698
+                                        say "A $thing.";
  1699
+                                    }
  1700
+                                }
  1701
+
1675 1702
                                 if $thing ~~ Pair {
1676  
-                                    say "A $thing.key().";
  1703
+                                    announce $thing.key;
1677 1704
                                     # XXX: Needs to work for nested calls, too
1678 1705
                                     say "The $thing.key() contains:";
1679 1706
                                     for $thing.value.list -> $containee {
@@ -1681,7 +1708,7 @@ inventory";
1681 1708
                                     }
1682 1709
                                 }
1683 1710
                                 else {
1684  
-                                    say "A $thing.";
  1711
+                                    announce $thing;
1685 1712
                                 }
1686 1713
                             }
1687 1714
                         }
12  game-data/descriptions
@@ -122,3 +122,15 @@ You die.
122 122
 == remark:made-it-out-with-treasure
123 123
 Congratulations! You found the treasure and got out with it
124 124
 alive!
  125
+
  126
+== phrase:car
  127
+Your %s is parked here.
  128
+
  129
+== phrase:leaves
  130
+69,105 %s.
  131
+
  132
+== phrase:brook
  133
+A small %s runs through the forest.
  134
+
  135
+== phrase:water
  136
+Some %s.

0 notes on commit 44ef4e3

Please sign in to comment.
Something went wrong with that request. Please try again.