TCAminesweeper
TCAminesweeper copied to clipboard
Update to Current Version of Composable Architecture (0.33.1)
What a great job you've done! This is a really well thought-through project, and covers so much ground. So hats off!
I was able to update your project to use 0.33.1 instead of 0.15.0 with a very small change:
// url: "https://github.com/pointfreeco/swift-composable-architecture", .exact("0.15.0")), url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.33.1"),
you could also substitute "0.9.0" here instead of "0.33.1" - it will use the highest version under 1.0 it finds
It looks like the definition of IdentifiedArray changed after 0.15.0 (I assume this is why you froze the project there).
There were only a few lines that needed to be changed - you just need to add id:
as a label when updating an element of the identifiable array. You also need to adjust for optionality - hence the ?
s. I marked the four affected lines below with ** delimiters
in Core/MinefieldCore.swift
public extension MinefieldState {
mutating func reveal(_ index: Int) {
self.reveal([index])
}
mutating func reveal(_ indexes: Set<Int>) {
gridInfo.revealed.formUnion(indexes)
gridInfo.flagged.subtract(indexes)
** indexes.forEach { grid.content[id: $0]?.isHidden = false } **
}
mutating func setTile(_ newTile: Tile, for index: Int) {
**grid.content[id: index]?.tile = newTile**
}
mutating func setMarked(_ isMarked: Bool, for index: Int) {
** grid.content[id: index]?.isMarked = isMarked **
if isMarked {
gridInfo.flagged.insert(index)
} else {
gridInfo.flagged.remove(index)
}
}
mutating func setWrongFlag(for index: Int) {
var tileState = grid.content[index]
tileState.isMarked = true
tileState.tile = .mine
tileState.isHidden = false
** grid.content[id: index] = tileState **
}
}
Thanks for providing this project.