예제 #1
0
파일: __init__.py 프로젝트: last-ent/goplay
def resign(conn, game_id, trans=None):
    player = conn.data["user"]
    game = player.getGameById(game_id)

    if game is not None:
        player_name = player.db_tuple.name

        if player_name in [game._config.black, game._config.white]:
            if game.resign(player):
                response = GameOk.ok_resign()
            else:
                response = GameError.error_resign()
        else:
            response = GameError.not_your_game()
    else:
        response = GameError.user_doesnt_know_game_id()

    conn.send(response, trans)