Example #1
0
        private DamageAllocationTrack GenerateDamageAllocationTrack(SystemTargeting useTargeting)
        {
            var d6 = Dice.RollD6();
            DamageAllocationTrack dacTrack = null;

            dacTrack = DamageAllocationChart.GetTrack(d6);

            if (useTargeting == SystemTargeting.Weapons)
            {
                if (d6 == 1 || d6 == 2)
                {
                    dacTrack = DamageAllocationChart.Weapons;
                }
            }

            if (useTargeting == SystemTargeting.Power)
            {
                if (d6 == 5 || d6 == 6)
                {
                    dacTrack = DamageAllocationChart.Power;
                }
            }

            return(dacTrack);
        }
Example #2
0
        public static DamageAllocationTrack GetDamageAllocationTrack(int trackNumber)
        {
            if (_damageAllocationChart == null)
            {
                var file =
                    new JsonDataReader().ReadSingleSpecification <DamageAllocationChartFile>(
                        AppEnvironment.Current.AppData + "\\Rules\\DamageAllocationChart.json");

                _damageAllocationChart = new DamageAllocationChart();
                foreach (var kvp in file)
                {
                    var track = new DamageAllocationTrack();
                    _damageAllocationChart.Tracks.Add(kvp.Key, track);
                    foreach (var trackUnitCode in kvp.Value)
                    {
                        var code          = trackUnitCode;
                        var oncePerVolley = trackUnitCode.StartsWith("_");
                        if (oncePerVolley)
                        {
                            code = trackUnitCode.Substring(1);
                        }

                        var isAny = trackUnitCode.StartsWith("*");
                        if (isAny)
                        {
                            code = trackUnitCode.Substring(1);
                        }

                        var isEndsWith = trackUnitCode.StartsWith("^");
                        if (isEndsWith)
                        {
                            code = trackUnitCode.Substring(1);
                        }

                        if (isAny)
                        {
                            foreach (var cmp in _components)
                            {
                                if (cmp.ComponentType == code)
                                {
                                    var unit = new DamageAllocationTrackUnit
                                    {
                                        Id            = $"{kvp.Key}-{code}",
                                        Code          = code,
                                        OncePerVolley = oncePerVolley,
                                    };
                                    track.Units.Add(unit);
                                }
                            }

                            continue;
                        }

                        if (isEndsWith)
                        {
                            foreach (var cmp in _components)
                            {
                                if (cmp.Code.EndsWith(code))
                                {
                                    var unit = new DamageAllocationTrackUnit
                                    {
                                        Id            = $"{kvp.Key}-{code}",
                                        Code          = code,
                                        OncePerVolley = oncePerVolley,
                                    };
                                    track.Units.Add(unit);
                                }
                            }

                            continue;
                        }


                        var unit2 = new DamageAllocationTrackUnit
                        {
                            Id            = $"{kvp.Key}-{code}",
                            Code          = code,
                            OncePerVolley = oncePerVolley,
                        };
                        track.Units.Add(unit2);
                    }
                }
            }

            return(_damageAllocationChart.Tracks[trackNumber]);
        }