示例#1
0
        public void AddEmptyPreset()
        {
            if (!loaded)
            {
                return;
            }

            JSONNode presetJson = new JSONObject();

            presetJson["name"]          = "Preset " + PresetList.Count;
            presetJson["constellation"] = App.Content.GameSettings.Json["constellation"];
            presetJson["abilities"]     = new JSONArray();
            presetJson["classes"]       = new JSONArray();
            presetJson["kits"]          = new JSONArray();

            var request = App.Server.Request(
                HTTPMethods.Post,
                "preset",
                (JSONNode json_) =>
            {
                ConstellationPreset preset = new ConstellationPreset(
                    json_.AsObject,
                    new PresetLimits(App.Content.GameSettings.NumAbilities, App.Content.GameSettings.NumClasses, App.Content.GameSettings.NumKits));
                PresetList.Add(preset);
                Json["presets"].AsArray.Add(json_);

                PresetAdded(preset);
            });

            request.AddHeader("Content-Type", "application/json");
            request.RawData = System.Text.Encoding.UTF8.GetBytes(presetJson.ToString());
            request.Send();
        }
示例#2
0
        public void RemovePreset(ConstellationPreset preset_)
        {
            if (!loaded)
            {
                return;
            }

            if (!PresetList.Contains(preset_))
            {
                return;
            }

            App.Server.Request(
                HTTPMethods.Delete,
                "champion/" + Json["_id"] + "/preset/" + preset_.Id,
                (JSONNode json_) =>
            {
                PresetList.Remove(preset_);
                foreach (var almostJson in Json["presets"].AsArray)
                {
                    if (almostJson.Value["_id"] == preset_.Id)
                    {
                        Json["presets"].AsArray.Remove(almostJson.Value);
                        break;
                    }
                }

                PresetRemoved(preset_);
            }).Send();
        }
示例#3
0
        private void PopulateFakeClassPreset(JSONArray array_)
        {
            JSONObject fakeClassPreset = new JSONObject();

            fakeClassPreset["classes"] = array_;
            ClassPreset = new ConstellationPreset(
                fakeClassPreset,
                new PresetLimits(0, 3, 0));
        }
示例#4
0
        public void SavePreset(ConstellationPreset preset_)
        {
            if (!loaded)
            {
                return;
            }

            if (preset_.Id != null && !PresetList.Contains(preset_))
            {
                return;
            }

            JSONObject  presetJson = preset_;
            HTTPRequest request;

            if (preset_.Id == null)
            {
                request = App.Server.Request(
                    HTTPMethods.Post,
                    "champion/" + Json["_id"] + "/preset",
                    (JSONNode json_) =>
                {
                    ConstellationPreset preset = new ConstellationPreset(
                        json_.AsObject,
                        new PresetLimits(App.Content.GameSettings.NumAbilities, App.Content.GameSettings.NumClasses, App.Content.GameSettings.NumKits));
                    PresetList.Add(preset);
                    Json["presets"].AsArray.Add(json_);

                    PresetSaved(preset_);
                });
            }
            else
            {
                request = App.Server.Request(
                    HTTPMethods.Put,
                    "champion/" + Json["_id"] + "/preset/",
                    (JSONNode json_) =>
                {
                    PresetSaved(preset_);
                });
            }
            request.AddHeader("Content-Type", "application/json");
            request.RawData = System.Text.Encoding.UTF8.GetBytes(presetJson.ToString());
            request.Send();
        }