|
|
|
@ -51,19 +51,10 @@ class GameScene : SKScene {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initializeBoard(game.board)
|
|
|
|
|
//displayBoard(game.board)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initializeBoard(_ board: Board) {
|
|
|
|
|
|
|
|
|
|
/*for (lineIndex, currentLine) in game.board.grid.enumerated() {
|
|
|
|
|
for (cellIndex, currentCell) in currentLine.enumerated() {
|
|
|
|
|
if (currentCell.piece != nil){
|
|
|
|
|
pieces[currentCell.piece!.owner]?[currentCell.piece!.animal]?.cellPosition = CGPoint(x: cellIndex, y: lineIndex)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
for (lineIndex, currentLine) in game.board.grid.enumerated() {
|
|
|
|
|
for (cellIndex, currentCell) in currentLine.enumerated() {
|
|
|
|
|
if let piece = currentCell.piece {
|
|
|
|
@ -73,58 +64,6 @@ class GameScene : SKScene {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*var new_array = game.board.grid.flatMap(pieces => {
|
|
|
|
|
pieces.forEach( => {
|
|
|
|
|
if (joueur1.pieces.includes(piece)) {
|
|
|
|
|
console.log(`La pièce ${piece} appartient à joueur1`);
|
|
|
|
|
} else if (joueur2.pieces.includes(piece)) {
|
|
|
|
|
console.log(`La pièce ${piece} appartient à joueur2`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// Retourner les pièces pour le new_array (si nécessaire)
|
|
|
|
|
return pieces;
|
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
let player1AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat]
|
|
|
|
|
let player1AnimalsLigne2: [Animal] = [.cat, .dog]
|
|
|
|
|
let player1AnimalsLigne3: [Animal] = [.leopard, .lion]
|
|
|
|
|
|
|
|
|
|
let player2AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat]
|
|
|
|
|
let player2AnimalsLigne2: [Animal] = [.cat, .dog]
|
|
|
|
|
let player2AnimalsLigne3: [Animal] = [.leopard, .lion]
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne1.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -2)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne2.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -3)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne3.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -3)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne1.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne2.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne3.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
|
|
|