🚨 ♻️ 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(),
let p1 = Human(withId: 1,
withName: "Geraldine Humanman",
usingScanner: scan),
let p2 = Bot(withId: 2,
withName: "Botty McBotFace"),
let game = Game(withScanner : scan,
withBoard: board,
withRules: rules,
withPlayer1: p1,
withPlayer2: p2) {
print(game.boardString) // 1st turn
while(!(game.isOver)) {
if game.play() {
print(game.boardString)
if let p1 = Human(withId: 1,
withName: "Geraldine Humanman",
usingScanner: scan) {
if let p2 = Bot(withId: 2,
withName: "Botty McBotFace") {
if let game = Game(withScanner : scan,
withBoard: board,
withRules: rules,
withPlayer1: p1,
withPlayer2: p2) {
print(game.boardString) // 1st turn
while(!(game.isOver)) {
if game.play() {
print(game.boardString)
}
}
print(game.gameOverString)
}
}
} }
} }
print(game.gameOverString)
} }

Loading…
Cancel
Save