🚨 ♻️ Merge nested if statements

main
Alexis Drai 2 years ago
parent 34930a7d48
commit 94bcf350fd

@ -12,33 +12,25 @@ public func scan() -> Int {
} }
var status: (isOver: Bool, result: Result) var status: (isOver: Bool, result: Result)
if let rules = BasicDefaultsNoDiag() {
if let board = Board() { if let rules = BasicDefaultsNoDiag(),
let board = Board(),
if let p1 = Human(withId: 1, let p1 = Human(withId: 1,
withName: "Geraldine Humanman", withName: "Geraldine Humanman",
usingScanner: scan) { usingScanner: scan),
let p2 = Bot(withId: 2,
if let p2 = Bot(withId: 2, withName: "Botty McBotFace"),
withName: "Botty McBotFace") { let game = Game(withScanner : scan,
withBoard: board,
if let game = Game(withScanner : scan, withRules: rules,
withBoard: board, withPlayer1: p1,
withRules: rules, withPlayer2: p2) {
withPlayer1: p1, print(game.boardString) // 1st turn
withPlayer2: p2) { while(!(game.isOver)) {
if game.play() {
print(game.boardString) // 1st turn print(game.boardString)
while(!(game.isOver)) {
if game.play() {
print(game.boardString)
}
}
print(game.gameOverString)
}
}
} }
} }
print(game.gameOverString)
} }

Loading…
Cancel
Save