Пример #1
0
        public PhaseShelling(BattleData data, string title, int phaseID, string suffix, bool isEscort, bool isEnemyEscort = false)
            : base(data, title)
        {
            PhaseID       = phaseID;
            Suffix        = suffix;
            IsEscort      = isEscort;
            IsEnemyEscort = isEnemyEscort;

            if (!IsAvailable)
            {
                return;
            }

            // "translate"

            int[]      fleetflag        = (int[])ShellingData.api_at_eflag;
            int[]      attackers        = (int[])ShellingData.api_at_list;
            int[]      attackTypes      = (int[])ShellingData.api_at_type;
            int[][]    defenders        = ((dynamic[])ShellingData.api_df_list).Select(elem => (int[])elem).ToArray();
            int[][]    attackEquipments = ((dynamic[])ShellingData.api_si_list).Select(elem => ((dynamic[])elem).Select <dynamic, int>(ch => ch is string?int.Parse(ch) : (int)ch).ToArray()).ToArray();
            int[][]    criticalFlags    = ((dynamic[])ShellingData.api_cl_list).Select(elem => (int[])elem).ToArray();
            double[][] rawDamages       = ((dynamic[])ShellingData.api_damage).Select(elem => ((double[])elem).Select(p => Math.Max(p, 0)).ToArray()).ToArray();

            Attacks = new List <PhaseShellingAttack>();

            for (int i = 0; i < attackers.Length; i++)
            {
                var attack = new PhaseShellingAttack()
                {
                    Attacker = new BattleIndex(attackers[i] + (fleetflag[i] == 0 ? 0 : 12), IsFriendCombined, IsEnemyCombined),
                };


                for (int k = 0; k < defenders[i].Length; k++)
                {
                    var defender = new PhaseShellingDefender
                    {
                        Defender     = new BattleIndex(defenders[i][k] + (fleetflag[i] == 0 ? 12 : 0), IsFriendCombined, IsEnemyCombined),
                        CriticalFlag = criticalFlags[i][k],
                        RawDamage    = rawDamages[i][k],
                    };

                    attack.Defenders.Add(defender);
                }

                attack.AttackType   = attackTypes[i];
                attack.EquipmentIDs = attackEquipments[i];

                Attacks.Add(attack);
            }
        }
Пример #2
0
        public PhaseShelling(BattleData data, string title, int phaseID, string suffix, bool isEscort, bool isEnemyEscort = false)
            : base(data, title)
        {
            this.phaseID       = phaseID;
            this.suffix        = suffix;
            this.isEscort      = isEscort;
            this.isEnemyEscort = isEnemyEscort;

            if (!IsAvailable)
            {
                return;
            }

            // "translate"

            int[]   fleetflag     = !ShellingData.api_at_eflag() ? null : ((int[])ShellingData.api_at_eflag).Skip(1).ToArray();
            int[]   attackers     = ((int[])ShellingData.api_at_list).Skip(1).ToArray();
            int[]   attackTypes   = ((int[])ShellingData.api_at_type).Skip(1).ToArray();
            int[][] defenders     = ((dynamic[])ShellingData.api_df_list).Skip(1).Select(elem => (int[])elem).ToArray();
            int[][] criticalFlags = ((dynamic[])ShellingData.api_cl_list).Skip(1).Select(elem => (int[])elem).ToArray();
            int[][] damages       = ((dynamic[])ShellingData.api_damage).Skip(1).Select(elem => ((int[])elem).Select(p => Math.Max(p, 0)).ToArray()).ToArray();


            Attacks = new List <PhaseShellingAttack>();

            for (int i = 0; i < attackers.Length; i++)
            {
                var attack = new PhaseShellingAttack();

                attack.Attacker  = attackers[i] - 1;
                attack.Defenders = new List <PhaseShellingDefender>();


                if (fleetflag != null)
                {
                    if (fleetflag[i] == 1)                              // enemy
                    {
                        attack.Attacker += 6;
                        if (isEnemyEscort)
                        {
                            attack.Attacker += 6;
                        }
                    }
                    else if (isEscort)                                  // friend escort
                    {
                        attack.Attacker += 6;
                    }

                    for (int k = 0; k < defenders[i].Length; k++)
                    {
                        var defender = new PhaseShellingDefender();
                        defender.Defender = defenders[i][k] - 1;

                        if (defender.Defender >= 6)                           // escort
                        {
                            defender.Defender += 6;
                        }
                        if (fleetflag[i] == 0)                           // friend -> *enemy*
                        {
                            defender.Defender += 6;
                        }

                        defender.CriticalFlag = criticalFlags[i][k];
                        defender.Damage       = damages[i][k];

                        attack.Defenders.Add(defender);
                    }
                }
                else if (isEscort)
                {
                    if (attack.Attacker < 6)                            // friend
                    {
                        attack.Attacker += 12;
                    }

                    for (int k = 0; k < defenders[i].Length; k++)
                    {
                        var defender = new PhaseShellingDefender();
                        defender.Defender = defenders[i][k] - 1;

                        if (PhaseBase.IsIndexEnemy(attack.Attacker))                                    // enemy -> *friend escort*
                        {
                            defender.Defender += 12;
                        }

                        defender.CriticalFlag = criticalFlags[i][k];
                        defender.Damage       = damages[i][k];

                        attack.Defenders.Add(defender);
                    }
                }
                else
                {
                    for (int k = 0; k < defenders[i].Length; k++)
                    {
                        var defender = new PhaseShellingDefender();

                        defender.Defender     = defenders[i][k] - 1;
                        defender.CriticalFlag = criticalFlags[i][k];
                        defender.Damage       = damages[i][k];

                        attack.Defenders.Add(defender);
                    }
                }

                attack.AttackType = attackTypes[i];

                Attacks.Add(attack);
            }
        }