Ejemplo n.º 1
0
        /// <summary>
        /// Set a memory in your story
        /// </summary>
        /// <param name="token">Provide the token of the play-through where the memory should be changed.</param>
        /// <param name="recallValue">The recall value of the memory.</param>
        /// <param name="saveValue">The new value of the memory.</param>
        /// <param name="callback">Called when the mood has successfully been set.</param>
        public static void SetMemory(string token, string recallValue, string saveValue, Action callback = null)
        {
            var memory = new SetMemoryParams(recallValue, saveValue);

            var request = new HTTPRequest(
                new Uri($"{BaseUrl}/play/set-memory/"), HTTPMethods.Post, (
                    (originalRequest, response) =>
            {
                if (!response.IsSuccess)
                {
                    Debug.LogError("Error:" + originalRequest.Response.DataAsText);
                    return;
                }

                CharismaLogger.Log($"Set memory - '{memory.memoryRecallValue}' with value '{memory.saveValue}'");
                callback?.Invoke();
            }))
            {
                RawData = Encoding.UTF8.GetBytes(CharismaUtilities.ToJson(memory))
            };

            request.SetHeader("Authorization", $"Bearer {token}");
            request.AddHeader("Content-Type", "application/json");
            request.UseAlternateSSL = true;
            request.Send();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set the mood of a Character in your story.
        /// </summary>
        /// <param name="token">Provide the token of the play-through where a characters mood should be set.</param>
        /// <param name="characterName">The name of the character who's mood should be set.</param>
        /// <param name="mood">The mood to update to.</param>
        /// <param name="callback">Called when the mood has successfully been set.</param>
        public static void SetMood(string token, string characterName, Mood mood, Action callback = null)
        {
            if (mood == null || characterName == null)
            {
                Debug.LogError("Charisma: You need to provide both a character name and a character mood modifier.");
                return;
            }

            var newMood = new SetMoodParams(characterName, mood);

            CharismaLogger.Log($"Setting new mood for {characterName}: CharismaUtilities.ToJson(newMood)");

            var request = new HTTPRequest(
                new Uri($"{BaseUrl}/play/set-mood"), HTTPMethods.Post, (
                    (originalRequest, response) =>
            {
                if (!response.IsSuccess)
                {
                    Debug.LogError("Error:" + originalRequest.Response.DataAsText);
                    return;
                }

                CharismaLogger.Log($"Updated mood of '{characterName}'");

                callback?.Invoke();
            }))
            {
                RawData = Encoding.UTF8.GetBytes(CharismaUtilities.ToJson(newMood))
            };

            request.SetHeader("Authorization", $"Bearer {token}");
            request.AddHeader("Content-Type", "application/json");
            request.UseAlternateSSL = true;
            request.Send();
        }