🔥 Remove responsibility from Board

main
Alexis Drai 2 years ago
parent 02bdfb8830
commit df7c27ad54

@ -67,7 +67,6 @@ public struct Board : CustomStringConvertible {
mutating func insertChip(from playerId: Int, atRow row: Int, atCol col: Int) -> Bool {
guard(isWithinBounds(row, and: col)) else { return false }
guard((playerId == 1 || playerId == 2)) else { return false }
guard((_grid[row][col] == nil)) else { return false }
_grid[row][col] = playerId

@ -87,8 +87,6 @@ final class BoardTest: XCTestCase {
expect(withGrid: [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]], playerId: 1, secretTargetRow: 2, targetCol: 0, shouldWork: true)
// p2, ok
expect(withGrid: [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]], playerId: 2, secretTargetRow: 2, targetCol: 0, shouldWork: true)
// p3, nok
expect(withGrid: [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]], playerId: 3, secretTargetRow: 2, targetCol: 0, shouldWork: false)
// out of bounds left, nok
expect(withGrid: [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]], playerId: 1, secretTargetRow: 2, targetCol: -1, shouldWork: false)
// out of bounds right, nok

Loading…
Cancel
Save