示例#1
0
async def remove_group_if_empty(group_id: str):
    try:
        group = Group.get_by_id(group_id)
    except Group.DoesNotExist:
        return

    if Shape.filter(group=group_id).count() == 0:
        group.delete_instance(True)
示例#2
0
async def remove_group(sid: str, group_id: str):
    pr: PlayerRoom = game_state.get(sid)

    for shape in Shape.filter(group_id=group_id).select():
        shape.group = None
        shape.show_badge = False
        shape.save()

    # check if group still has members
    await remove_group_if_empty(group_id)

    for psid, _ in game_state.get_users(room=pr.room):
        await sio.emit(
            "Group.Remove",
            group_id,
            room=psid,
            skip_sid=sid,
            namespace=GAME_NS,
        )