Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDinko Galetic <dgaletic@everflame.(none)>2010-06-08 23:04:38 (GMT)
committer Dinko Galetic <dgaletic@everflame.(none)>2010-06-08 23:04:38 (GMT)
commitae3912e7607781fc7f9c941ee4f2bf86f551bc83 (patch)
treebe75d7d2c02309a9fb12829cc3cd960356a69257
parentbf2a4d7645d9ff2a32859577873f4dcf85f0b2a6 (diff)
Added unalias() function.
unalias() takes a string the user entered and returns an object represented by that string.
-rw-r--r--library/pippy/scholar/scholar.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/pippy/scholar/scholar.py b/library/pippy/scholar/scholar.py
index 0f50f65..58a97f5 100644
--- a/library/pippy/scholar/scholar.py
+++ b/library/pippy/scholar/scholar.py
@@ -108,3 +108,16 @@ def go(player, side):
examine(player, player.position)
else:
print "No such exit."
+
+# An item can be referred to in several ways ("katana" and "sword" for
+# the same item), this function returns the object behind the alias.
+def unalias(player, player_input):
+ if player_input == "here" or player_input == "room":
+ return player.position
+ for exit in player.position.exits:
+ if exit.name == player_input:
+ return exit
+ for item in player.position.contains:
+ if player_input in item.aliases:
+ return item
+ return None