Add Codable to session types and auto-number duplicate adversaries#19
Merged
Add Codable to session types and auto-number duplicate adversaries#19
Conversation
- preserve spotlightedSlotID across Codable round-trip - fix dead `default:` in adversary counter lookups - clarify definitionSnapshotDate doc comment - rename mixedAdversaries test to camelCase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AdversaryState,PlayerState,EnvironmentState— addsCodableconformance; all fields are standard types so synthesis handles everythingEncounterSession— addsCodablevia customencode/decode(needed because backing state lives in private arrays); uses@MainActor Codableisolated conformance for Swift 6.2 correctnessdefinitionID: UUID?anddefinitionSnapshotDate: Date?onEncounterSession— set bymake(from:using:), used by the registry to detect stale sessions;nilfor directly-constructed sessionsmake(from:using:)now setscustomNameto"<Name> 1","<Name> 2", … when the same adversary ID appears more than once; single-copy adversaries keepcustomName == nilspotlightedSlotIDpreserved across encode/decode so mid-encounter sessions restore with the active spotlight intactCloses #16, closes #17
Test plan
swift build --target DHKitpassesswift test --filter DHKitTests— 92 tests pass (13 new)swift test --filter DHModelsTests— 70 tests pass (no regressions)./Scripts/format.shexits clean