Пример #1
0
        public bool buildHorizontalRoad(Point coords, Player player)
        {
            int xVal = coords.X;
            int yVal = coords.Y;
            int intRow, intCol = 0;
            intRow = xVal/2;
            if (xVal == 0 || xVal == 10)
            {
                intCol = yVal + 2;
            }
            else if (xVal == 2 || xVal == 8)
            {
                intCol = yVal + 1;
            }
            else if (xVal == 4 || xVal == 6)
            {
                intCol = yVal;
            }
            else
            {
            } // throw exception?

            if (roadHasBuildingOrConnectingRoad(new Point(intRow, intCol), new Point(intRow, intCol + 1), player))
            {
                map[intRow, intCol].connections[2].buildRoad(player.getColor());
                map[intRow, intCol + 1].connections[0].buildRoad(player.getColor());
                player.addConnection(map[intRow, intCol].connections[2]);

                return true;
            }
            else return false;
        }
Пример #2
0
        public bool buildVerticalRoad(Point coords, Player player)
        {
            int xVal = coords.X;
            int yVal = coords.Y;
            int intRow, intCol = 0;
            intRow = xVal/2;
            if (xVal == 1 || xVal == 9)
            {
                intCol = yVal*2 + 2;
            }
            else if (xVal == 3 || xVal == 7)
            {
                intCol = yVal*2 + 1;
            }
            else if (xVal == 5)
            {
                intCol = yVal*2;
            }
            else
            {
            } // Throw exception?

            if (roadHasBuildingOrConnectingRoad(new Point(intRow, intCol), new Point(intRow + 1, intCol), player))
            {
                map[intRow, intCol].connections[1].buildRoad(player.getColor());
                map[intRow + 1, intCol].connections[1].buildRoad(player.getColor());
                player.addConnection(map[intRow, intCol].connections[1]);

                return true;
            }
            else return false;
        }