Beispiel #1
0
    /// <summary>
    /// Save game state.
    /// </summary>
    /// <param name="login">authenticated user login</param>
    /// <param name="sceneId">active scene identifier</param>
    /// <param name="player">player state</param>
    /// <param name="extGameState">game state</param>
    /// <returns></returns>
    public void SaveGame(string login, string sceneId, CharacterModel player, ExtendedGameState extGameState)
    {
        // Create game safe point
        var created   = DateTime.UtcNow;
        var gameState = new GameStateModel(
            Guid.NewGuid().ToString(),
            login,
            sceneId,
            string.Format("Save for {0} at {1}", login, created.ToLocalTime()),
            created);
        var gameStateDto = gameState.ConvertToDTO <GameStateDTO>();

        // Create main character safe point state
        var gameStateCharacterDto =
            player.ConvertToDTO <CharacterStateDTO>(gameStateDto.GameStateId);

        // todo: save all objects to Database in transaction
        _connection.Insert(gameStateDto);
        _connection.Insert(gameStateCharacterDto);

        // todo: process extGameState saving
    }