Example #1
0
async def update_initiative_turn(sid: int, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    if pr.role != Role.DM:
        logger.warning(
            f"{pr.player.name} attempted to advance the initiative tracker")
        return

    location_data = InitiativeLocationData.get(location=pr.active_location)
    with db.atomic():
        location_data.turn = data
        location_data.save()

        effects = (InitiativeEffect.select().join(Initiative).where(
            Initiative.uuid == data))
        for effect in effects:
            if effect.turns <= 0:
                effect.delete_instance()
            else:
                effect.turns -= 1
            effect.save()

    await sio.emit(
        "Initiative.Turn.Update",
        data,
        room=pr.active_location.get_path(),
        skip_sid=sid,
        namespace=GAME_NS,
    )
Example #2
0
async def update_initiative_turn(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    if room.creator != user:
        logger.warning(
            f"{user.name} attempted to advance the initiative tracker")
        return

    location_data = InitiativeLocationData.get(location=location)
    with db.atomic():
        location_data.turn = data
        location_data.save()

        effects = (InitiativeEffect.select().join(Initiative).where(
            Initiative.uuid == data))
        for effect in effects:
            if effect.turns <= 0:
                effect.delete_instance()
            else:
                effect.turns -= 1
            effect.save()

    await sio.emit(
        "Initiative.Turn.Update",
        data,
        room=location.get_path(),
        skip_sid=sid,
        namespace="/planarally",
    )
Example #3
0
async def update_initiative_turn(sid: str, data: str):
    pr: PlayerRoom = game_state.get(sid)

    if pr.role != Role.DM:
        logger.warning(
            f"{pr.player.name} attempted to advance the initiative tracker")
        return

    location_data = InitiativeLocationData.get(location=pr.active_location)
    with db.atomic():
        location_data.turn = data
        location_data.save()

        effects = (InitiativeEffect.select().join(Initiative).where(
            Initiative.uuid == data))
        for effect in effects:
            try:
                turns = int(effect.turns)
                if turns <= 0:
                    effect.delete_instance()
                else:
                    effect.turns = str(turns - 1)
            except ValueError:
                # For non-number inputs do not update the effect
                pass
            effect.save()

    await sio.emit(
        "Initiative.Turn.Update",
        data,
        room=pr.active_location.get_path(),
        skip_sid=sid,
        namespace=GAME_NS,
    )
Example #4
0
async def update_initiative_order(sid: int, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    if pr.role != Role.DM:
        logger.warning(
            f"{pr.player.name} attempted to change the initiative order")
        return

    location_data = InitiativeLocationData.get(location=pr.active_location)

    with db.atomic():
        for i, uuid in enumerate(data):
            init = Initiative.get(uuid=uuid)
            init.index = i
            init.save()

    await send_client_initiatives(pr)
Example #5
0
async def update_initiative_order(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    if room.creator != user:
        logger.warning(f"{user.name} attempted to change the initiative order")
        return

    location_data = InitiativeLocationData.get(location=location)

    with db.atomic():
        for i, uuid in enumerate(data):
            init = Initiative.get(uuid=uuid)
            init.index = i
            init.save()

    await send_client_initiatives(room, location)
Example #6
0
async def update_initiative_round(sid: int, data: Dict[str, Any]):
    pr: PlayerRoom = game_state.get(sid)

    if pr.role != Role.DM:
        logger.warning(
            f"{pr.player.name} attempted to advance the initiative tracker")
        return

    location_data = InitiativeLocationData.get(location=pr.active_location)
    with db.atomic():
        location_data.round = data
        location_data.save()

    await sio.emit(
        "Initiative.Round.Update",
        data,
        room=pr.active_location.get_path(),
        skip_sid=sid,
        namespace=GAME_NS,
    )
Example #7
0
async def update_initiative_round(sid, data):
    sid_data = state.sid_map[sid]
    user = sid_data["user"]
    room = sid_data["room"]
    location = sid_data["location"]

    if room.creator != user:
        logger.warning(
            f"{user.name} attempted to advance the initiative tracker")
        return

    location_data = InitiativeLocationData.get(location=location)
    with db.atomic():
        location_data.round = data
        location_data.save()

    await sio.emit(
        "Initiative.Round.Update",
        data,
        room=location.get_path(),
        skip_sid=sid,
        namespace="/planarally",
    )