33 lines
883 B
Swift
33 lines
883 B
Swift
//
|
|
// SuperTicTacToeBoard.swift
|
|
// TTTKit
|
|
//
|
|
// Created by Shadowfacts on 12/21/22.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct SuperTicTacToeBoard: Board {
|
|
|
|
private var boards: [[TicTacToeBoard]] = [
|
|
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
|
|
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
|
|
[TicTacToeBoard(), TicTacToeBoard(), TicTacToeBoard()],
|
|
]
|
|
|
|
public subscript(_ column: Int, _ row: Int) -> Mark? {
|
|
get {
|
|
getSubBoard(column: column, row: row).win?.mark
|
|
}
|
|
}
|
|
|
|
public func getSubBoard(column: Int, row: Int) -> TicTacToeBoard {
|
|
return boards[row][column]
|
|
}
|
|
|
|
public mutating func play(mark: Mark, subBoard: (column: Int, row: Int), column: Int, row: Int) {
|
|
boards[subBoard.row][subBoard.column].play(mark: mark, column: column, row: row)
|
|
}
|
|
|
|
}
|