Ejemplo n.º 1
0
 public void MoveShips()
 {
     if (Ships.Count > 0)
     {
         Ships.ForEach(s => s.Move());
         Ships.RemoveAll(s => s.location == null);
     }
 }
Ejemplo n.º 2
0
        internal void CalcProbabilities(BattleshipPlayer player)
        {
            int remainingHits = 0;

            Ships.ForEach(ship => { if (ship.Destroyed == false)
                                    {
                                        remainingHits += Ship.Size(ship.ShipType);
                                    }
                          });
            if ((17 - player.ShotsHit) < remainingHits)
            {
                // We have a target that needs to be hunted
                Hunting = true;
            }

            var directions = new Direction[] { Direction.North, Direction.South, Direction.East, Direction.West };

            Cells.ForEach(cell =>
            {
                if (cell.Missed || cell.Damaged)
                {
                    return;
                }

                Ships.ForEach(ship =>
                {
                    foreach (Direction dir in directions)
                    {
                        if (HasCellsForDirection(cell.Point, dir, Ship.Size(ship.ShipType)) == false)
                        {
                            continue;
                        }
                        List <OpponentCell> cells = GetAllCellsInDirection(cell.Point, dir, Ship.Size(ship.ShipType));
                        if ((cells.Any(c => c.Damaged) == true) && Hunting)
                        {
                            foreach (OpponentCell oc in cells)
                            {
                                if (oc.Missed == true)
                                {
                                    break;
                                }
                                if (oc.Damaged == true)
                                {
                                    cell.Probability += 2;
                                }
                            }
                        }
                        if (cells.Any(c => c.Missed) == true)
                        {
                            continue;
                        }

                        cell.Probability++;
                    }
                });
            });
        }
Ejemplo n.º 3
0
 private void ItemsHandler(getmember_slotitem[] api)
 {
     if (Equipments == null)
     {
         Equipments = new IDTable <int, Equipment>(api.Select(x => new Equipment(x)));
     }
     else
     {
         Equipments.UpdateAll(api, x => x.api_id);
     }
     Staff.Current.Admiral.EquipCount = api.Length;
     Ships?.ForEach(x => x.TryUpdateEquip());
 }