示例#1
0
        /// <summary>
        /// CSV ancestries are easy to create by users who want to add their
        /// own or control available ancestries via whitelist.
        /// </summary>
        public void LoadCsvAncestries()
        {
            try
            {
                string   fileContents = File.ReadAllText(@"ancestries.csv");
                string[] recordList   = fileContents.Split('\n');
                bool     isFirst      = true;
                foreach (var record in recordList)
                {
                    // Skip header line
                    if (isFirst)
                    {
                        isFirst = false;
                        continue;
                    }
                    // Skip empty lines
                    if (record == "")
                    {
                        continue;
                    }

                    string[] splitRecord = record.Split(',');
                    var      entryList   = new List <string>(splitRecord);
                    var      ancestry    = new Ancestry();

                    _fillStringEntry(entryList, 0, out ancestry.Name);

                    if (entryList.Count() <= 7)
                    {
                        Console.WriteLine("WARN: "
                                          + ancestry.Name + " entry only has "
                                          + entryList.Count() + " members: " + record);
                    }

                    _fillIntEntry(entryList, 1, out ancestry.MinAppearing,
                                  ancestry.Name + " MinAppearing");
                    _fillIntEntry(entryList, 2, out ancestry.MaxAppearing,
                                  ancestry.Name + " MaxAppearing");
                    _fillIntEntry(entryList, 3, out ancestry.BaseAc,
                                  ancestry.Name + " BaseAc");
                    _fillIntEntry(entryList, 4, out ancestry.BaseToHit,
                                  ancestry.Name + " BaseToHit");
                    _fillIntEntry(entryList, 5, out ancestry.BaseNumAttacks,
                                  ancestry.Name + " NumAttacks");
                    _fillIntEntry(entryList, 6, out ancestry.HitDice,
                                  ancestry.Name + " HitDice");
                    _fillIntEntry(entryList, 7, out ancestry.MoraleBonus,
                                  ancestry.Name + " MoraleBonus");

                    _ancestryTable.AddItem(ancestry);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Skipping ancestries.csv");
            }
        }
示例#2
0
        public void InitializeAsRandomPop(int tier)
        {
            var ancestryGen = AncestryIndex.Instance;

            ancestryGen.LoadAllSources();
            BaseAncestry = ancestryGen.GetRandomAncestry(tier);
            Members      = _dice.RandomNumber(BaseAncestry.MinAppearing,
                                              BaseAncestry.MaxAppearing);
            if (Members < 1)
            {
                Members = 1;
            }
            string record = Members + " "
                            + RandomName.Pluralize(BaseAncestry.Name)
                            + " have entered the world.";

            History.addRecord(record);
        }
示例#3
0
        /// <summary>
        /// Old method used in the initial testing. Now ancestries are loaded
        /// from files so you can control what is included in your world.
        /// </summary>
        public void LoadConstantAncestries()
        {
            var nameList = new List <string> {
                "human", "elf", "dwarf", "hobgoblin", "dark elf", "orc"
            };

            foreach (var name in nameList)
            {
                var ancestryObj = new Ancestry();
                ancestryObj.Name           = name;
                ancestryObj.MinAppearing   = 180;
                ancestryObj.MaxAppearing   = 220;
                ancestryObj.BaseAc         = 10;
                ancestryObj.BaseToHit      = 0;
                ancestryObj.BaseNumAttacks = 1;
                ancestryObj.HitDice        = 1;
                ancestryObj.MoraleBonus    = 0;
                _ancestryTable.AddItem(ancestryObj);
            }
        }
示例#4
0
        /// <summary>
        /// Converts a single bestiary monster into an Ancestry object
        /// </summary>
        /// <param name="monster"></param>
        /// <returns></returns>
        public Ancestry AsAncestry(BestiaryMonster monster)
        {
            var ancestry = new Ancestry();

            // Todo: convert ancestries
            ancestry.Name           = monster.name;
            ancestry.BaseAc         = monster.ArmorClass;
            ancestry.BaseToHit      = _calcBaseToHit(monster.action);
            ancestry.BaseNumAttacks = _calcNumAttacks(monster.action);
            ancestry.HitDice        = _parseHitDice(monster.hp);
            ancestry.MoraleBonus    = (int)((monster.Wis - 10) * 0.5);

            float baseAppearing = 200 / ancestry.HitDice;
            float mod           = baseAppearing * 0.15f;
            float fMin          = baseAppearing - mod;
            float fMax          = baseAppearing + mod;

            ancestry.MinAppearing = (int)fMin;
            ancestry.MaxAppearing = (int)fMax;

            return(ancestry);
        }