Пример #1
0
 private static IEnumerable <Attack> ParseAttack(decimal[] damageList, int[] torpedoFlags, int[] bombFlags, int[] criticalList, bool direction,
                                                 ShipInBattle[] fleet, ShipInBattle torpedoSource, ShipInBattle bombSource)
 {
     for (int i = 1; i < damageList.Length; i++)
     {
         ShipInBattle source;
         bool         torpedo = torpedoFlags[i] != 0, bomb = bombFlags[i] != 0;
         if (torpedo && bomb)
         {
             source = null;
         }
         else if (torpedo)
         {
             source = torpedoSource;
         }
         else if (bomb)
         {
             source = bombSource;
         }
         else
         {
             continue;
         }
         var damage = Attack.ParseDamage(damageList[i]);
         (var friend, var enemy) = direction ? (source, fleet[i - 1]) : (fleet[i - 1], source);
Пример #2
0
        protected void ParseAttacks(Battle battle, sortie_battle.airbattle api, ShipInBattle friendtorpedo, ShipInBattle friendbomb, ShipInBattle enemytorpedo, ShipInBattle enemybomb)
        {
            var result = Enumerable.Empty <Attack>();

            void ParseStage3(sortie_battle.airbattle.stage3 stage3, ShipInBattle[] friend, ShipInBattle[] enemy)
            {
                if (stage3 == null)
                {
                    return;
                }
                if (stage3.api_fdam != null)
                {
                    result = result.Concat(ParseAttack(stage3.api_fdam, stage3.api_frai_flag, stage3.api_fbak_flag, stage3.api_fcl_flag,
                                                       false, friend, enemytorpedo, enemybomb));
                }
                if (stage3.api_edam != null)
                {
                    result = result.Concat(ParseAttack(stage3.api_edam, stage3.api_erai_flag, stage3.api_ebak_flag, stage3.api_ecl_flag,
                                                       true, enemy, friendtorpedo, friendbomb));
                }
            }

            ParseStage3(api.api_stage3, battle.Fleet1, battle.EnemyFleet);
            ParseStage3(api.api_stage3_combined, battle.Fleet2, battle.EnemyFleet2);

            ApplyAttacks(result, battle);
        }