public static Dictionary <int, List <FleetDamages> >[] GetDamages(this Enemy_Combined_Hougeki hougeki)
        {
            var result = new[]
            {
                new Dictionary <int, List <FleetDamages> >(),
                new Dictionary <int, List <FleetDamages> >()
            };

            var flags   = hougeki.api_at_eflag.GetData().ToArray();
            var targets = hougeki.api_df_list.GetData().Cast <object[]>().Select(x => Convert.ToInt32(x[0])).ToArray();
            var damages = hougeki.api_damage.GetData().Cast <object[]>().Select(x => x.Sum(Convert.ToInt32)).ToArray();

            for (var i = 0; i < flags.Length; i++)
            {
                // 0: f->e; 1: e->f
                var flag = flags[i] == 0 ? 1 : 0;

                // 1~12
                var target = targets[i] - 1;

                var fleet = target / 6;
                target = target % 6;

                var d = new FleetDamages();
                d.Ships[target] = damages[i];
                result[flag].GetOrAddNew(fleet).Add(d);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static IEnumerable <Attack> GetDamages(this Enemy_Combined_Hougeki hougeki)
        {
            var flags     = hougeki.api_at_eflag.GetData().ToArray();
            var sources   = hougeki.api_at_list.GetData().ToArray();
            var targets   = hougeki.api_df_list.GetData().Cast <object[]>().Select(x => x.ToInt32Array()).ToArray();
            var damages   = hougeki.api_damage.GetData().Cast <object[]>().Select(x => x.ToInt32Array()).ToArray();
            var criticals = hougeki.api_cl_list.GetData().Cast <object[]>().Select(x => x.ToInt32Array()).ToArray();

            for (var i = 0; i < flags.Length; i++)
            {
                FleetType sourceType, targetType;

                // 0: f->e; 1: e->f
                if (flags[i] == 0)
                {
                    sourceType = FleetType.Friend;
                    targetType = FleetType.Enemy;
                }
                else
                {
                    sourceType = FleetType.Enemy;
                    targetType = FleetType.Friend;
                }

                var source = sourceType == FleetType.Enemy ? -sources[i] - 1 : sources[i] + 1;
                //ToIndex(sources[i], sourceType);
                var attackDamages = damages[i].Select((damage, index) =>
                                                      new Damage(targetType == FleetType.Enemy ? -targets[i][index] - 1 : targets[i][index] + 1, damage, criticals[i][index] == 2))
                                    .ToArray();

                yield return(new Attack(source, attackDamages));
            }
        }
        private void Shelling(Enemy_Combined_Hougeki shelling)
        {
            if (shelling == null) return;

            var damages = shelling.GetDamages();

            foreach (var damage in damages[0])
            {
                this.FriendFleet.Fleets[damage.Key].CalcDamages(damage.Value.ToArray());
            }

            foreach (var damage in damages[1])
            {
                this.EnemyFleet.Fleets[damage.Key].CalcDamages(damage.Value.ToArray());
            }
        }