|
|
|
@ -37,17 +37,7 @@ class IngameVM: ObservableObject {
|
|
|
|
|
var currentBoard: Board
|
|
|
|
|
|
|
|
|
|
@Published
|
|
|
|
|
var paused: Bool = false {
|
|
|
|
|
didSet {
|
|
|
|
|
Task.detached(priority: .userInitiated) {
|
|
|
|
|
if (self.paused) {
|
|
|
|
|
// TODO
|
|
|
|
|
} else {
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var result: Connect4Core.Result = .notFinished
|
|
|
|
|
|
|
|
|
|
private var running: Bool = false
|
|
|
|
|
|
|
|
|
@ -80,11 +70,10 @@ class IngameVM: ObservableObject {
|
|
|
|
|
self.scene = GameScene(viewModel: self)
|
|
|
|
|
|
|
|
|
|
game.addGameOverListener { board, result, player in
|
|
|
|
|
print("game over")
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.currentPlayer = .noOne
|
|
|
|
|
self.result = result
|
|
|
|
|
}
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
game.addGameChangedListener { game, result in
|
|
|
|
|
if game.players.contains(where: { $0.value is ReplayPlayer }) {
|
|
|
|
@ -117,10 +106,6 @@ class IngameVM: ObservableObject {
|
|
|
|
|
withFolderName: Persistance.saveDirectory
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
game.addGameStartedListener { board in
|
|
|
|
|
print("game started")
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
game.addBoardChangedListener { board, lastCell in
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.currentBoard = board
|
|
|
|
@ -152,15 +137,17 @@ class IngameVM: ObservableObject {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static func playerOf(settings: PlayerSettingsVM, id: Owner) -> Player? {
|
|
|
|
|
let name = settings.name.nilIfEmpty ?? String(localized: String.LocalizationValue(settings.type.baseTranslationKey))
|
|
|
|
|
|
|
|
|
|
return switch (settings.type) {
|
|
|
|
|
case .Human:
|
|
|
|
|
HumanPlayer(withName: settings.name, andId: id)
|
|
|
|
|
HumanPlayer(withName: name, andId: id)
|
|
|
|
|
case .AIRandom:
|
|
|
|
|
RandomPlayer(withName: settings.name, andId: id)
|
|
|
|
|
RandomPlayer(withName: name, andId: id)
|
|
|
|
|
case .AIFinnishHim:
|
|
|
|
|
FinnishHimPlayer(withName: settings.name, andId: id)
|
|
|
|
|
FinnishHimPlayer(withName: name, andId: id)
|
|
|
|
|
case .AISimpleNegaMax:
|
|
|
|
|
SimpleNegaMaxPlayer(withName: settings.name, andId: id)
|
|
|
|
|
SimpleNegaMaxPlayer(withName: name, andId: id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|