Skip to content

Commit

Permalink
Remove BegriffixBoard.findBalance
Browse files Browse the repository at this point in the history
This was a workaround and is not needed anymore.
  • Loading branch information
tamaracha committed Feb 21, 2019
1 parent 2a41c47 commit 279db8b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
7 changes: 0 additions & 7 deletions Sources/Games/BegriffixBoard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions Tests/GamesTests/BegriffixBoardTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 279db8b

Please sign in to comment.