示例#1
0
    const Piece *Game::getPiece(unsigned int x, unsigned int y) const {

        if(__grid[((x*__width) + y)] != nullptr) {
            return __grid[((x*__width) + y)];
        }

        throw PositionEmptyEx(x,y);
    }
示例#2
0
    const Piece* Game::getPiece(unsigned int x, unsigned int y) const
    {
         if(y >= __width ||  x >=__height)
             throw OutOfBoundsEx(__height, __width, x, y);


        if (__grid[y + (x * __width)] == nullptr) throw PositionEmptyEx(x, y);
        return __grid[y + (x * __width)];
    }
示例#3
0
    const Piece *Game::getPiece(unsigned int x, unsigned int y) const {
        //TODO would i return the piece that is at that location??
        int location = y +(x* __width);         //will look for this location on the grid
        if (x < 0 || x >= __height || y < 0 || y >= __width)
            throw OutOfBoundsEx(__width, __height, x, y);
        if (__grid[location] == nullptr)
            throw PositionEmptyEx(x, y);

        return __grid[location];                //returns the location on the grid
    }
示例#4
0
    const Piece * Game::getPiece(unsigned int x, unsigned int y) const
    {
		if (x > __width || y > __height)
			throw OutOfBoundsEx(__width, __height, x, y);
		for (int it = 0; it < __grid.size(); it++)
		{
			if (__grid[it] != nullptr)
				if (__grid[it]->getPosition().x == x && __grid[it]->getPosition().y == y)
					return __grid[it];
		}
		throw PositionEmptyEx(x, y);
        return __grid[0];
    }
示例#5
0
    const Piece *Game::getPiece(unsigned int x, unsigned int y) const
    {
        if (y >= __width || x >= __height)
        {
            throw OutOfBoundsEx(__width, __height, x, y);
        }

        if (__grid[x * __width + y] == nullptr)
        {
            throw PositionEmptyEx(x, y);
        }

        int location = x * __width + y;
        return __grid[location];
    }
示例#6
0
 const Piece *Game::getPiece(unsigned int x, unsigned int y) const {
     if(__grid[y*__width + x] != nullptr)
         return __grid[y*__width + x];
     throw PositionEmptyEx(x, y);
 }