Exemplo n.º 1
0
        /// <summary>
        /// Parses the yaml.
        /// </summary>
        /// <returns>The yaml.</returns>
        /// <param name="modifierNode">Modifier node.</param>
        /// <param name="source">Source of the modifier.</param>
        public static IList <BasicStatModifier> ParseYaml(YamlNodeWrapper modifierNode, string source)
        {
            IList <BasicStatModifier> modifiers = new List <BasicStatModifier>();

            foreach (var mod in modifierNode.Children())
            {
                var statName  = mod.GetString("stat");
                var amount    = mod.GetInteger("modifier");
                var type      = mod.GetString("type");
                var condition = mod.GetStringOptional("condition");
                BasicStatModifier modifier;

                if (!string.IsNullOrEmpty(condition))
                {
                    modifier = new ConditionalStatModifier(
                        condition,
                        statName,
                        amount,
                        type,
                        source);
                }
                else
                {
                    modifier = new BasicStatModifier(
                        statName,
                        amount,
                        type,
                        source);
                }

                modifiers.Add(modifier);
            }

            return(modifiers);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <returns>The from yaml.</returns>
        /// <param name="yaml">Yaml data to load from.</param>
        private static IList <Class> LoadFromYaml(YamlNodeWrapper yaml)
        {
            var classes = new List <Class>();

            foreach (var node in yaml.Children())
            {
                var cls = new Class();
                cls.Name = node.GetString("name");
                ShortLog.Debug("Loading Class: " + cls.Name);
                cls.SkillPoints         = node.GetInteger("skillpoints");
                cls.HitDice             = DiceStrings.ParseSides(node.GetString("hitdice"));
                cls.BaseAttackBonusRate = node.GetFloat("baseattackbonus");
                cls.FortitudeSaveRate   = node.GetFloat("fortitude");
                cls.ReflexSaveRate      = node.GetFloat("reflex");
                cls.WillSaveRate        = node.GetFloat("will");
                cls.ClassDevelopmentAge = node.GetEnum <ClassDevelopmentAge>("developedage");

                var armor = node.GetCommaStringOptional("armorproficiencies");
                cls.ArmorProficiencies.Add(armor);

                var weapons = node.GetCommaStringOptional("weaponproficiencies");
                cls.WeaponProficiencies.Add(weapons);

                // Get the Skills for this class
                var skills = node.GetNode("skills").Children();
                foreach (var s in skills)
                {
                    cls.AddClassSkill(s.Value);
                }

                classes.Add(cls);
            }

            return(classes);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Loads from yaml.
 /// </summary>
 /// <param name="yaml">Yaml to parse.</param>
 private void LoadFromYaml(YamlNodeWrapper yaml)
 {
     this.languages = new List <Language>();
     foreach (var n in yaml.Children())
     {
         this.languages.Add(new Language(
                                n.GetString("name"),
                                n.GetString("description")));
     }
 }
Exemplo n.º 4
0
 private void ParseYaml(YamlNodeWrapper yaml)
 {
     drawbacks = new WeightedOptionTable <Drawback>();
     foreach (var node in yaml.Children())
     {
         var drawback = new Drawback();
         drawback.Name      = node.GetString("name");
         drawback.Weighting = node.GetInteger("weight");
         drawback.Traits.Add(node.GetCommaStringOptional("traits"));
         drawbacks.AddEntry(drawback, drawback.Weighting);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <param name="yaml">Yaml data to load from</param>
        private void LoadFromYaml(YamlNodeWrapper yaml)
        {
            this.skills = new List <Skill>();

            foreach (var skillNode in yaml.Children())
            {
                var skill = new Skill(
                    skillNode.GetString("name"),
                    AbilityScore.GetType(skillNode.GetString("ability")),
                    skillNode.GetString("trained") == "yes",
                    skillNode.GetString("description"));
                this.skills.Add(skill);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <param name="yaml">Yaml data to parse.</param>
        private void LoadFromYaml(YamlNodeWrapper yaml)
        {
            this.races = new List <Race>();

            foreach (var raceNode in yaml.Children())
            {
                var race = new Race();
                race.Name = raceNode.GetString("name");
                ShortLog.Debug("Loading Race: " + race.Name);
                race.SizeSetting = (CharacterSize)System.Enum.Parse(typeof(CharacterSize), raceNode.GetString("size"));
                race.HeightRange = DiceStrings.ParseDice(raceNode.GetString("height"));
                race.WeightRange = DiceStrings.ParseDice(raceNode.GetString("weight"));

                var abilities = raceNode.GetNode("abilities");
                foreach (var ability in abilities.ChildrenToDictionary())
                {
                    var modifier = new AbilityScoreAdjustment();
                    modifier.Reason   = "Racial Trait";
                    modifier.Modifier = int.Parse(ability.Value);

                    // Special case is races that can choose
                    if (string.Compare(ability.Key, "choose", true) == 0)
                    {
                        modifier.RacialModifier = true;
                    }
                    else
                    {
                        modifier.AbilityName = AbilityScore.GetType(ability.Key);
                    }

                    race.AbilityModifiers.Add(modifier);
                }

                var traits = raceNode.GetNode("traits");
                foreach (var trait in traits.Children())
                {
                    race.Traits.Add(trait.Value);
                }

                var languages = raceNode.GetNode("languages");
                race.KnownLanguages.Add(languages.GetCommaStringOptional("known"));
                race.AvailableLanguages.Add(languages.GetCommaStringOptional("available"));

                // Get Speed
                race.BaseMovementSpeed = raceNode.GetInteger("basemovementspeed");

                this.races.Add(race);
            }
        }
Exemplo n.º 7
0
        private void LoadFromYaml(YamlNodeWrapper yamlData)
        {
            foreach (var node in yamlData.Children())
            {
                var name = new NameInformation();
                name.Gender = node.GetString("gender");
                name.Type   = node.GetEnum <NameTypes>("category");
                name.Race   = node.GetString("race");
                var names = node.GetCommaString("names");

                name.Names.Add(
                    names.Where(x => string.IsNullOrEmpty(x) == false));
                namesDatabase.Add(name);
            }
        }
Exemplo n.º 8
0
 private void ParseYaml(YamlNodeWrapper yaml)
 {
     maturities = new List <Maturity>();
     foreach (var mat_node in yaml.Children())
     {
         var node     = mat_node.GetNode("maturity");
         var maturity = new Maturity();
         maturity.Name      = node.GetString("race");
         maturity.Adulthood = node.GetInteger("adulthood");
         maturity.Young     = DiceStrings.ParseDice(node.GetString("young"));
         maturity.Trained   = DiceStrings.ParseDice(node.GetString("trained"));
         maturity.Studied   = DiceStrings.ParseDice(node.GetString("studied"));
         maturities.Add(maturity);
     }
 }
Exemplo n.º 9
0
 private void ParseYaml(YamlNodeWrapper yaml)
 {
     homelands = new List <Homeland>();
     foreach (var node in yaml.Children())
     {
         var table = node.GetNode("table");
         foreach (var entry in table.Children())
         {
             var homeland = new Homeland();
             homeland.Race      = node.GetString("race");
             homeland.Location  = entry.GetString("location");
             homeland.Weighting = entry.GetInteger("weight");
             homeland.Traits.Add(entry.GetCommaStringOptional("traits"));
             homelands.Add(homeland);
         }
     }
 }
Exemplo n.º 10
0
 private void ParseYaml(YamlNodeWrapper yaml)
 {
     classOrigins = new List <ClassOrigin>();
     foreach (var classNode in yaml.Children())
     {
         var table = classNode.GetNode("table");
         foreach (var entry in table.Children())
         {
             var origin = new ClassOrigin();
             origin.Class     = classNode.GetString("class");
             origin.Name      = entry.GetString("name");
             origin.Weighting = entry.GetInteger("weight");
             origin.Traits.Add(entry.GetCommaStringOptional("traits"));
             origin.Storylines.Add(entry.GetCommaStringOptional("storylines"));
             classOrigins.Add(origin);
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <param name="yaml">Yaml to parse.</param>
        private void LoadFromYaml(YamlNodeWrapper yaml)
        {
            this.armors = new List <Armor>();

            foreach (var node in yaml.Children())
            {
                ShortLog.DebugFormat("Loading Armor: {0}", node.GetString("name"));
                var armor = new Armor(
                    node.GetString("name"),
                    node.GetInteger("armor_class"),
                    node.GetFloat("weight"),
                    node.GetInteger("maximum_dexterity_bonus"),
                    node.GetInteger("armor_check_penalty"),
                    node.GetInteger("arcane_spell_failure_chance"),
                    node.GetEnum <ArmorType>("armor_type"));

                this.armors.Add(armor);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Loads all the feats from a YAML node.
        /// </summary>
        /// <returns>The feats stored in the YAML document.</returns>
        /// <param name="yaml">YAML to parse out.</param>
        public static IList <Feat> LoadFromYaml(YamlNodeWrapper yaml)
        {
            // TODO: Refactor to Gateway class
            var feats = new List <Feat>();

            foreach (var featNode in yaml.Children())
            {
                var feat = new Feat();
                feat.Name = featNode.GetString("name");
                ShortLog.DebugFormat("Loading Feat: {0}", feat.Name);
                feat.Description = featNode.GetString("description");

                // Get Any skill Modifiers if they exist
                var skills = featNode.GetNodeOptional("modifiers");
                if (skills != null)
                {
                    foreach (var skillAdj in skills.Children())
                    {
                        var skillName = skillAdj.GetString("stat");
                        var modifier  = skillAdj.GetInteger("modifier");
                        var type      = skillAdj.GetString("type");
                        feat.Modifiers.Add(new BasicStatModifier(
                                               skillName,
                                               modifier,
                                               type,
                                               string.Format("{0} (feat)", feat.Name)));
                    }
                }

                // Get Any Prerequisites
                var prereq = featNode.GetNodeOptional("prerequisites");
                if (prereq != null)
                {
                    feat.Prerequisites = new Prerequisites(prereq);
                }

                feat.Tags = featNode.GetCommaStringOptional("tags").ToList();
                feats.Add(feat);
            }

            return(feats);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <param name="yaml">Yaml data to load.</param>
        private void LoadFromYaml(YamlNodeWrapper yaml)
        {
            this.weapons = new List <Weapon>();

            foreach (var node in yaml.Children())
            {
                ShortLog.DebugFormat("Loading Weapon: {0}", node.GetString("name"));
                var w = new Weapon(
                    node.GetString("name"),
                    node.GetFloat("weight"),
                    node.GetString("damage"),
                    node.GetEnum <DamageTypes>("damage_type"),
                    node.GetIntegerOptional("critical_threat"),
                    node.GetIntegerOptional("critical_modifier"),
                    node.GetIntegerOptional("range"),
                    node.GetEnum <WeaponType>("type"),
                    node.GetEnum <WeaponGroup>("group"),
                    node.GetEnum <WeaponTrainingLevel>("training_level"));
                this.weapons.Add(w);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Loads from yaml.
        /// </summary>
        /// <param name="yaml">Yaml node to load from</param>
        private void LoadFromYaml(YamlNodeWrapper yaml)
        {
            this.traits = new List <Trait>();

            foreach (var traitNode in yaml.Children())
            {
                var trait = new Trait();
                trait.Name = traitNode.GetString("name");
                ShortLog.Debug("Loading Trait: " + trait.Name);
                trait.Description = traitNode.GetString("description");
                trait.Tags.Add(traitNode.GetCommaStringOptional("tags"));

                // Get Any skill Modifiers if they exist
                var modifiers = traitNode.GetNodeOptional("modifiers");
                if (modifiers != null)
                {
                    var mods = ParseStatModifiersYaml.ParseYaml(modifiers, string.Format("{0} (trait)", trait.Name));
                    foreach (var m in mods)
                    {
                        trait.Modifiers.Add(m);
                    }
                }

                // Get any special abilities
                var abilities = traitNode.GetNodeOptional("special");
                if (abilities != null)
                {
                    foreach (var spec in abilities.Children())
                    {
                        var specialAbility = new SpecialAbility(
                            spec.GetString("condition"),
                            spec.GetString("type"));
                        trait.SpecialAbilities.Add(specialAbility);
                    }
                }

                this.traits.Add(trait);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Characters.Gateways.LanguageYamlGateway"/> class.
 /// </summary>
 /// <param name="yaml">Yaml node to parse for languages</param>
 public LanguageYamlGateway(YamlNodeWrapper yaml)
 {
     this.LoadFromYaml(yaml);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Equipment.Gateways.WeaponYamlGateway"/> class.
 /// </summary>
 /// <param name="yamlData">Yaml data.</param>
 public WeaponYamlGateway(YamlNodeWrapper yamlData)
 {
     this.LoadFromYaml(yamlData);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Characters.Prerequisites"/> class.
 /// </summary>
 /// <param name="yaml">Yaml node wrapper to parse requisites from.</param>
 public Prerequisites(YamlNodeWrapper yaml)
 {
     this.ParseYaml(yaml);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Parses the yaml and find prerequisites
        /// </summary>
        /// <param name="yaml">Yaml Node to parse </param>
        private void ParseYaml(YamlNodeWrapper yaml)
        {
            foreach (var prereq in yaml.Children())
            {
                Prerequisite newreq = null;

                // TODO: This seems clunky and weird
                foreach (var key in this.prerequisiteKeyNames)
                {
                    var val = prereq.GetStringOptional(key);
                    if (val != null)
                    {
                        switch (key)
                        {
                        case "ability":
                            newreq = new AbilityPrerequisite(val);
                            break;

                        case "baseattackbonus":
                            newreq = new BaseAttackBonusPrerequisite(val);
                            break;

                        case "casterlevel":
                            newreq = new CasterLevelPrerequisite(val);
                            break;

                        case "classfeature":
                            newreq = new ClassFeaturePrerequisite(val);
                            break;

                        case "classlevel":
                            newreq = new ClassLevelPrerequisite(val);
                            break;

                        case "feat":
                            newreq = new FeatPrerequisite(val);
                            break;

                        case "proficiency":
                            newreq = new ProficiencyPrerequisite(val);
                            break;

                        case "race":
                            newreq = new RacePrerequisite(val);
                            break;

                        case "skillranks":
                            newreq = new SkillRankPrerequisite(val);
                            break;
                        }

                        break;
                    }
                }

                if (newreq != null)
                {
                    this.Add(newreq);
                }
            }
        }
Exemplo n.º 19
0
 public DrawbackYamlGateway(YamlNodeWrapper yamlNode)
 {
     ParseYaml(yamlNode);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Characters.Gateways.ClassYamlGateway"/> class.
 /// </summary>
 /// <param name="yaml">Yaml data.</param>
 public ClassYamlGateway(YamlNodeWrapper yaml)
 {
     this.classes = LoadFromYaml(yaml);
 }
Exemplo n.º 21
0
 public RaceMaturityYamlGateway(YamlNodeWrapper yaml)
 {
     ParseYaml(yaml);
 }
Exemplo n.º 22
0
 public CharacterNamesYamlGateway(YamlNodeWrapper yamlData)
 {
     namesDatabase = new List <NameInformation>();
     LoadFromYaml(yamlData);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Characters.Gateways.SkillYamlGateway"/> class.
 /// </summary>
 /// <param name="yaml">Yaml data to parse.</param>
 public SkillYamlGateway(YamlNodeWrapper yaml)
 {
     this.LoadFromYaml(yaml);
 }
Exemplo n.º 24
0
 public HomelandYamlGateway(YamlNodeWrapper yaml)
 {
     ParseYaml(yaml);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Equipment.Gateways.ArmorYamlGateway"/> class.
 /// </summary>
 /// <param name="yaml">Yaml to parse</param>
 public ArmorYamlGateway(YamlNodeWrapper yaml)
 {
     this.LoadFromYaml(yaml);
 }
Exemplo n.º 26
0
 public ClassOriginYamlGateway(YamlNodeWrapper yaml)
 {
     ParseYaml(yaml);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SilverNeedle.Characters.Gateways.TraitYamlGateway"/> class.
 /// </summary>
 /// <param name="yaml">Yaml to parse.</param>
 public TraitYamlGateway(YamlNodeWrapper yaml)
 {
     this.LoadFromYaml(yaml);
 }