public void BaseScoreTen_Aggregates()
        {
            // Arrange
            AbilityScore abilityScore = new AbilityScore();

            abilityScore.BaseScore = 10;

            // Assert
            Assert.IsTrue(abilityScore.GetTotal().HasValue,
                          "Ability scores with a non-null base score should always have a total.");
            Assert.AreEqual(10, abilityScore.GetTotal().Value,
                            "Ability scores with non-null base bases should have a total equal to their base score by default.");
            Assert.AreEqual(0, abilityScore.GetModifier(),
                            "Modifier for ability score 10 is 0.");
            Assert.AreEqual(0, abilityScore.GetBonus(),
                            "Bonuses for ability scores below 12 are always zero.");
        }
Ejemplo n.º 2
0
        /// <exception cref="System.ArgumentNullException">Thrown when an argument is null.</exception>
        public void ApplyTo(ICharacter character)
        {
            if (null == character)
            {
                throw new ArgumentNullException(nameof(character), "Argument may not be null.");
            }
            var spell       = EtherealJaunt.SorcererVersion;
            var castingStat = new AbilityScore()
            {
                BaseScore = Convert.ToByte(10 + spell.Level)
            };
            var sla = new SpellLikeAbility(usesPerDay: 1,
                                           spell: spell,
                                           keyAbilityScore: castingStat,
                                           baseCasterLevel: () => this.CasterLevel);

            character.SpellLikeAbilities?.Known?.Add(sla);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Applies the effects of Hand of the Mage to an ICharacter.
        /// </summary>
        /// <param name="character">The character to apply effects to.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when an argument is null.</exception>
        public void ApplyTo(ICharacter character)
        {
            if (null == character)
            {
                throw new ArgumentNullException(nameof(character), "Argument cannot be null.");
            }
            // Do not register the spell-like ability--we don't want feats applying to it.
            var           spell = MageHand.SorcererVersion;
            IAbilityScore handOfTheMageCastingStat = new AbilityScore {
                BaseScore = Convert.ToByte(10 + spell.Level)
            };
            ISpellLikeAbility mageHandSpellLikeAbility = new SpellLikeAbility(usesPerDay:      0,
                                                                              spell:           spell,
                                                                              keyAbilityScore: handOfTheMageCastingStat,
                                                                              baseCasterLevel: () => this.GetCasterLevel().Value);

            character.SpellLikeAbilities?.Known?.Add(mageHandSpellLikeAbility);
        }
        public string constructSkillString()
        {
            string        output         = "";
            List <Skill>  skills         = DBManager.SkillData.getSkills();
            List <string> allKnownSkills = Choices.AllKnownSkills;

            foreach (Skill skill in skills)
            {
                string       currentSkill        = HTMLRadioButton.Replace("@name@", skill.Name);
                AbilityScore currentSkillAbility = Choices.Abilities.FirstOrDefault(ability => ability.Name == skill.Ability);
                string       buttonLabel         = $"{skill.Name} ({skill.Ability.Substring(0, 3)})";

                if (allKnownSkills.Contains(skill.Name))
                {
                    int proficientModifier = 0;

                    if ((Choices.ClassChoice.ExtraSkills.Contains(skill.Name)) && Choices.ClassChoice.DoublesProficiency)
                    {
                        proficientModifier = currentSkillAbility.getModifier() + (ProficiencyBonus * 2);
                    }
                    else if ((Choices.ClassChoice.getSelectedSubclass().ExtraSkills.Contains(skill.Name)) && Choices.ClassChoice.getSelectedSubclass().DoublesProficiency)
                    {
                        proficientModifier = currentSkillAbility.getModifier() + (ProficiencyBonus * 2);
                    }
                    else
                    {
                        proficientModifier = currentSkillAbility.getModifier() + ProficiencyBonus;
                    }

                    currentSkill = currentSkill.Replace("@text@", $"{proficientModifier.ToString("+#;-#;+0")} {buttonLabel}");
                    currentSkill = currentSkill.Replace("@checked@", HTMLRadioButtonChecked);
                }
                else
                {
                    currentSkill = currentSkill.Replace("@text@", $"{currentSkillAbility.getModifier().ToString("+#;-#;+0")} {buttonLabel}");
                    currentSkill = currentSkill.Replace("@checked@", "");
                }

                output += currentSkill;
            }

            return(output);
        }
        public int calculateAC()
        {
            int armoredAC   = 0;
            int unarmoredAC = 10;

            //calculate armored AC
            List <Armor> ownedArmor = getOwnedArmor();

            if (ownedArmor.Count > 0)
            {
                Armor bodyArmor = ownedArmor.FirstOrDefault(armor => armor.AC > 0);
                if (bodyArmor != null)
                {
                    int armorModifier = 0;

                    AbilityScore armorModifierAbility = Choices.Abilities.FirstOrDefault(ability => ability.Name == bodyArmor.AdditionalModifier);
                    if (armorModifierAbility != null)
                    {
                        armorModifier = armorModifierAbility.getModifier();
                    }

                    if (bodyArmor.AdditionalModifierLimit > 0)
                    {
                        if (armorModifier > bodyArmor.AdditionalModifierLimit)
                        {
                            armorModifier = bodyArmor.AdditionalModifierLimit;
                        }
                    }
                    armoredAC = bodyArmor.AC + armorModifier;
                }
            }

            //calculate unarmored AC
            List <string> unarmoredAbilities = DBManager.ExportData.getUnarmoredDefenseAbilities(Choices.ClassChoice.Name);

            foreach (string ability in unarmoredAbilities)
            {
                AbilityScore unarmoredModifierAbility = Choices.Abilities.FirstOrDefault(score => score.Name == ability);
                unarmoredAC += unarmoredModifierAbility.getModifier();
            }

            return(Math.Max(armoredAC, unarmoredAC));
        }
Ejemplo n.º 6
0
 private void CalculateAbilityScores(List <AbilityScoreBoostFlaw> boostsAndFlaws)
 {
     Strength     = new AbilityScore(10, Ability.Strength);
     Dexterity    = new AbilityScore(10, Ability.Dexterity);
     Constitution = new AbilityScore(10, Ability.Constitution);
     Intelligence = new AbilityScore(10, Ability.Intelligence);
     Wisdom       = new AbilityScore(10, Ability.Wisdom);
     Charisma     = new AbilityScore(10, Ability.Charisma);
     foreach (var boostFlaw in boostsAndFlaws)
     {
         foreach (var property in propertiesOfThisClass)
         {
             if (property.Name == "FreeBoostsAvailable")
             {
                 continue;
             }
             if (boostFlaw.Ability == Ability.Free.ToString())
             {
                 continue;
             }
             if (boostFlaw.Ability == property.Name)
             {
                 AbilityScore newAbilityScore;
                 AbilityScore abilityScore = property.GetValue(this) as AbilityScore;
                 if (boostFlaw.IsBoost)
                 {
                     newAbilityScore = new AbilityScore(abilityScore.Score + 2, abilityScore.Ability);
                 }
                 else
                 {
                     newAbilityScore = new AbilityScore(abilityScore.Score - 2, abilityScore.Ability);
                 }
                 property.SetValue(this, newAbilityScore);
             }
         }
         if (boostFlaw.Ability == "Free")
         {
             FreeBoostsAvailable++;
         }
     }
 }
Ejemplo n.º 7
0
        public void changeStat(AbilityScore name, int newValue)
        {
            AbilityScores[(int)name] = newValue;

            SkillBonuses[(int)SkillBonus.Athletics] = AbilityScores[(int)AbilityScore.Strength];

            for (int i = (int)SkillBonus.Acrobatics; i < (int)SkillBonus.Arcana; i++)
            {
                SkillBonuses[i] = (AbilityScores[(int)AbilityScore.Dexterity] - 10) / 2;
                if (SkillProficiencies[i])
                {
                    SkillBonuses[i] += getProficiency();
                }
            }
            for (int i = (int)SkillBonus.Arcana; i < (int)SkillBonus.AnimalHandling; i++)
            {
                SkillBonuses[i] = (AbilityScores[(int)AbilityScore.Intelligence] - 10) / 2;
                if (SkillProficiencies[i])
                {
                    SkillBonuses[i] += getProficiency();
                }
            }
            for (int i = (int)SkillBonus.AnimalHandling; i < (int)SkillBonus.Survival; i++)
            {
                SkillBonuses[i] = (AbilityScores[(int)AbilityScore.Wisdom] - 10) / 2;
                if (SkillProficiencies[i])
                {
                    SkillBonuses[i] += getProficiency();
                }
            }
            for (int i = (int)SkillBonus.Survival; i <= (int)SkillBonus.Persuasion; i++)
            {
                SkillBonuses[i] = (AbilityScores[(int)AbilityScore.Charisma] - 10) / 2;
                if (SkillProficiencies[i])
                {
                    SkillBonuses[i] += getProficiency();
                }
            }

            SkillBonuses = SkillBonuses;
        }
        public void BigPenalties_Aggregates()
        {
            // Arrange
            AbilityScore abilityScore = new AbilityScore();

            abilityScore.BaseScore = 1;
            abilityScore.Penalties.Add(() => 6);

            // Act
            byte?total = abilityScore.GetTotal();

            // Assert
            Assert.IsTrue(total.HasValue,
                          "An ability score with a non-null base score should have a non-null total.");
            Assert.AreEqual(0, total.Value,
                            "A negative total ability score should be reported as though it was zero.");
            Assert.AreEqual(-5, abilityScore.GetModifier(),
                            "An ability score of 0 should have a -5 modifier.");
            Assert.AreEqual(0, abilityScore.GetBonus(),
                            "An ability score of less than 12 should have a bonus of zero.");
        }
        public void TypicalPenalties_Aggregates()
        {
            // Arrange
            AbilityScore abilityScore = new AbilityScore();

            abilityScore.BaseScore = 10;
            abilityScore.Penalties.Add(() => 6);

            // Act
            byte?total = abilityScore.GetTotal();

            // Assert
            Assert.IsTrue(total.HasValue,
                          "An ability score with a non-null base score should have a non-null total.");
            Assert.AreEqual(4, total.Value,
                            "An ability score of 10 with a penalty of -6 should have a total of 4.");
            Assert.AreEqual(-3, abilityScore.GetModifier(),
                            "An ability score of 4 should have a -3 modifier.");
            Assert.AreEqual(0, abilityScore.GetBonus(),
                            "An ability score of less than 12 should have a bonus of zero.");
        }
Ejemplo n.º 10
0
        public void MoraleBonuses_Aggregates()
        {
            // Arrange
            AbilityScore abilityScore = new AbilityScore();

            abilityScore.BaseScore = 10;
            abilityScore.MoraleBonuses.Add(() => 6);

            // Act
            byte?total = abilityScore.GetTotal();

            // Assert
            Assert.IsTrue(total.HasValue,
                          "An ability score with a non-null base score should have a non-null total.");
            Assert.AreEqual(16, total.Value,
                            "An ability score of 10 with a morale bonus of +6 should have a total of 16.");
            Assert.AreEqual(3, abilityScore.GetModifier(),
                            "An ability score of 16 should have a +3 modifier.");
            Assert.AreEqual(3, abilityScore.GetBonus(),
                            "An ability score of 16 should have a +3 bonus.");
        }
Ejemplo n.º 11
0
        public void ApplyTo(ICharacter character)
        {
            if (null == character)
            {
                throw new ArgumentNullException(nameof(character), "Argument cannot be null.");
            }

            // Once per day, the shield can cast Spell Turning.
            // Since it is not specified which version of the spell to use, here we assume it is the sorcerer version.
            // We don't want the SLA registered, since we don't want feats applying to it.
            ISpell        spell = SpellTurning.SorcererVersion;
            IAbilityScore enchantmentCastingStat = new AbilityScore {
                BaseScore = Convert.ToByte(10 + spell.Level)
            };
            ISpellLikeAbility sla = new SpellLikeAbility(usesPerDay:      1,
                                                         spell:           spell,
                                                         keyAbilityScore: enchantmentCastingStat,
                                                         baseCasterLevel: () => this.CasterLevel);

            character.SpellLikeAbilities?.Known?.Add(sla);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Applies Winged Shield's effects to an ICharacter.
        /// </summary>
        /// <param name="character">The character to apply effects to.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when an argument is null.</exception>
        public void ApplyTo(ICharacter character)
        {
            if (null == character)
            {
                throw new ArgumentNullException(nameof(character), "Argument may not be null.");
            }
            character.ArmorClass?.ShieldBonuses?.Add(() => this.GetShieldBonus());
            foreach (var skill in character.Skills?.GetAllSkills() ?? Enumerable.Empty <ISkill>())
            {
                skill.Penalties?.Add(() => skill.ArmorCheckPenaltyApplies ? this.GetArmorCheckPenalty() : (byte)0);
            }
            // Do not register the spell-like ability--we don't want feats applying to it.
            var           flySpell          = Spells.Paizo.CoreRulebook.Fly.WizardVersion;
            IAbilityScore shieldCastingStat = new AbilityScore {
                BaseScore = Convert.ToByte(10 + flySpell.Level)
            };
            ISpellLikeAbility flySpellLikeAbility = new SpellLikeAbility(usesPerDay:      1,
                                                                         spell:           flySpell,
                                                                         keyAbilityScore: shieldCastingStat,
                                                                         baseCasterLevel: () => this.GetCasterLevel().Value);

            character?.SpellLikeAbilities?.Known?.Add(flySpellLikeAbility);
        }
Ejemplo n.º 13
0
        public void Initialize(ComponentContainer components)
        {
            this.charisma         = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
            this.strength         = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Strength);
            this.size             = components.Get <SizeStats>();
            this.CriticalModifier = new BasicStat("Claws Critical Modifier", 2);

            var offense = components.Get <OffenseStats>();

            this.AttackBonus = new BasicStat("Claw Attack Bonus");
            this.AttackBonus.AddModifier(new StatisticStatModifier(this.AttackBonus.Name, offense.MeleeAttackBonus));
            this.sorcererLevel = components.Get <ClassLevel>();

            if (components.Contains <IDraconicBloodline>())
            {
                var bloodline = components.Get <IDraconicBloodline>();
                BonusDamageType = bloodline.DragonType.EnergyType;
            }
            else
            {
                BonusDamageType = "fire";
            }
        }
Ejemplo n.º 14
0
        public bool SavingThrow(AbilityScore score, int dc, AbilityRoll rollType = AbilityRoll.Normal)
        {
            if (Abilities.ContainsKey(score))
            {
                int roll = Dice.MakeAbilityRoll(rollType) + Abilities[score].Save;
                if (HasBless)
                {
                    roll += Dice.D4();
                }

                if (ActiveEffect != null)
                {
                    if (ActiveEffect.Type == SpellEffectType.SynapticStatic)
                    {
                        roll -= Dice.D6();
                    }
                }

                return(roll >= dc);
            }

            return(false);
        }
Ejemplo n.º 15
0
        public ChoiceManager()
        {
            Preset = 0;
            Level  = 1;
            AdjustStartingMoney = true;

            RaceChoice = new Race();

            LawAlignment      = "";
            MoralityAlignment = "";

            Age = 1;

            HeightModifier = 0;
            WeightModifier = 0;
            Height         = "";
            Weight         = "";

            EyeColor  = "";
            SkinColor = "";
            HairColor = "";

            ClassChoice = new CharacterClass();

            BackgroundChoice = new Background();

            Strength     = new AbilityScore("Strength");
            Dexterity    = new AbilityScore("Dexterity");
            Constitution = new AbilityScore("Constitution");
            Intelligence = new AbilityScore("Intelligence");
            Wisdom       = new AbilityScore("Wisdom");
            Charisma     = new AbilityScore("Charisma");
            Abilities    = new List <AbilityScore>(new AbilityScore[] { Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma });
            HP           = 0;

            Languages = new List <string>();

            Skills      = new List <string>();
            ExtraSkills = new List <string>();

            Equipment1     = new List <EquipmentItem>();
            Equipment2     = new List <EquipmentItem>();
            Equipment3     = new List <EquipmentItem>();
            Equipment4     = new List <EquipmentItem>();
            ExtraEquipment = "";

            Spells = new List <Spell>();

            RaceSpells = new List <Spell>();

            CharacterName = "";
            PlayerName    = "";
            IsMale        = false;

            Trait         = "";
            Ideal         = "";
            Bond          = "";
            Flaw          = "";
            CustomTrait   = false;
            CustomIdeal   = false;
            CustomBond    = false;
            CustomFlaw    = false;
            TerrainChoice = new WildShapeTerrain();
            Backstory     = "";

            allKnownSkills  = new List <string>();
            chosenEquipment = new List <EquipmentItem>();
        }
Ejemplo n.º 16
0
 public void Initialize(ComponentContainer components)
 {
     sorcererLevels = components.Get <ClassLevel>();
     elementalType  = components.Get <ElementalType>();
     charisma       = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
 }
Ejemplo n.º 17
0
 public int MakeAbilityCheck(Character character, Ability ability)
 {
     return(d20.Roll() + AbilityScore.CalculateAbilityScore(character, ability));
 }
Ejemplo n.º 18
0
        public IActionResult Statblock()
        {
            var creature = Creature.Create("Thomas the Tank Engine", Size.Medium, ChallengeRating.Create(5), AbilityScore.CreateStandard(16, 9, 13, 1, 3, 25), 10);

            creature.Type = CreatureType.Construct;

            creature.ArmorClass = new ArmorClass(18, "Natural Armor");

            creature.Speeds = new List <Speed>()
            {
                new Speed(MovementMode.Walk, 60), new Speed(MovementMode.Swim, 120), new Speed(MovementMode.Burrow, 75)
            };

            creature.DamageImmunities = new List <DamageType>()
            {
                DamageType.Fire, DamageType.Lightning, DamageType.Acid
            };
            creature.ConditionImmunities = new List <Condition>()
            {
                Condition.Blinded, Condition.Deafened, Condition.Prone
            };

            var ramAttack = new Models.Action {
                Name = "Ram"
            };

            ramAttack.RulesText = new RulesText()
            {
                Text = "Melee weapon attack. {attack:str+p} to hit {dmg:2d8+str} {type:bludgeoning} damage"
            };
            creature.Actions.Add(ramAttack);

            var chooChooAttack = new Models.Action()
            {
                Name = "Choo Choo"
            };

            chooChooAttack.RulesText = new RulesText()
            {
                Text = "Thomas does a big ol choo-choo thing. every targer in a 30 foot cone centered on him takes {dmg:2d8+str} {type:bludgeoning} damage and {dmg:1d8} {type:fire} damage"
            };
            creature.Actions.Add(chooChooAttack);

            creature.Actions.Add(new Models.Action()
            {
                Name = "Steam Whistle", Recharge = "Recharge 5-6", RulesText = new RulesText()
                {
                    Text = "Thomas blows hot steam in a 60-foot sphere centered on Thomas. Each creature in that area other than Thomas must make a DC 18 Dexterity saving throw, taking 35 (10d6) fire damage on a failed save, or half as much damage on a successful one."
                }
            });

            creature.Features.Add(new Feature()
            {
                Name = "Antimagic Susceptibility", Description = "Thomas is incapacitated while in the area of an anitmagic-field. If targeted by dispel magic, Thomas must suceed on a Constitution saving throw agains that caster's spell save DC or fall unconscious for 1 minute"
            });
            creature.Features.Add(new Feature()
            {
                Name = "False Appearance", Description = "While Thomas remains motionless, it is indistinguishable from a normal tank engine."
            });

            creature.Senses.Add(new Sense(SenseType.Truesight, 60));
            creature.Senses.Add(new Sense(SenseType.Tremorsense, 120));

            creature.Languages.Add(Language.Abyssal);
            creature.Languages.Add(Language.Celestial);
            creature.Languages.Add(Language.DeepSpeech);

            return(View("StatBlockView", new List <ViewModels.CreatureViewModel>()
            {
                new ViewModels.CreatureViewModel(creature)
            }));
        }
Ejemplo n.º 19
0
 public void Initialize(ComponentContainer components)
 {
     charisma = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
 }
Ejemplo n.º 20
0
 private int ApplyBonus(int roll, Character character, SkillType skillType)
 {
     return(roll + AbilityScore.CalculateAbilityScore(character, skillType));
 }
Ejemplo n.º 21
0
 public int this[AbilityScore score]
 {
     get {
         return this.stats[score.ToString()];
     }
 }
Ejemplo n.º 22
0
 public void Initialize(ComponentContainer components)
 {
     this.charisma       = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
     this.sorcererLevels = components.Get <ClassLevel>();
 }
Ejemplo n.º 23
0
 public decimal GetCurrentAbilityScore(AbilityScore score) => baseAbilityScores[score] * abilityScoreMultipliers[score];
Ejemplo n.º 24
0
 public void Initialize(ComponentContainer components)
 {
     clericLevel     = components.Get <ClassLevel>();
     wisdom          = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Wisdom);
     this.DamageType = "electricity";
 }
Ejemplo n.º 25
0
 public decimal SetAbilityScoreMultiplier(AbilityScore score, decimal scoreValue) => abilityScoreMultipliers[score] = scoreValue;
Ejemplo n.º 26
0
 public decimal GetAbilityScoreMultiplier(AbilityScore score) => abilityScoreMultipliers[score];
Ejemplo n.º 27
0
 public decimal GetBaseAbilityScore(AbilityScore score) => baseAbilityScores[score];
Ejemplo n.º 28
0
        public void TotalScoreIsTheSumOfAllModifiers()
        {
            var score = new AbilityScore(AbilityScoreTypes.Strength, 15);

            Assert.Equal(15, score.TotalValue);
        }
Ejemplo n.º 29
0
 public void Initialize(ComponentContainer components)
 {
     source      = components.Get <ClassLevel>();
     baseAbility = components.Get <AbilityScores>().GetAbility(baseAbilityType);
 }
Ejemplo n.º 30
0
        public IActionResult CharacterSheet(IFormFile file)
        {
            Character     character         = new Character();
            List <string> Elements          = new List <string>();
            List <string> ElementExceptions = new List <string>();

            ElementExceptions.Add("character");
            ElementExceptions.Add("adventurelist");
            ElementExceptions.Add("temp");

            //Remove From Exceptions when we can.
            //ElementExceptions.Add("backgroundlink"); //Todo Need to store this but not sure where yet.
            ElementExceptions.Add("featlist");
            //ElementExceptions.Add("powermode");
            ElementExceptions.Add("powers");
            //ElementExceptions.Add("racelink");
            //ElementExceptions.Add("token");


            StringBuilder errorLog = new StringBuilder();

            var result = new StringBuilder();
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Parse;
            using (var stream = new StreamReader(file.OpenReadStream()))
            {
                XmlReader reader = XmlReader.Create(stream, settings);

                reader.MoveToContent();

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (!ElementExceptions.Contains(reader.Name.ToLower()))
                        {
                            Elements.Add(reader.Name);
                        }

                        break;

                    case XmlNodeType.Text:
                        Console.Write(reader.Value);
                        if (Elements[0].ToLower() == "abilities")
                        {
                            //Grab the ability we are currently working with based of the Elements
                            var currentAbility = character.AbilityScores.FirstOrDefault(x => x.Name.ToString().ToLower() == Elements[1].Substring(0, 3).ToLower());

                            //If the ability does not exisit yet (ie the first attribute of the ability) set it up
                            if (currentAbility == null)
                            {
                                currentAbility = new AbilityScore();
                                if (Elements[1].ToLower() == "charisma")
                                {
                                    currentAbility.Name = AbilityNames.Cha;
                                }
                                else if (Elements[1] == "constitution")
                                {
                                    currentAbility.Name = AbilityNames.Con;
                                }
                                else if (Elements[1] == "dexterity")
                                {
                                    currentAbility.Name = AbilityNames.Dex;
                                }
                                else if (Elements[1] == "intelligence")
                                {
                                    currentAbility.Name = AbilityNames.Int;
                                }
                                else if (Elements[1] == "strength")
                                {
                                    currentAbility.Name = AbilityNames.Str;
                                }
                                else if (Elements[1] == "wisdom")
                                {
                                    currentAbility.Name = AbilityNames.Wis;
                                }
                                else
                                {
                                    currentAbility.Name = AbilityNames.Custom; currentAbility.CustomName = Elements[1];
                                }

                                character.AbilityScores.Add(currentAbility);
                            }

                            //Set the property of the abilit score based of the name of the 3rd Element.
                            if (Elements[2].ToLower() == "bonus")
                            {
                                currentAbility.Bonus = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "save")
                            {
                                currentAbility.Save = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "savemodifier")
                            {
                                currentAbility.SaveMod = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "saveprof")
                            {
                                currentAbility.SaveProf = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "score")
                            {
                                currentAbility.Value = Convert.ToInt32(reader.Value);
                            }
                            else
                            {
                                errorLog.AppendLine("Not expecting Element " + Elements[0] + " >> " + Elements[1] + " >> " + Elements[2]);
                            }
                        }
                        else if (Elements[0].ToLower() == "alignment")
                        {
                            if (reader.Value.ToLower() == "lawful good")
                            {
                                character.Details.Alignment = Alignment.LawfulGood;
                            }
                            if (reader.Value.ToLower() == "lawful neutral")
                            {
                                character.Details.Alignment = Alignment.LawfulNeutral;
                            }
                            if (reader.Value.ToLower() == "lawful evil")
                            {
                                character.Details.Alignment = Alignment.LawfulEvil;
                            }
                            if (reader.Value.ToLower() == "neutral good")
                            {
                                character.Details.Alignment = Alignment.NeutralGood;
                            }
                            if (reader.Value.ToLower() == "true neutral")
                            {
                                character.Details.Alignment = Alignment.TrueNeutral;
                            }
                            if (reader.Value.ToLower() == "neutral evil")
                            {
                                character.Details.Alignment = Alignment.NeutralEvil;
                            }
                            if (reader.Value.ToLower() == "chaotic good")
                            {
                                character.Details.Alignment = Alignment.ChaoticGood;
                            }
                            if (reader.Value.ToLower() == "chaotic neutral")
                            {
                                character.Details.Alignment = Alignment.ChaoticNeutral;
                            }
                            if (reader.Value.ToLower() == "chaitic evil")
                            {
                                character.Details.Alignment = Alignment.ChaiticEvil;
                            }
                        }
                        else if (Elements[0].ToLower() == "appearance")
                        {
                            character.Details.Appearance = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "background")
                        {
                            character.Details.Background = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "personalitytraits")
                        {
                            character.Peronality.Traits = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "bonds")
                        {
                            character.Peronality.Bonds = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "flaws")
                        {
                            character.Peronality.Flaws = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "ideals")
                        {
                            character.Peronality.Ideals = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "exp")
                        {
                            character.Details.ExperincePoints = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "expneeded")
                        {
                            character.Details.ExperincePointsNeeded = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "expneeded")
                        {
                            character.Details.ExperincePointsNeeded = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "level")
                        {
                            character.Details.CharacterLevel = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "name")
                        {
                            character.Name = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "perception")
                        {
                            character.Details.Perception = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "perceptionmodifier")
                        {
                            character.Details.PerceptionMod = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "profbonus")
                        {
                            character.Details.ProficencyBonus = Convert.ToInt32(reader.Value);
                        }
                        else if (Elements[0].ToLower() == "race")
                        {
                            character.Race = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "senses")
                        {
                            character.Details.Senses = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "size")
                        {
                            character.Details.Size = reader.Value;
                        }
                        else if (Elements[0].ToLower() == "skilllist")
                        {
                            var currentSkill = character.Skills.FirstOrDefault(x => x.SourceId.ToLower() == Elements[1].ToLower());

                            //If the ability does not exisit yet (ie the first attribute of the ability) set it up
                            if (currentSkill == null)
                            {
                                currentSkill          = new Skill();
                                currentSkill.SourceId = Elements[1];
                                character.Skills.Add(currentSkill);
                            }

                            if (Elements[2] == "misc")
                            {
                                currentSkill.MiscBonus = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "name")
                            {
                                currentSkill.Name = reader.Value;
                            }
                            else if (Elements[2] == "prof")
                            {
                                currentSkill.ProfBonus = Convert.ToInt32(reader.Value);
                            }
                            else if (Elements[2] == "stat")
                            {
                                var abilityScore = character.AbilityScores.FirstOrDefault(x => x.Name.ToString().ToLower() == reader.Value.Substring(0, 3).ToLower());
                                if (abilityScore != null)
                                {
                                    currentSkill.Ability = abilityScore;
                                }
                            }
                            else if (Elements[2] == "total")
                            {
                                currentSkill.Value = Convert.ToInt32(reader.Value);
                            }
                        }
                        break;

                    case XmlNodeType.CDATA:
                        Console.Write("<![CDATA[{0}]]>", reader.Value);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        Console.Write("<?{0} {1}?>", reader.Name, reader.Value);
                        break;

                    case XmlNodeType.Comment:
                        Console.Write("<!--{0}-->", reader.Value);
                        break;

                    case XmlNodeType.XmlDeclaration:
                        Console.Write("<?xml version='1.0'?>");
                        break;

                    case XmlNodeType.Document:
                        break;

                    case XmlNodeType.DocumentType:
                        Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);
                        break;

                    case XmlNodeType.EntityReference:
                        Console.Write(reader.Name);
                        break;

                    case XmlNodeType.EndElement:
                        var currentElement = Elements.FirstOrDefault(x => x == reader.Name);
                        if (currentElement != null)
                        {
                            Elements.Remove(currentElement);
                        }

                        break;
                    }
                }
            }
            return(View(character));
        }
Ejemplo n.º 31
0
        /// <summary>
        ///
        /// </summary>
        private static void CharacterAbilityScores(XmlElement Element, CharacterSheet Receiver)
        {
            Int32         Count = Element.ChildNodes.Count;
            XmlNode       Child;
            String        Name;
            AbilityScores AS = Receiver.AbilityScores;
            AbilityScore  AB = null;

            for (Int32 I = 0; I < Count; I++)
            {
                Child = Element.ChildNodes[I];
                Name  = Child.Name;

                switch (Name[0])
                {
                default:
                    AB = null;
                    break;

                case 'C':
                    if (Name == "Constitution")
                    {
                        AB = AS.Constitution;
                    }
                    else if (Name == "Charisma")
                    {
                        AB = AS.Charisma;
                    }
                    break;

                case 'I':
                    if (Name == "Intelligence")
                    {
                        AB = AS.Intelligence;
                    }
                    break;

                case 'D':
                    if (Name == "Dexterity")
                    {
                        AB = AS.Dexterity;
                    }
                    break;

                case 'S':
                    if (Name == "Strength")
                    {
                        AB = AS.Strength;
                    }
                    break;

                case 'W':
                    if (Name == "Wisdom")
                    {
                        AB = AS.Wisdom;
                    }
                    break;
                }

                if (AB != null)
                {
                    AB.Score = Int32.Parse(Child.Attributes["score"].Value);
                }
            }
        }