Esempio n. 1
0
        public List <string> GetAvailableQuests(AgentPrivate Quester)
        {
            List <string> QuestIds = new List <string>();

            HttpRequestOptions options = new HttpRequestOptions();

            options.Method = HttpRequestMethod.GET;

            Guid   PersonaId          = Quester.AgentInfo.AvatarUuid;
            string availableQuestsUrl = $"{BaseUrl}/players/{PersonaId}/characters/{CharacterId}/quest-definitions";

            Quester.SendChat($"{availableQuestsUrl}");
            var result = WaitFor(ScenePrivate.HttpClient.Request, availableQuestsUrl, options) as HttpClient.RequestData;

            if (!result.Success || result.Response.Status != 200)
            {
                return(QuestIds);
            }

            string jsonResponse = result.Response.Body;

            Quester.SendChat($"{jsonResponse}");
            StorylineResponse parsed = ((JsonSerializationData <StorylineResponse>)(WaitFor(JsonSerializer.Deserialize <StorylineResponse>, jsonResponse))).Object;

            Quester.SendChat(parsed.ToString());
            foreach (QuestData d in parsed.data)
            {
                QuestIds.Add(d.id);
            }
            return(QuestIds);
        }
        public void GetAvailableQuests(AgentPrivate Quester)
        {
            HttpRequestOptions options = new HttpRequestOptions();

            options.Method = HttpRequestMethod.GET;

            Guid   PersonaId          = Quester.AgentInfo.AvatarUuid;
            string availableQuestsUrl = $"{BaseUrl}/players/{PersonaId}/storylines/{StorylineId}/quests";

            Quester.SendChat($"{availableQuestsUrl}");
            var result = WaitFor(ScenePrivate.HttpClient.Request, availableQuestsUrl, options) as HttpClient.RequestData;

            if (!result.Success || result.Response.Status != 200)
            {
                return;
            }

            string jsonResponse = result.Response.Body;

            Quester.SendChat($"{jsonResponse}");
            JsonSerializerOptions jsonOptions = new JsonSerializerOptions
            {
                SerializeReferences = false
            };
            StorylineResponse parsed = ((JsonSerializationData <StorylineResponse>)(WaitFor(JsonSerializer.Deserialize <StorylineResponse>, jsonResponse, jsonOptions))).Object;

            if (parsed.data.Count == 0)
            {
                return;
            }
            Quester.SendChat(parsed.ToString());
            Quester.SendChat(parsed.data.ToString());
            Quester.SendChat(parsed.data[0].ToString());
            Quester.SendChat(parsed.data[0].id.ToString());

            string QuestId    = parsed.data[0].id;
            string QuestTitle = parsed.data[0].title;

            Quester.SendChat($"questID: {QuestId}");
            Quester.SendChat($"questTitle: {QuestTitle}");
            Quester.SendChat($"questObjectives: {parsed.data[0].objectiveDefinitions.ToString()}");

            GetQuest(Quester, QuestId);
        }
Esempio n. 3
0
        public List <string> CompleteAnyQuests(AgentPrivate Quester)
        {
            List <string> QuestIds = new List <string>();

            HttpRequestOptions options = new HttpRequestOptions();

            options.Method  = HttpRequestMethod.PATCH;
            options.Headers = new Dictionary <string, string>()
            {
                { "content-type", "application/json" }
            };
            options.Body = $"{{\"data\": {{\"state\":\"COMPLETED\"}} }}";

            Guid   PersonaId         = Quester.AgentInfo.AvatarUuid;
            string completeQuestsUrl = $"{BaseUrl}/players/{PersonaId}/characters/{CharacterId}/objectives/{CompleteObjectiveHandle}";

            Quester.SendChat(completeQuestsUrl);

            var result = WaitFor(ScenePrivate.HttpClient.Request, completeQuestsUrl, options) as HttpClient.RequestData;

            if (!result.Success || result.Response.Status != 200)
            {
                return(QuestIds);
            }

            string jsonResponse = result.Response.Body;

            Quester.SendChat($"{jsonResponse}");
            StorylineResponse parsed = ((JsonSerializationData <StorylineResponse>)(WaitFor(JsonSerializer.Deserialize <StorylineResponse>, jsonResponse))).Object;

            Quester.SendChat(parsed.ToString());

            foreach (QuestData d in parsed.data)
            {
                QuestIds.Add(d.id);
            }
            return(QuestIds);
        }