New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistence #19
Persistence #19
Conversation
ruihan00
commented
Mar 21, 2024
•
edited
edited
- Added sqlite3 persistence
- Added Storage manager as a bridge between database and game
- Added json data file for 1 level
- Added loading of map in view controller (temporary to test)
- Added sprite size parameters to obstacle , tool entity
- Added sprite size health parameters to monster
…istence merge with latest changes
// | ||
|
||
import Foundation | ||
struct LevelPersistable: Encodable, Decodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think can just shorten into Codable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
let entityPersistabls = self.database.getEntityPersistables(levelId: id) | ||
return Level(levelPersistable: levelPersistable, entityPersistables: entityPersistabls) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entityPersistable
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
private let entityTable = Table("entity") | ||
private var db: Connection? | ||
|
||
init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use a singleton design pattern for Database
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I previously got marked down for singleton design pattern so not sure about this
self.entities = entities | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe can group LevelData
and data.json
into 1 folder for organization, since they both only deal with preloaded levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!