コード例 #1
0
 public bool Load(string Name)
 {
     if (!Saves.ContainsKey(Name))
     {
         return(false);
     }
     else
     {
         Selected = Saves[Name];
         return(true);
     }
 }
コード例 #2
0
        public bool New(string Name, string Description = default)
        {
            if (FilesystemUtil.Sys.DirExists("Saves/" + Name) || Saves.ContainsKey(Name))
            {
                return(false);
            }

            Dictionary <string, uint> NewRegistry = new Dictionary <string, uint>();

            uint Counter = 0;

            foreach (var Entry in EntriesSys.Entries.GetEntries())
            {
                NewRegistry[Entry] = Counter;
                Counter++;
            }

            Registry Registry = new Registry();

            Registry.Init();

            Save NewSave = new Save
            {
                Description = Description,
                Core        = Sys.Ref.Shared.GetObject <ModSys>().Core.Mod,
                Dependency  = Sys.Ref.Shared.GetObject <ModSys>().LoadOrder,
                Time        = DateTime.Now.ToString(),
                Path        = "Saves/" + Name,
                Registry    = Registry
            };

            FilesystemUtil.Sys.DirCreate("Saves/" + Name);

            try
            {
                FilesystemUtil.Sys.FileWrite("Saves/" + Name + "/Manifest.json", JsonConvert.SerializeObject(NewSave));
            }
            catch (Exception)
            {
                return(false);
            }

            Saves[Name] = NewSave;

            return(true);
        }
コード例 #3
0
        private void SetupSheet()
        {
            if (RawAbilities != null)
            {
                if (RawAbilities.Count == 0)
                {
                    DefaultLoadAbilities();
                }
                else
                {
                    foreach (KeyValuePair <string, string> item in RawAbilities)
                    {
                        switch (item.Key)
                        {
                        case "luk":
                            try { Luck = int.Parse(item.Value); } catch (FormatException) { Luck = 0; }
                            break;

                        case "int":
                            try { Intellect = int.Parse(item.Value); } catch (FormatException) { Intellect = 0; }
                            break;

                        case "cha":
                            try { Charisma = int.Parse(item.Value); } catch (FormatException) { Charisma = 0; }
                            break;

                        case "str":
                            try { Strength = int.Parse(item.Value); } catch (FormatException) { Strength = 0; }
                            break;

                        case "agi":
                            try { Agility = int.Parse(item.Value); } catch (FormatException) { Agility = 0; }
                            break;

                        case "end":
                            try { Endurance = int.Parse(item.Value); } catch (FormatException) { Endurance = 0; }
                            break;

                        case "per":
                            try { Perception = int.Parse(item.Value); } catch (FormatException) { Perception = 0; }
                            break;

                        default:
                            break;
                        }
                    }
                    AbilitiesPresent = true;
                }
            }
            else
            {
                DefaultLoadAbilities();
            }

            if (RawPotential != null)
            {
                if (RawPotential.Count == 0)
                {
                    DefaultLoadPotential();
                }
                else
                {
                    foreach (KeyValuePair <string, string> item in RawPotential)
                    {
                        switch (item.Key)
                        {
                        case "luk":
                            try { PotLuck = int.Parse(item.Value); } catch (FormatException) { PotLuck = 20; }
                            break;

                        case "int":
                            try { PotIntellect = int.Parse(item.Value); } catch (FormatException) { PotIntellect = 20; }
                            break;

                        case "cha":
                            try { PotCharisma = int.Parse(item.Value); } catch (FormatException) { PotCharisma = 20; }
                            break;

                        case "str":
                            try { PotStrength = int.Parse(item.Value); } catch (FormatException) { PotStrength = 20; }
                            break;

                        case "agi":
                            try { PotAgility = int.Parse(item.Value); } catch (FormatException) { PotAgility = 20; }
                            break;

                        case "end":
                            try { PotEndurance = int.Parse(item.Value); } catch (FormatException) { PotEndurance = 20; }
                            break;

                        case "per":
                            try { PotPerception = int.Parse(item.Value); } catch (FormatException) { PotPerception = 20; }
                            break;

                        default:
                            break;
                        }
                    }
                    PotentialPresent = true;
                }
            }
            else
            {
                DefaultLoadPotential();
            }

            // also, let's check the saving throws
            if (Saves.Count == 0)
            {
                Saves["fort"]   = new Save();
                Saves["reflex"] = new Save();
                Saves["will"]   = new Save();
            }
            else
            {
                if (!Saves.ContainsKey("fort"))
                {
                    Saves["fort"] = new Save();
                }
                if (!Saves.ContainsKey("reflex"))
                {
                    Saves["reflex"] = new Save();
                }
                if (!Saves.ContainsKey("will"))
                {
                    Saves["will"] = new Save();
                }
            }

            void DefaultLoadAbilities()
            {
                // the user didn't fill in the base ability scores for the character at all
                // so just set everything to 0
                Luck             = 0;
                Intellect        = 0;
                Charisma         = 0;
                Strength         = 0;
                Agility          = 0;
                Endurance        = 0;
                Perception       = 0;
                AbilitiesPresent = false;
            }

            void DefaultLoadPotential()
            {
                // the user didn't fill in the potential scores for the character at all
                // so just set everything to 20 (default value)
                PotLuck          = 20;
                PotIntellect     = 20;
                PotCharisma      = 20;
                PotStrength      = 20;
                PotAgility       = 20;
                PotEndurance     = 20;
                PotPerception    = 20;
                PotentialPresent = false;
            }
        }