Match3Kit
Library for simple Match3 games.
It can work with a solid grid of figures and spill them only in columns.

Example
Create the enum for all kinds of figures:
typealias MyGrid = Grid<Shape>
typealias MyController = Controller<Shape, Generator<Shape>, Matcher<Shape>>
enum Shapes: String, GridFilling {
case square
case circle
case triangle
var pattern: Pattern {
Pattern(indices: [])
}
}
Create a grid controller with configurations:
let controller = MyController(
size: Size(columns: 6, rows: 6),
basic: [.square, .circle, .triangle],
bonuse: [],
obstacles: []
)
Create UI based on the grid that the controller generated:
for index in allIndices {
let cell = controller.grid.cell(at: index)
setupUI(for: cell, at: index)
}
Swap figures after the user interaction:
func swap(source: Index, target: Index) {
if controller.canSwapCell(at: source, with: target) {
swapUI(source, target)
if controller.shouldSwapCell(at: source, with: target) {
let indices = controller.swapAndMatchCell(at: source, with: target)
let match = controller.match(indices: indices, swapIndices: [source, target], refill: .spill)
remove(indices)
spawn(match.spawned)
spill(match.removed)
} else {
swapUI(source, target)
}
}
}
Used in:
Forest walk

TODO:
- Add more examples with bonuses
- Add a demo project
Match3Kit
Library for simple Match3 games. It can work with a solid grid of figures and spill them only in columns.
Example
Create the enum for all kinds of figures:
Create a grid controller with configurations:
Create UI based on the grid that the controller generated:
Swap figures after the user interaction:
Used in:
Forest walk
TODO: