コード例 #1
0
        static void RollOnChart(Animal result, Chart chart, Dice dice, string dieCode = "D6")
        {
            var option = dice.ChooseByRoll(chart.Option, dieCode);

            if (option.Attributes != null)
                foreach (var att in option.Attributes)
                    result.Increase(att.Name, dice.D(att.Bonus));

            if (option.Charts != null)
                foreach (var subChart in option.Charts)
                {
                    RollOnChart(result, subChart, dice, subChart.Roll);
                }

            if (option.Features != null)
                foreach (var feature in option.Features)
                    result.Features.Add(feature.Text);

            if (option.PostScripts != null)
                foreach (var script in option.PostScripts)
                    result.PostScripts.Add(script.Text);

            if (option.Skills != null)
                foreach (var skill in option.Skills)
                    if (skill.ScoreSpecified)
                        result.Skills.Add(skill.Name, skill.Score);
                    else
                        result.Skills.Increase(skill.Name, skill.Bonus);

            if (option.Behaviors != null)
                foreach (var behaviorMeta in option.Behaviors)
                {
                    var behavior = BehaviorList.SingleOrDefault(x => x.Name == behaviorMeta.Name);
                    if (behavior == null)
                        throw new BookException($"Chart {chart.Name} referes to unknown behavior named '{behaviorMeta.Name}'");
                    result.Behavior = result.Behavior + ", " + behavior.Name;
                    AddBehavior(result, behavior, dice);
                }
        }