예제 #1
0
def test_add_active_warp_scanner_command(brain, cmd, args):
    parser.parse([], args)
    mobile = brain.mobile
    i = item.Item()
    i.name = "Active Warp Scanner"
    mobile.aux["inventory"].inventory.append(i)
    pantsmud.game.environment.add_item(i)
    message.command_success(mobile, cmd, {"item": str(i.uuid)})
예제 #2
0
파일: thrust.py 프로젝트: ecdavis/spacegame
def thrust_speed_command(brain, cmd, args):
    params = parser.parse([("speed", parser.INT)], args)
    mobile = brain.mobile
    speed = params["speed"]
    if speed < 0 or speed > 10:
        raise error.CommandFail()  # TODO Add error message.
    mobile.speed = speed
    message.command_success(mobile, cmd)
예제 #3
0
def inventory_command(brain, cmd, args):
    parser.parse([], args)
    mobile = brain.mobile
    fitted_data = mobile.aux["inventory"].fitted
    if fitted_data:
        fitted_data = {fitted_data.name: str(fitted_data.uuid)}
    inventory = mobile.aux["inventory"].inventory
    inventory_data = {i.name: str(i.uuid) for i in inventory}
    message.command_success(mobile, cmd, {"fitted": fitted_data, "inventory": inventory_data})
예제 #4
0
파일: chat.py 프로젝트: ecdavis/spacegame
def chat_global_command(brain, cmd, args):
    params = parser.parse([("message", parser.STRING)], args)
    mobile = brain.mobile
    universe = mobile.universe
    data = {"mobile_from": mobile.name, "message": params["message"]}
    message.command_success(mobile, cmd, data)
    for m in universe.get_mobiles():
        if m is mobile:
            continue
        message.notify(m, cmd, data)
예제 #5
0
def unfit_command(brain, cmd, args):
    parser.parse([], args)
    mobile = brain.mobile
    if mobile.aux["inventory"].fitted is None:
        raise error.CommandFail()
    inventory = mobile.aux["inventory"].inventory[:]
    fitted_item = mobile.aux["inventory"].fitted
    inventory.append(fitted_item)
    mobile.aux["inventory"].fitted = None
    mobile.aux["inventory"].inventory = inventory
    message.command_success(mobile, cmd)
예제 #6
0
파일: jump.py 프로젝트: ecdavis/spacegame
def jump_command(brain, cmd, args):
    params = parser.parse([("system_name", parser.STRING)], args)
    mobile = brain.mobile
    universe = pantsmud.game.environment
    star_system = universe.get_star_system(params["system_name"])
    if not star_system:
        raise error.CommandFail()  # TODO Add error message.
    elif mobile.star_system is star_system:
        raise error.CommandFail()  # TODO Add error message.
    hook.run(hook_types.STAR_SYSTEM_EXIT, mobile)
    mobile.celestial = random.choice(list(star_system.core_celestials))
    message.command_success(mobile, cmd, None)
예제 #7
0
파일: thrust.py 프로젝트: ecdavis/spacegame
def thrust_vector_command(brain, cmd, args):
    params = parser.parse([("x", parser.FLOAT), ("y", parser.FLOAT), ("z", parser.FLOAT)], args)
    mobile = brain.mobile
    x = round(params["x"], 3)
    y = round(params["y"], 3)
    z = round(params["z"], 3)
    vector = (x, y, z)
    if x > 1.0 or y > 1.0 or z > 1.0:
        raise error.CommandFail()  # TODO Add error message.
    if abs(1.0 - sum((abs(x), abs(y), abs(z)))) > 0.001:
        raise error.CommandFail()  # TODO Add error message.
    mobile.vector = vector
    message.command_success(mobile, cmd)
예제 #8
0
파일: chat.py 프로젝트: ecdavis/spacegame
def chat_private_command(brain, cmd, args):
    params = parser.parse([("mobile_name", parser.WORD), ("message", parser.STRING)], args)
    mobile = brain.mobile
    target = mobile.universe.get_entity(params["mobile_name"])
    if not target:
        raise error.CommandFail()  # TODO Add error message.
    if target is mobile:
        raise error.CommandFail()  # TODO Add error message.
    data = {
        "mobile_from": mobile.name,
        "mobile_to": target.name,
        "message": params["message"]
    }
    message.notify(target, cmd, data)
    message.command_success(mobile, cmd, data)
예제 #9
0
def fit_command(brain, cmd, args):
    params = parser.parse([("item_uuid", parser.UUID)], args)
    mobile = brain.mobile
    if mobile.aux["inventory"].fitted:
        raise error.CommandFail()
    inventory = mobile.aux["inventory"].inventory[:]
    fittable_item = None
    for i in inventory:
        if i.uuid == params["item_uuid"]:
            fittable_item = i
    if fittable_item is None:
        raise error.CommandFail()
    inventory = [i for i in inventory if i.uuid != params["item_uuid"]]
    mobile.aux["inventory"].fitted = fittable_item
    mobile.aux["inventory"].inventory = inventory
    message.command_success(mobile, cmd)
예제 #10
0
파일: info.py 프로젝트: ecdavis/spacegame
def position_command(brain, cmd, args):
    parser.parse([], args)
    mobile = brain.mobile
    message.command_success(mobile, cmd, {"position": mobile.position})
예제 #11
0
파일: info.py 프로젝트: ecdavis/spacegame
def location_command(brain, cmd, args):
    parser.parse([], args)
    mobile = brain.mobile
    message.command_success(mobile, cmd, {"celestial": mobile.celestial.name, "star_system": mobile.star_system.name})
예제 #12
0
파일: warp.py 프로젝트: ecdavis/spacegame
def warp_command(brain, cmd, args):
    params = parser.parse([("destination_uuid", parser.UUID)], args)
    result = warp.do_warp(brain.mobile, params["destination_uuid"])
    message.command_success(brain, cmd, result)
예제 #13
0
파일: warp.py 프로젝트: ecdavis/spacegame
def warp_scan_activate_command(brain, cmd, args):
    parser.parse([], args)
    result = warp.do_warp_scan_activate(brain.mobile)
    message.command_success(brain, cmd, result)
예제 #14
0
파일: warp.py 프로젝트: ecdavis/spacegame
def warp_beacon_command(brain, cmd, args):
    parser.parse([], args)
    result = warp.do_warp_beacon(brain.mobile)
    message.command_success(brain, cmd, result)