Skip to content
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

Merged
merged 8 commits into from Mar 22, 2024
Merged

Persistence #19

merged 8 commits into from Mar 22, 2024

Conversation

ruihan00
Copy link
Contributor

@ruihan00 ruihan00 commented Mar 21, 2024

  • 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

star-dash/star-dash/Persistence/EntityPersistable.swift Outdated Show resolved Hide resolved
star-dash/star-dash/Persistence/data.json Outdated Show resolved Hide resolved
//

import Foundation
struct LevelPersistable: Encodable, Decodable {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Comment on lines 19 to 20
let entityPersistabls = self.database.getEntityPersistables(levelId: id)
return Level(levelPersistable: levelPersistable, entityPersistables: entityPersistabls)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entityPersistable typo

Copy link
Contributor Author

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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
}

}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Contributor

@Junyi00 Junyi00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@ruihan00 ruihan00 merged commit 11cc529 into main Mar 22, 2024
1 check failed
@jasonqiu212 jasonqiu212 deleted the feat/persistence branch March 27, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants