コード例 #1
0
def find_thing(name, person_or_place):
    thing = find_object_by_name(name, person_or_place_things(person_or_place))
    if not thing:
        tell([
            "There is nothing called", name,
            *person_or_place_name(person_or_place)
        ], world.my_avatar)
    return thing
コード例 #2
0
ファイル: motion.py プロジェクト: mbillingr/sdf
def move_person(person, src, dst, actor):
    if src is world.heaven or dst is world.heaven:
        move_internal(person, src, dst)
    exit = src.find_exit(dst)
    if not exit:
        tell(["There is no exit from", src, "to", dst], actor)
    elif person is actor:
        narrate([person, "leaves via the", exit.direction, "exit"], src)
        move_internal(person, src, dst)
    else:
        narrate(["You can't force", person, "to move!"], actor)
コード例 #3
0
def look_in_bag(person_name=None):
    if person_name is None:
        person = world.my_avatar
    else:
        person = find_person(person_name)

    if person:
        referent = local_possessive(person)
        things = person.get_things()
        if not things:
            messaging.tell([referent, "bag is empty"], world.my_avatar)
        else:
            messaging.tell([referent, "bag contains", *things],
                           world.my_avatar)
コード例 #4
0
ファイル: motion.py プロジェクト: mbillingr/sdf
def move_steal(mobile_thing, from_bag, to_bag, actor):
    former_holder = from_bag.holder
    new_holder = to_bag.holder

    if from_bag is to_bag:
        tell([new_holder, "is already carrying", mobile_thing], actor)
    elif actor is former_holder:
        narrate([actor, "gives", mobile_thing, "to", new_holder], actor)
    elif actor is new_holder:
        narrate([actor, "takes", mobile_thing, "from", former_holder], actor)
    else:
        narrate([actor, "takes", mobile_thing, "from", former_holder, "and gives it to", new_holder], actor)

    if actor is not former_holder:
        say(former_holder, ["Yaaaah! I am upset!"])
    if actor is not new_holder:
        say(new_holder, ["Whoa! Where'd you get this?"])
    if from_bag is not to_bag:
        move_internal(mobile_thing, from_bag, to_bag)
コード例 #5
0
def tell(person_name, *message):
    messaging.tell(list(message), find_person(person_name))
コード例 #6
0
ファイル: motion.py プロジェクト: mbillingr/sdf
def teleport_thing(mobile_thing, from_place, to_place, actor):
    if from_place is to_place:
        tell([mobile_thing, "is already in", to_place], actor)
    else:
        tell(["How do you propose to move", mobile_thing, "without carrying it?"], actor)
コード例 #7
0
ファイル: motion.py プロジェクト: mbillingr/sdf
from .place import Place
from .thing import Thing


def take_thing(thing, person):
    move(thing, person.bag, person)


def drop_thing(thing, person):
    move(thing, person.location, person)


# default generic move
generic_move.add_handler(
    match_args(Thing, Container, Container, Person),
    lambda thing, src, dst, actor: tell([thing, "is not movable"], actor)
)


def move_steal(mobile_thing, from_bag, to_bag, actor):
    former_holder = from_bag.holder
    new_holder = to_bag.holder

    if from_bag is to_bag:
        tell([new_holder, "is already carrying", mobile_thing], actor)
    elif actor is former_holder:
        narrate([actor, "gives", mobile_thing, "to", new_holder], actor)
    elif actor is new_holder:
        narrate([actor, "takes", mobile_thing, "from", former_holder], actor)
    else:
        narrate([actor, "takes", mobile_thing, "from", former_holder, "and gives it to", new_holder], actor)
コード例 #8
0
def find_person(name):
    person = find_object_by_name(name, world.my_avatar.people_here())
    if not person:
        tell(["There is no one called", name, "here"], world.my_avatar)
    return person