diff --git a/TetraVexKit/TetraVexBoardModel.swift b/TetraVexKit/TetraVexBoardModel.swift index c23cfad..8be777c 100644 --- a/TetraVexKit/TetraVexBoardModel.swift +++ b/TetraVexKit/TetraVexBoardModel.swift @@ -25,6 +25,10 @@ open class TetraVexBoardModel { return false } + if board[x][y] != nil { + return false + } + var leftP : PieceModel? = nil if 0 ... board.count-1 ~= x-1 && 0 ... board[0].count-1 ~= y { leftP = board[x-1][y] diff --git a/TetraVexKitTests/TetraVexKitTests.swift b/TetraVexKitTests/TetraVexKitTests.swift index e40f6ca..866438b 100644 --- a/TetraVexKitTests/TetraVexKitTests.swift +++ b/TetraVexKitTests/TetraVexKitTests.swift @@ -59,6 +59,8 @@ class TetraVexKitTests: XCTestCase { let board = TetraVexBoardModel(width: 2, height: 2) var r = board.addPieceToBoard(a, x: 0, y: 1) XCTAssert(r == true) + r = board.addPieceToBoard(b, x: 0, y: 1) + XCTAssert(r == false) r = board.addPieceToBoard(b, x: 1, y: 1) XCTAssert(r == true) r = board.addPieceToBoard(c, x: 1, y: 0)