You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
4.3 KiB

//
// main.swift
// ProjectDouShouQi
//
// Created by Louis DUFOUR on 15/01/2024.
//
import Foundation
import Model
import Extension
let initialBoardConfiguration: [[Cell]] = [
// Ligne 1
[Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .lion)),
Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .tiger))],
// Ligne 2
[Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .dog)),
Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle),
Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .cat)), Cell(ofType: .jungle)],
// Ligne 3
[Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .rat)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .leopard)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .wolf)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player1, andAnimal: .elephant))],
// Lignes 4 à 7 (Eau et Jungle)
[Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water),
Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)],
[Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water),
Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)],
[Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water),
Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)],
[Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water),
Cell(ofType: .jungle), Cell(ofType: .water), Cell(ofType: .water), Cell(ofType: .jungle)],
// Ligne 8
[Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .elephant)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .wolf)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .leopard)),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .rat))],
// Ligne 9
[Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .cat)),
Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .jungle),
Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .dog)), Cell(ofType: .jungle)],
// Ligne 10
[Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .tiger)),
Cell(ofType: .jungle), Cell(ofType: .trap), Cell(ofType: .den), Cell(ofType: .trap),
Cell(ofType: .jungle), Cell(ofType: .jungle, withPiece: Piece(withOwner: .player2, andAnimal: .lion))]
]
if let board = Board(withGrid: initialBoardConfiguration) {
// Afficher le plateau de jeu
print(board)
} else {
print("Erreur lors de l'initialisation du plateau de jeu.")
}
// Initialisez un Board avec cette configuration
if var board = Board(withGrid: initialBoardConfiguration) {
print("Plateau initial:")
print(board) // Affichez l'état initial du plateau
// Testez countPieces(of:)
let player1PieceCount = board.countPieces(of: .player1)
print("Nombre de pièces pour le Joueur 1: \(player1PieceCount)")
let player2PieceCount = board.countPieces(of: .player2)
print("Nombre de pièces pour le Joueur 2: \(player2PieceCount)")
// Testez countPieces()
let (countPlayer1, countPlayer2) = board.countPieces()
print("Comptage total - Joueur 1: \(countPlayer1), Joueur 2: \(countPlayer2)")
// Testez removePiece(atRow:andColumn:)
let removeResult = board.removePiece(atRow: 0, andColumn: 0)
print("Résultat de la suppression : \(removeResult)")
print(board) // Affichez le plateau après suppression
// Testez insert(piece:atRow:andColumn:)
let insertResult = board.insert(piece: Piece(withOwner: .player1, andAnimal: .lion), atRow: 0, andColumn: 0)
print("Résultat de l'insertion : \(insertResult)")
print(board) // Affichez le plateau après insertion
} else {
print("Erreur lors de l'initialisation du plateau de jeu.")
}