parent
a960f6f390
commit
27df2f0bb8
@ -1,11 +1,45 @@
|
||||
//
|
||||
// main.swift
|
||||
// CLI
|
||||
//
|
||||
// Created by Mathieu GROUSSEAU on 11/01/2025.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
print("Hello, World!")
|
||||
import Model
|
||||
import CustomTypes
|
||||
|
||||
guard var board = Board(columns: 5, rows: 5) else {
|
||||
print("Failed to create board.")
|
||||
exit(EXIT_FAILURE)
|
||||
}
|
||||
|
||||
print(board.debugDescription)
|
||||
print(board)
|
||||
|
||||
for i in 0...2 {
|
||||
for _ in 0...i {
|
||||
let dropAt = board.getInsertionCoordinates(from: .Top, offset: i)
|
||||
let landAt = switch board.fallCoordinates(initialCoords: dropAt, direction: .Bottom) {
|
||||
case .Border(let at), .Piece(let at, _):
|
||||
at
|
||||
case .Occupied:
|
||||
exit(EXIT_FAILURE)
|
||||
}
|
||||
|
||||
board[landAt] = Piece(owner: .A)
|
||||
}
|
||||
}
|
||||
|
||||
print(board)
|
||||
|
||||
board[0, 2] = Piece(owner: .B)
|
||||
board[2, 4] = nil
|
||||
|
||||
for c in 0..<board.rows {
|
||||
switch board.fallCoordinates(initialCoords: board.getInsertionCoordinates(from: .Right, offset: c), direction: .Left) {
|
||||
case .Border(let at):
|
||||
board[at] = Piece(owner: .B)
|
||||
case .Piece(let at, let touched):
|
||||
(board[at], board[touched]) = (board[touched], Piece(owner: .B))
|
||||
case .Occupied:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
print(board.debugDescription)
|
||||
print(board)
|
||||
|
Loading…
Reference in new issue