Ejemplo n.º 1
0
        public void UpdateStatus()
        {
            LowCondition   = false;
            HeavilyDamaged = false;
            NeedCharge     = false;
            Repairing      = false;
            foreach (var ship in Ships)
            {
                LowCondition   |= ship.Condition < 40;
                HeavilyDamaged |= !ship.IsEscaped && ship.DamageControl == null && ship != Ships.FirstOrDefault() && ship.HP.Current * 4 <= ship.HP.Max;
                NeedCharge     |= !(ship.Fuel.IsMax && ship.Bull.IsMax);
                Repairing      |= ship.IsRepairing;
            }
#pragma warning disable CC0014
            if (InSortie)
            {
                Status = HeavilyDamaged ? FleetStatus.Warning : FleetStatus.InSortie;
            }
            else if (MissionState != FleetMissionState.None)
            {
                Status = FleetStatus.InMission;
            }
            else if (NeedCharge || HeavilyDamaged || LowCondition || Repairing || CanHomeportRepairing)
            {
                Status = FleetStatus.NotReady;
            }
            else
            {
                Status = FleetStatus.Ready;
            }
#pragma warning restore CC0014
            AirFightPower = Ships.Where(x => !x.IsEscaped).Aggregate(new AirFightPower(), (x, y) => x + y.AirFightPower);
            if (Ships.Any())
            {
                mincondition = Ships.Min(x => x.Condition);
            }
            else
            {
                mincondition = 49;
                Status       = FleetStatus.Empty;
            }
            OnPropertyChanged(nameof(AirFightPower));
            OnPropertyChanged(nameof(LevelSum));
            OnPropertyChanged(nameof(LevelAverage));
            OnPropertyChanged(nameof(LoSInMap));
            OnPropertyChanged(nameof(ChargeCost));
            OnPropertyChanged(nameof(RepairCost));
            OnPropertyChanged(nameof(CanHomeportRepairing));
            OnPropertyChanged(nameof(Speed));
        }