From ae3912e7607781fc7f9c941ee4f2bf86f551bc83 Mon Sep 17 00:00:00 2001 From: Dinko Galetic Date: Tue, 08 Jun 2010 23:04:38 +0000 Subject: Added unalias() function. unalias() takes a string the user entered and returns an object represented by that string. --- (limited to 'library') 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 -- cgit v0.9.1