From 279db8b2c15d57324bd1026ccec563f8786069ec Mon Sep 17 00:00:00 2001 From: Tamara Cook <10754072+tamaracha@users.noreply.github.com> Date: Thu, 21 Feb 2019 11:56:27 +0100 Subject: [PATCH] Remove BegriffixBoard.findBalance This was a workaround and is not needed anymore. --- Sources/Games/BegriffixBoard.swift | 7 ------- Tests/GamesTests/BegriffixBoardTests.swift | 23 ---------------------- 2 files changed, 30 deletions(-) diff --git a/Sources/Games/BegriffixBoard.swift b/Sources/Games/BegriffixBoard.swift index e2c6e51..9bc90e6 100644 --- a/Sources/Games/BegriffixBoard.swift +++ b/Sources/Games/BegriffixBoard.swift @@ -118,13 +118,6 @@ public struct BegriffixBoard { } .map {Place(start: $0, direction: direction, count: count)} } - /// Returns the direction which more places exist for - public func findBalance() -> Direction? { - let horizontal = self.find(direction: .horizontal, count: self.sideLength).count - let vertical = self.find(direction: .vertical, count: self.sideLength).count - if horizontal == vertical {return nil} - return horizontal > vertical ? .horizontal : .vertical - } /// Return the words crossing the given place after inserting a given word public func words(orthogonalTo place: Place, word: Word) -> [Word] { let area = place.area diff --git a/Tests/GamesTests/BegriffixBoardTests.swift b/Tests/GamesTests/BegriffixBoardTests.swift index 7aad886..7907809 100644 --- a/Tests/GamesTests/BegriffixBoardTests.swift +++ b/Tests/GamesTests/BegriffixBoardTests.swift @@ -75,27 +75,4 @@ class BegriffixBoardTests: XCTestCase { let word: Begriffix.Word = ["x", "y", "z"] XCTAssertEqual(BegriffixBoard.word(in: pattern, around: 2), word) } - // MARK: findBalance - func testBalanceAfterInit() { - let board = try! BegriffixBoard(startLetters: "xxxx") - XCTAssertNil(board.findBalance()) - } - func testBalanceafterFirstHorizontalMoveIsVertical() { - var board = try! BegriffixBoard(startLetters: "xxxx") - let point = Point(row: 3, column: 3) - let word = "xxxxx" - let place = Place(start: point, direction: .horizontal, count: 5) - try! board.insert(Array(word.unicodeScalars), at: place) - let balance = board.findBalance() - XCTAssertEqual(balance, .vertical) - } - func testBalanceafterFirstVerticalMoveIsHorizontal() { - var board = try! BegriffixBoard(startLetters: "xxxx") - let point = Point(row: 3, column: 3) - let word = "xxxxx" - let place = Place(start: point, direction: .vertical, count: 5) - try! board.insert(Array(word.unicodeScalars), at: place) - let balance = board.findBalance() - XCTAssertEqual(balance, .horizontal) - } }