示例#1
0
 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
示例#2
0
 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
示例#3
0
 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
示例#4
0
文件: look.py 项目: ViKingIX/grailmud
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)
示例#5
0
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)
示例#6
0
文件: says.py 项目: ViKingIX/grailmud
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.")
示例#7
0
 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)
示例#8
0
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)
示例#9
0
 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
示例#10
0
 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
示例#11
0
 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
示例#12
0
 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