namespace Stove.StoveSDK
{
    using System.Collections.Generic;

    /**
     * User information included in a game log.
     *
     * Returned by the resolver registered in GameLog.Configure at log creation time (lazily).
     * All three values are optional.
     * @since 3.0.0
     */
    public class GameLogUserInfo
    {
        /**
         * GUID or member_no. When null, the log's guid is recorded as "0".
         * @since 3.0.0
         */
        public string UserId { get; set; }

        /**
         * Game character number. Included in the log only when greater than 0.
         * @since 3.0.0
         */
        public long? CharacterNo { get; set; }

        /**
         * World ID. Included in the log only when not empty.
         * @since 3.0.0
         */
        public string WorldId { get; set; }

        /**
         * Default constructor.
         * @since 3.0.0
         */
        public GameLogUserInfo() { }

        /**
         * Constructor with values.
         * @param userId GUID or member_no.
         * @param characterNo Game character number.
         * @param worldId World ID.
         * @since 3.0.0
         */
        public GameLogUserInfo(string userId, long? characterNo, string worldId)
        {
            UserId = userId;
            CharacterNo = characterNo;
            WorldId = worldId;
        }

        /**
         * Dictionary serialization used to pass the value to the native module.
         * Keys: "userId"(string), "characterNo"(long), "worldId"(string).
         * @return Dictionary representation. Only non-null values are included.
         * @since 3.0.0
         */
        public Dictionary<string, object> ToDictionary()
        {
            Dictionary<string, object> dictionary = new Dictionary<string, object>();
            if (UserId != null)
            {
                dictionary.Add("userId", UserId);
            }
            if (CharacterNo.HasValue)
            {
                dictionary.Add("characterNo", CharacterNo.Value);
            }
            if (WorldId != null)
            {
                dictionary.Add("worldId", WorldId);
            }
            return dictionary;
        }
    }
}
