public static void Begin(IShip ship1, IShip ship2) { while (ship1.IsAlive && ship2.IsAlive) { ship1.Attack(ship2); if (ship2.IsAlive) { ship2.Attack(ship1); } } if (ship1.IsAlive) { Console.WriteLine("\nПобедил {0}", ship1.Name); } else { Console.WriteLine("\nПобедил {0}", ship2.Name); } }
public AttackMessage GetAttackOnFieldResult(int i, int j) { cellField[i, j].Explored = true; IShip ship = GetShipByIJCoordinates(i, j); if (ship == null) { return(new AttackMessage(AttackResult.Miss, i, j)); } else { if (ship.Attack() == AttackResult.Destroy) { ShipDestroyed(ship); return(new AttackMessage(AttackResult.Destroy, i, j, ship)); } else { return(new AttackMessage(AttackResult.Hit, i, j)); } } }