def test_adjs_number_failure(self): parseres = adjs_pattern.parseString("killer rabbit 42")[0] try: print get_from_rooms(parseres, [self.room], self.info) except UnfoundError: pass else: assert False
def test_adjs_no_number_failure(self): parseres = adjs_pattern.parseString("harmless gopher")[0] try: print get_from_rooms(parseres, [self.room], self.info) except UnfoundError: pass else: assert False
def test_shorttarget_failure(self): parseres = shorttarget_pattern.parseString("$mike")[0] try: print get_from_rooms(parseres, [self.room], self.info) except UnfoundError: pass else: assert False
def lookDistributor(actor, text, info): matcher = Matcher(text) if matcher.match(lookAtPattern): blob, = matcher.results try: target = get_from_rooms(blob, [actor.inventory, actor.room], info) except UnfoundError: unfoundObject(actor) else: lookAt(actor, target) else: lookRoom(actor)
def emoteToWrapper(actor, text, info): try: blob, text = emote_to_pattern.parseString(text) except ParseException: badSyntax() return try: target = get_from_rooms(blob, [actor.inventory, actor.room], info) except UnfoundError: unfoundObject() return text = text.replace('%', '%%') emoteTo(actor, target, 'You have emoted: ' + text, text, text)
def speakToWrapper(actor, text, info): matcher = Matcher(text) if matcher.match(speakToPattern): blob, saying = matcher.results try: target = get_from_rooms(blob, [actor.inventory, actor.room], info) except UnfoundError: unfoundObject(actor) else: speakTo(actor, target, saying) else: badSyntax(actor, "Can't find the end of the target identifier. Use " "',' at its end to specify it.")
def __call__(self, actor, text, info): try: blob, = object_pattern.parseString(text) except ParseException: pass else: try: target = get_from_rooms(blob, [actor.inventory, actor.room], info) self.send_out_events(actor, target) except UnfoundError: pass else: return self.fallback(actor)
def targetDistributor(actor, text, info): if info.instigator is not actor: permissionDenied(info.instigator) return matcher = Matcher(text) if matcher.match(target_set_pattern): (name,), blob = matcher.results try: target = get_from_rooms(blob, [actor.inventory, actor.room], info) except UnfoundError: unfoundObject(actor) else: targetSet(actor, name.lower(), target) elif matcher.match(target_clear_pattern): (name,), = matcher.results targetClear(actor, name.lower()) elif matcher.match(target_list_pattern): targetList(actor) else: badSyntax(actor)
def test_not_in_very_first_room(self): parseres = adjs_pattern.parseString("KILLER RABBIT")[0] res = get_from_rooms(parseres, [self.bogusroom, self.room], self.info) assert res is self.target
def test_adjs_caseless(self): parseres = adjs_pattern.parseString("KILLER RABBIT")[0] res = get_from_rooms(parseres, [self.room], self.info) assert res is self.target
def test_adjs_numbered_success(self): parseres = adjs_pattern.parseString("killer rabbit 0")[0] res = get_from_rooms(parseres, [self.room], self.info) assert res is self.target
def test_shorttarget_caseless(self): parseres = shorttarget_pattern.parseString("$BOB")[0] res = get_from_rooms(parseres, [self.room], self.info) assert res is self.target