コード例 #1
0
ファイル: AttackSelection.cs プロジェクト: DnDGen/CreatureGen
        public static AttackSelection From(string rawData)
        {
            var helper = new AttackHelper();
            var data   = helper.ParseEntry(rawData);

            var selection = new AttackSelection();

            selection.IsMelee               = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsMeleeIndex]);
            selection.IsNatural             = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsNaturalIndex]);
            selection.IsPrimary             = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsPrimaryIndex]);
            selection.IsSpecial             = Convert.ToBoolean(data[DataIndexConstants.AttackData.IsSpecialIndex]);
            selection.Name                  = data[DataIndexConstants.AttackData.NameIndex];
            selection.DamageEffect          = data[DataIndexConstants.AttackData.DamageEffectIndex];
            selection.DamageBonusMultiplier = Convert.ToDouble(data[DataIndexConstants.AttackData.DamageBonusMultiplierIndex]);
            selection.FrequencyQuantity     = Convert.ToInt32(data[DataIndexConstants.AttackData.FrequencyQuantityIndex]);
            selection.FrequencyTimePeriod   = data[DataIndexConstants.AttackData.FrequencyTimePeriodIndex];
            selection.Save                  = data[DataIndexConstants.AttackData.SaveIndex];
            selection.SaveAbility           = data[DataIndexConstants.AttackData.SaveAbilityIndex];
            selection.AttackType            = data[DataIndexConstants.AttackData.AttackTypeIndex];
            selection.SaveDcBonus           = Convert.ToInt32(data[DataIndexConstants.AttackData.SaveDcBonusIndex]);

            var damageHelper  = new DamageHelper();
            var damageEntries = damageHelper.ParseEntries(data[DataIndexConstants.AttackData.DamageDataIndex]);

            foreach (var damageData in damageEntries)
            {
                var damage = new Damage
                {
                    Roll      = damageData[DataIndexConstants.AttackData.DamageData.RollIndex],
                    Type      = damageData[DataIndexConstants.AttackData.DamageData.TypeIndex],
                    Condition = damageData[DataIndexConstants.AttackData.DamageData.ConditionIndex],
                };

                selection.Damages.Add(damage);
            }

            return(selection);
        }
コード例 #2
0
        public void ParseData()
        {
            var data = helper.ParseEntry("this@is@my@data");

            Assert.That(data, Is.EqualTo(new[] { "this", "is", "my", "data" }));
        }