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()); }
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); }
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); }
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)); }
public bool HasPilot(string name) { return(Ships.Any(n => n.Instance.PilotInfo.PilotName == name)); }
public bool IsShipGate(byte gateId) { return(Ships.Any(s => s.PhysicalGateID.Contains(gateId))); }