Beispiel #1
0
async def set_client_location_options(sid: str, data: LocationOptions):
    pr: PlayerRoom = game_state.get(sid)

    LocationUserOption.update(
        pan_x=data["pan_x"],
        pan_y=data["pan_y"],
        zoom_factor=data["zoom_factor"],
    ).where(
        (LocationUserOption.location == pr.active_location)
        & (LocationUserOption.user == pr.player)
    ).execute()
Beispiel #2
0
async def set_client(sid: str, data: ClientOptions):
    pr: PlayerRoom = game_state.get(sid)

    with db.atomic():
        for option, value in data.items():
            if option != "location_options":
                setattr(pr.player, option, value)
        pr.player.save()

    if "location_options" in data:
        LocationUserOption.update(
            pan_x=data["location_options"]["pan_x"],
            pan_y=data["location_options"]["pan_y"],
            zoom_factor=data["location_options"]["zoom_factor"],
        ).where((LocationUserOption.location == pr.active_location)
                & (LocationUserOption.user == pr.player)).execute()
Beispiel #3
0
async def set_client(sid: int, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    with db.atomic():
        for option in [
            ("gridColour", "grid_colour"),
            ("fowColour", "fow_colour"),
            ("rulerColour", "ruler_colour"),
            ("invertAlt", "invert_alt"),
        ]:
            if option[0] in data:
                setattr(pr.player, option[1], data[option[0]])
        pr.player.save()
    if "locationOptions" in data:
        LocationUserOption.update(
            pan_x=data["locationOptions"]["panX"],
            pan_y=data["locationOptions"]["panY"],
            zoom_factor=data["locationOptions"]["zoomFactor"],
        ).where((LocationUserOption.location == pr.active_location)
                & (LocationUserOption.user == pr.player)).execute()
Beispiel #4
0
async def set_client(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    location = sid_data["location"]

    with db.atomic():
        for option in [
            ("gridColour", "grid_colour"),
            ("fowColour", "fow_colour"),
            ("rulerColour", "ruler_colour"),
        ]:
            if option[0] in data:
                setattr(user, option[1], data[option[0]])
        user.save()
    if "locationOptions" in data:
        LocationUserOption.update(
            pan_x=data["locationOptions"]["panX"],
            pan_y=data["locationOptions"]["panY"],
            zoom_factor=data["locationOptions"]["zoomFactor"],
        ).where((LocationUserOption.location == location)
                & (LocationUserOption.user == user)).execute()
Beispiel #5
0
async def update_client_location(player: int, room: int, sid: str,
                                 data: LocationOptions):
    pr = PlayerRoom.get(player=player, room=room)

    LocationUserOption.update(
        pan_x=data["pan_x"],
        pan_y=data["pan_y"],
        zoom_display=data["zoom_display"],
    ).where((LocationUserOption.location == pr.active_location)
            & (LocationUserOption.user == pr.player)).execute()

    if pr.role != Role.DM:
        for p_sid, p_player in game_state.get_t(skip_sid=sid):
            if p_player.role == Role.DM or p_player.player.id == player:
                await sio.emit(
                    "Client.Move",
                    {
                        "player": pr.player.id,
                        **data
                    },
                    room=p_sid,
                    namespace=GAME_NS,
                )