// for use with default game type - different ship models public BattleshipCompetition(IBattleshipOpponent op1, IBattleshipOpponent op2) { if (op1 == null) { throw new ArgumentNullException("op1"); } if (op2 == null) { throw new ArgumentNullException("op2"); } this.op1 = op1; this.op2 = op2; this.boardSize = new Size(10,10); this.useModels = true; this.shipSizes = new List<int>(); this.shipTypes = new List<ShipType>(); this.shipTypes.Add(ShipType.AIRCRAFT_CARRIER); this.shipTypes.Add(ShipType.BATTLESHIP); this.shipTypes.Add(ShipType.DESTROYER); this.shipTypes.Add(ShipType.SUBMARINE); this.shipTypes.Add(ShipType.PATROL_BOAT); }
private List <int> shipSizes; // Liste des tailles des bateaux // Constructeur public BattleshipCompetition(IBattleshipOpponent op1, IBattleshipOpponent op2, TimeSpan timePerGame, int wins, bool playOut, Size boardSize, params int[] shipSizes) { // Gestion des cas d'erreur if (op1 == null) { throw new ArgumentNullException("op1"); } if (op2 == null) { throw new ArgumentNullException("op2"); } if (timePerGame.TotalMilliseconds <= 0) { throw new ArgumentOutOfRangeException("timePerGame"); } if (wins <= 0) { throw new ArgumentOutOfRangeException("wins"); } if (boardSize.Width <= 2 || boardSize.Height <= 2) { throw new ArgumentOutOfRangeException("boardSize"); } if (shipSizes == null || shipSizes.Length < 1) { throw new ArgumentNullException("shipSizes"); } if (shipSizes.Where(s => s <= 0).Any()) { throw new ArgumentOutOfRangeException("shipSizes"); } if (shipSizes.Sum() >= (boardSize.Width * boardSize.Height)) { throw new ArgumentOutOfRangeException("shipSizes"); } // Cas général : affectation des attributs this.op1 = op1; this.op2 = op2; this.timePerGame = timePerGame; this.wins = wins; this.playOut = playOut; this.boardSize = boardSize; this.shipSizes = new List <int> (shipSizes); }
public BattleshipCompetition(IBattleshipOpponent op1, IBattleshipOpponent op2, TimeSpan timePerGame, int wins, bool playOut, Size boardSize, params int[] shipSizes) { if (op1 == null) { throw new ArgumentNullException("op1"); } if (op2 == null) { throw new ArgumentNullException("op2"); } if (timePerGame.TotalMilliseconds <= 0) { throw new ArgumentOutOfRangeException("timePerGame"); } if (wins <= 0) { throw new ArgumentOutOfRangeException("wins"); } if (boardSize.Width <= 2 || boardSize.Height <= 2) { throw new ArgumentOutOfRangeException("boardSize"); } if (shipSizes == null || shipSizes.Length < 1) { throw new ArgumentNullException("shipSizes"); } if (shipSizes.Where(s => s <= 0).Any()) { throw new ArgumentOutOfRangeException("shipSizes"); } if (shipSizes.Sum() >= (boardSize.Width * boardSize.Height)) { throw new ArgumentOutOfRangeException("shipSizes"); } this.op1 = op1; this.op2 = op2; this.timePerGame = timePerGame; this.wins = wins; this.playOut = playOut; this.boardSize = boardSize; this.shipSizes = new List<int>(shipSizes); }
public BattleshipCompetition(IBattleshipOpponent op1, IBattleshipOpponent op2, Size boardSize, params int[] shipSizes) { if (op1 == null) { throw new ArgumentNullException("op1"); } if (op2 == null) { throw new ArgumentNullException("op2"); } if (boardSize.Width <= 2 || boardSize.Height <= 2) { throw new ArgumentOutOfRangeException("boardSize"); } if (shipSizes == null || shipSizes.Length < 1) { throw new ArgumentNullException("shipSizes"); } if (shipSizes.Where(s => s <= 0).Any()) { throw new ArgumentOutOfRangeException("shipSizes"); } if (shipSizes.Sum() >= (boardSize.Width * boardSize.Height)) { throw new ArgumentOutOfRangeException("shipSizes"); } this.op1 = op1; this.op2 = op2; this.boardSize = boardSize; this.shipTypes = new List<ShipType>(); this.shipSizes = new List<int>(shipSizes); this.useModels = false; }
private static void InitializeOpponentMatch(IBattleshipOpponent opponent, int bibNumber, IDictionary<int, IBattleshipOpponent> opponents, IDictionary<int, int> scores, IDictionary<int, Stopwatch> times, IDictionary<int, List<Point>> shots) { opponents[bibNumber] = opponent; scores[bibNumber] = 0; times[bibNumber] = new Stopwatch(); shots[bibNumber] = new List<Point>(); }