tridiak/spellspm
Simple package which wraps an SQLite database containing Pathfinder 1e spells.
Intro
Simple package which wraps an SQLite database containing Pathfinder 1e spells.
This package assumes the developer has some knowledge of the Pathfinder RPG.
Installation
SPM
In XCode, ``File > Swift Packages > Add Package Dependency``.
Structs and Classes
Main classes and structs.
actor SpellDBAccessClass that that accesses the SQLite database. Uses C api.
class SpellClass that contains the metadata for a spell. Has an extension which provides a lot of convenince accessors.
actor SpellStorageSimple storage class for the Spell class.
struct SpellFieldsStruct with properties that match the SQLite database spell columns.
extension StringStuffUtility methods for String.
Usage
Download macOS demo app here demonstrating basic usage of the SPM.
From the demo app:
struct SpellData : Identifiable {
let id = UUID()
let name : String
var school : SpellSPM.SpellSchools? = nil
}
@MainActor
@Observable
class SpellListModel {
let spellStore : SpellSPM.SpellStorage
let db : SpellSPM.SpellDBAccess
init() {
spellStore = try! SpellStorage()
db = try! SpellSPM.SpellDBAccess()
}
var spells : [SpellData] = []
func reloadSpells() {
Task {
guard let s = try? await db.getAllNames(force: true) else { return }
self.spells = s.map({ S in
return SpellData(name: S)
})
}
}
}Package Metadata
Repository: tridiak/spellspm
Default branch: main
README: README.md