Skip to content

Add Codable to session types and auto-number duplicate adversaries#19

Merged
gwillish merged 2 commits intomainfrom
codable-session-types
Apr 4, 2026
Merged

Add Codable to session types and auto-number duplicate adversaries#19
gwillish merged 2 commits intomainfrom
codable-session-types

Conversation

@gwillish
Copy link
Copy Markdown
Owner

@gwillish gwillish commented Apr 4, 2026

Summary

  • AdversaryState, PlayerState, EnvironmentState — adds Codable conformance; all fields are standard types so synthesis handles everything
  • EncounterSession — adds Codable via custom encode/decode (needed because backing state lives in private arrays); uses @MainActor Codable isolated conformance for Swift 6.2 correctness
  • definitionID: UUID? and definitionSnapshotDate: Date? on EncounterSession — set by make(from:using:), used by the registry to detect stale sessions; nil for directly-constructed sessions
  • Auto-numbered duplicate adversariesmake(from:using:) now sets customName to "<Name> 1", "<Name> 2", … when the same adversary ID appears more than once; single-copy adversaries keep customName == nil
  • spotlightedSlotID preserved across encode/decode so mid-encounter sessions restore with the active spotlight intact

Closes #16, closes #17

Test plan

  • swift build --target DHKit passes
  • swift test --filter DHKitTests — 92 tests pass (13 new)
  • swift test --filter DHModelsTests — 70 tests pass (no regressions)
  • ./Scripts/format.sh exits clean
  • Linux CI passes

gwillish added 2 commits April 4, 2026 12:56
- preserve spotlightedSlotID across Codable round-trip
- fix dead `default:` in adversary counter lookups
- clarify definitionSnapshotDate doc comment
- rename mixedAdversaries test to camelCase
@gwillish gwillish merged commit 1ca0966 into main Apr 4, 2026
2 checks passed
@gwillish gwillish deleted the codable-session-types branch April 4, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant