internal void Process(ApiInfo rpInfo, BattleStage rpFirstStage = null)
        {
            var rData = rpInfo.Data as RawBattleBase;
            var rCombinedFleetData = rData as IRawCombinedFleet;

            FriendAndEnemy = new BattleParticipantSnapshot[rCombinedFleetData == null ? 12 : 24];

            for (var i = 1; i < rData.CurrentHPs.Length; i++)
                if (rData.MaximumHPs[i] != -1)
                    FriendAndEnemy[i - 1] = new BattleParticipantSnapshot(rData.MaximumHPs[i], rData.CurrentHPs[i]);

            FriendMain = FriendAndEnemy.Take(6).TakeWhile(r => r != null).ToArray();
            for (var i = 0; i < FriendMain.Count; i++)
                FriendMain[i].Participant = Owner.Participants.FriendMain[i];

            EnemyMain = FriendAndEnemy.Skip(6).TakeWhile(r => r != null).ToArray();
            for (var i = 0; i < EnemyMain.Count; i++)
                EnemyMain[i].Participant = Owner.Participants.EnemyMain[i];

            if (rCombinedFleetData != null)
            {
                BattleParticipantSnapshot[] rFriendAndEnemyEscort;

                if (rpFirstStage == null)
                    rFriendAndEnemyEscort = rCombinedFleetData.EscortFleetCurrentHPs.Zip(rCombinedFleetData.EscortFleetMaximumHPs,
                        (rpCurrent, rpMaximum) => rpMaximum != -1 ? new BattleParticipantSnapshot(rpMaximum, rpCurrent) : null).Skip(1).ToArray();
                else
                {
                    IEnumerable<BattleParticipantSnapshot> rFriendEscort = rpFirstStage.FriendEscort;
                    if (rFriendEscort == null)
                        rFriendEscort = Enumerable.Repeat<BattleParticipantSnapshot>(null, 6);

                    IEnumerable<BattleParticipantSnapshot> rEnemyEscort = rpFirstStage.EnemyEscort;
                    if (rEnemyEscort == null)
                        rEnemyEscort = Enumerable.Repeat<BattleParticipantSnapshot>(null, 6);

                    rFriendAndEnemyEscort = rFriendEscort.Concat(rEnemyEscort).Select(r => r != null ? new BattleParticipantSnapshot(r.Maximum, r.Current) : null).ToArray();
                }

                if (rFriendAndEnemyEscort[0] != null)
                {
                    FriendEscort = rFriendAndEnemyEscort.Take(6).TakeWhile(r => r != null).ToArray();

                    for (var i = 0; i < FriendEscort.Count; i++)
                    {
                        FriendEscort[i].Participant = Owner.Participants.FriendEscort[i];
                        FriendAndEnemy[i + 12] = FriendEscort[i];
                    }
                }

                if ((rpFirstStage == null && rFriendAndEnemyEscort.Length > 6) || (rpFirstStage != null && rpFirstStage.EnemyEscort != null))
                {
                    EnemyEscort = rFriendAndEnemyEscort.Skip(6).ToArray();

                    for (var i = 0; i < EnemyEscort.Count; i++)
                    {
                        EnemyEscort[i].Participant = Owner.Participants.EnemyEscort[i];
                        FriendAndEnemy[i + 18] = EnemyEscort[i];
                    }
                }
            }

            if (FriendEscort == null)
                Friend = FriendMain;
            else
                Friend = FriendMain.Concat(FriendEscort).ToArray();

            if (EnemyEscort == null)
                Enemy = EnemyMain;
            else
                Enemy = EnemyMain.Concat(EnemyEscort).ToArray();

            foreach (var rPhase in Phases)
                rPhase.Process();

            if (!Owner.IsPractice)
                foreach (var rSnapshot in Friend)
                {
                    var rParticipant = (FriendShip)rSnapshot.Participant;
                    if (rSnapshot.State == BattleParticipantState.HeavilyDamaged && rParticipant.EquipedEquipment.Any(r => r.Info.Type == EquipmentType.DamageControl))
                    {
                        rParticipant.IsDamageControlConsumed = false;
                        rParticipant.IsDamageControlVisible = true;
                    }
                }
        }
Esempio n. 2
0
        internal void Process(ApiInfo rpInfo, BattleStage rpFirstStage = null)
        {
            var rData = rpInfo.Data as RawBattleBase;
            var rCombinedFleetData = rData as IRawCombinedFleet;

            FriendAndEnemy = new BattleParticipantSnapshot[rCombinedFleetData == null ? 12 : 24];

            for (var i = 1; i < rData.CurrentHPs.Length; i++)
            {
                if (rData.MaximumHPs[i] != -1)
                {
                    FriendAndEnemy[i - 1] = new BattleParticipantSnapshot(rData.MaximumHPs[i], rData.CurrentHPs[i]);
                }
            }

            FriendMain = FriendAndEnemy.Take(6).TakeWhile(r => r != null).ToArray();
            for (var i = 0; i < FriendMain.Count; i++)
            {
                FriendMain[i].Participant = Owner.Participants.FriendMain[i];
            }

            EnemyMain = FriendAndEnemy.Skip(6).TakeWhile(r => r != null).ToArray();
            for (var i = 0; i < EnemyMain.Count; i++)
            {
                EnemyMain[i].Participant = Owner.Participants.EnemyMain[i];
            }

            if (rCombinedFleetData != null)
            {
                BattleParticipantSnapshot[] rFriendAndEnemyEscort;

                if (rpFirstStage == null)
                {
                    rFriendAndEnemyEscort = rCombinedFleetData.EscortFleetCurrentHPs.Zip(rCombinedFleetData.EscortFleetMaximumHPs,
                                                                                         (rpCurrent, rpMaximum) => rpMaximum != -1 ? new BattleParticipantSnapshot(rpMaximum, rpCurrent) : null).Skip(1).ToArray();
                }
                else
                {
                    IEnumerable <BattleParticipantSnapshot> rFriendEscort = rpFirstStage.FriendEscort;
                    if (rFriendEscort == null)
                    {
                        rFriendEscort = Enumerable.Repeat <BattleParticipantSnapshot>(null, 6);
                    }

                    IEnumerable <BattleParticipantSnapshot> rEnemyEscort = rpFirstStage.EnemyEscort;
                    if (rEnemyEscort == null)
                    {
                        rEnemyEscort = Enumerable.Repeat <BattleParticipantSnapshot>(null, 6);
                    }

                    rFriendAndEnemyEscort = rFriendEscort.Concat(rEnemyEscort).Select(r => r != null ? new BattleParticipantSnapshot(r.Maximum, r.Current) : null).ToArray();
                }

                if (rFriendAndEnemyEscort[0] != null)
                {
                    FriendEscort = rFriendAndEnemyEscort.Take(6).TakeWhile(r => r != null).ToArray();

                    for (var i = 0; i < FriendEscort.Count; i++)
                    {
                        FriendEscort[i].Participant = Owner.Participants.FriendEscort[i];
                        FriendAndEnemy[i + 12]      = FriendEscort[i];
                    }
                }

                if ((rpFirstStage == null && rFriendAndEnemyEscort.Length > 6) || (rpFirstStage != null && rpFirstStage.EnemyEscort != null))
                {
                    EnemyEscort = rFriendAndEnemyEscort.Skip(6).ToArray();

                    for (var i = 0; i < EnemyEscort.Count; i++)
                    {
                        EnemyEscort[i].Participant = Owner.Participants.EnemyEscort[i];
                        FriendAndEnemy[i + 18]     = EnemyEscort[i];
                    }
                }
            }

            if (FriendEscort == null)
            {
                Friend = FriendMain;
            }
            else
            {
                Friend = FriendMain.Concat(FriendEscort).ToArray();
            }

            if (EnemyEscort == null)
            {
                Enemy = EnemyMain;
            }
            else
            {
                Enemy = EnemyMain.Concat(EnemyEscort).ToArray();
            }

            foreach (var rPhase in Phases)
            {
                rPhase.Process();
            }

            if (!Owner.IsPractice)
            {
                foreach (var rSnapshot in Friend)
                {
                    var rParticipant = (FriendShip)rSnapshot.Participant;
                    if (rSnapshot.State == BattleParticipantState.HeavilyDamaged && rParticipant.EquipedEquipment.Any(r => r.Info.Type == EquipmentType.DamageControl))
                    {
                        rParticipant.IsDamageControlConsumed = false;
                        rParticipant.IsDamageControlVisible  = true;
                    }
                }
            }
        }