Exemplo n.º 1
0
 // TODO: order of constructors is too restricting... fix me!
 public BatteShipGame(IPlayer cpu, IPlayer humanOrCpu, Coordinate boardDims, ShipPlacementHelper sph, GameInfoHelper gih)
 {
     this.maxCoords = boardDims; // ex) 10 x 10 board would have maxCoord of 9, 9
     this.sph = sph;
     this.gih = gih;
     this.A = cpu;
     this.B = humanOrCpu;
     this.A.Initialize(maxCoords, gih.GetStartingShips());
     this.B.Initialize(maxCoords, gih.GetStartingShips());
 }
Exemplo n.º 2
0
        public void TestPlaceShips(IPlayer player)
        {
            String failMsg = player.PlayerName + " Failed TestPlaceShips ";
            var sph = new ShipPlacementHelper(getMaxCoords());
            List<Ship> ships = new List<Ship>();

            player.PlaceShips();

            foreach (var ship in player.Ships)
            {
                Assert.IsFalse(sph.IsInvalidPlacement(ship), failMsg + "Invalid Placement");
                if (sph.PlacementCreatesConflict(ship, ships)) { Assert.Fail(failMsg + "Placement Conflict"); }
                else { ships.Add(ship); }
            }
        }
Exemplo n.º 3
0
        public void Initialize(Coordinate maxCoords, Ship[] startingShips)
        {
            this.Ships = startingShips;
            this.MaxCoords = maxCoords;
            this.Attacks = new Attack[maxCoords.X + 1, maxCoords.Y + 1];
            for (int x = 0; x <= maxCoords.X; x++) { for (int y = 0; y <= maxCoords.Y; y++) { Attacks[x, y] = new Attack(); } }
            this.sph = new ShipPlacementHelper(maxCoords);
            this.gih = new GameInfoHelper();

            this.resetShips.IsEnabled = false;
            this.resetShips.Visibility = Visibility.Hidden;

            InitializeGrids();
            InitializeShips();
            InitializePlayerInfo();
        }
Exemplo n.º 4
0
 public void Initialize(Coordinate maxCoords, Ship[] startingShips)
 {
     this.wdw.Initialize(maxCoords, startingShips);
     wdw.ShipsPlaced += new MainWindow.ShipsPlacedEventHandler(HandlePiecePlaced);
     wdw.AttackMade += new MainWindow.AttackMadeEventHandler(HandleAttackMade);
     this.sph = new ShipPlacementHelper(maxCoords);
 }
Exemplo n.º 5
0
 public virtual void Initialize(Coordinate maxCoords, Ship[] startingShips)
 {
     this.Ships = startingShips;
     this.Attacks = new Attack[maxCoords.X + 1, maxCoords.Y + 1];
     for (int x = 0; x <= maxCoords.X; x++) { for (int y = 0; y <= maxCoords.Y; y++) { Attacks[x, y] = new Attack(); } }
     this.MaxCoords = maxCoords;
     this.sph = new ShipPlacementHelper(maxCoords);
 }