Exemplo n.º 1
0
        internal string GetStatusMessage()
        {
            var message = new StringBuilder();

            if (Ships.Any(a => a.HitCount > 0))
            {
                message.AppendLine($"{Name} current status:");

                var hitShips = Ships.Where(w => w.HitCount > 0 && !w.IsSunk).ToList();
                foreach (var item in hitShips)
                {
                    var plural = item.HitCount > 1 ? "s" : string.Empty;
                    message.AppendLine($"{item.Name} : {item.HitCount} hit{plural}");
                }

                var sunkShips = Ships.Where(w => w.IsSunk).ToList();
                foreach (var item in sunkShips)
                {
                    message.AppendLine($"{item.Name} : Sunk");
                }

                message.AppendLine($"Received {GameBoard.Squares.Count(c => c.IsHit)} hit shot");
                message.AppendLine($"Received {GameBoard.Squares.Count(c => c.IsMiss)} missed shot");
            }

            return(message.ToString());
        }
Exemplo n.º 2
0
 private FleetState CheckFleetState()
 {
     if (Ships.AsList().Count == 0)
     {
         return(FleetState.Empty);
     }
     if (Expedition != null)
     {
         return(FleetState.Expedition);
     }
     if (ships.Any(s => s.IsRepairing))
     {
         return(FleetState.Repairing);
     }
     if (Ships.Any(s => s.HP.DamageState >= ShipDamageState.HeavilyDamaged))
     {
         return(FleetState.Damaged);
     }
     if (Ships.Any(s => !s.Fuel.IsMaximum || !s.Bullet.IsMaximum))
     {
         return(FleetState.Insufficient);
     }
     if (Ships.Any(s => s.Morale < 40))
     {
         return(FleetState.Fatigued);
     }
     if (owner.CombinedFleet > 0 && (Id == 1 || Id == 2))
     {
         return(FleetState.Combined);
     }
     return(FleetState.Ready);
 }
Exemplo n.º 3
0
 public bool IsShield(ShipInfo ship)
 {
     lock (Types)
         if (Types.Any(_ => _.ID == ship.ShipCargoType))
         {
             return(true);
         }
     lock (Ships)
         if (Ships.Any(_ => _.ID == ship.MMSI))
         {
             return(true);
         }
     return(false);
 }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
 public bool HasPilot(string name)
 {
     return(Ships.Any(n => n.Instance.PilotInfo.PilotName == name));
 }
Exemplo n.º 6
0
 public bool IsShipGate(byte gateId)
 {
     return(Ships.Any(s => s.PhysicalGateID.Contains(gateId)));
 }