Beispiel #1
0
def setSp(player, sp):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    if sp not in ["save1", "save2"]:
        return {"msg": "Unknown save point.", "suc": False}
    pos, dim = __getPlayerPos(player)
    pos = str(pos)[1:-1].replace(",", "")
    try:
        row = modules.SavePoint.query.get(player)
        if sp == "save1":
            row.save1_pos = pos
            row.save1_dim = dim
            database.db.session.commit()
        elif sp == "save2":
            row.save2_pos = pos
            row.save2_dim = dim
            database.db.session.commit()
    except Exception as e:
        print(e)
        return {"msg": e, "suc": False}
    __tell(player, f"设置{sp}到 {pos}({dim}).")
    return {"msg": f"Set {sp} to {pos}({dim}).", "suc": True}
Beispiel #2
0
def spawn(player):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    resp = __tp(player, SPAWN_POINT)
    if "No entity was found" in resp:
        return {"msg": resp, "suc": False}
    return {"msg": resp, "suc": True}
Beispiel #3
0
def tpPlayer(player, target_player):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    resp = __tp(player, target_player)
    if modules.User.query.get(target_player) is None:
        return {"msg": "Unknown target", "suc": False}
    if "No entity was found" in resp:
        return {"msg": resp, "suc": False}
    return {"msg": resp, "suc": True}
Beispiel #4
0
def tpWt(player, wt):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    if wt not in WORLD_TELEPOINT:
        return {"msg": "Unknown Wt", "suc": False}
    resp = __tp(player, WORLD_TELEPOINT[wt]["pos"], WORLD_TELEPOINT[wt]["dim"])
    if "No entity was found" in resp:
        return {"msg": resp, "suc": False}
    return {"msg": resp, "suc": True}
Beispiel #5
0
def home(player):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    home_pos = modules.User.query.get(player).home_pos
    home_dim = modules.User.query.get(player).home_dim
    resp = __tp(player, home_pos, dimension=home_dim)
    if "No entity was found" in resp:
        return {"msg": resp, "suc": False}
    return {"msg": resp, "suc": True}
Beispiel #6
0
def setHome(player):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    pos, dim = __getPlayerPos(player)
    try:
        row = modules.User.query.get(player)
        row.home_pos = str(pos)[1:-1].replace(",", "")
        row.home_dim = dim
        database.db.session.commit()
    except Exception as e:
        return {"msg": e, "suc": False}
    __tell(player, f"设置Home到 {pos}({dim}).")
    return {"msg": f"Set home to {pos}({dim}).", "suc": True}
Beispiel #7
0
def tpSp(player, sp):
    if player is None:
        return {"msg": "? id ne ?", "suc": False}
    if not __onlineCheck(player):
        return {"msg": "玩家不在线", "suc": False}
    if getUid() != player:
        return {"msg": "Context异常", "suc": False}
    if sp not in ["save1", "save2"]:
        return {"msg": "Unknown save point.", "suc": False}
    pos = None
    dim = None
    if sp == "save1":
        pos = modules.User.query.get(player).SavePoint[0].save1_pos
        dim = modules.User.query.get(player).SavePoint[0].save1_dim
    elif sp == "save2":
        pos = modules.User.query.get(player).SavePoint[0].save2_pos
        dim = modules.User.query.get(player).SavePoint[0].save2_dim

    resp = __tp(player, pos, dim)
    if "No entity was found" in resp:
        return {"msg": resp, "suc": False}
    return {"msg": resp, "suc": True}