@@ -442,6 +442,93 @@ struct DifficultyBudgetTests {
442442 }
443443}
444444
445+ // MARK: - Player
446+
447+ struct PlayerTests {
448+
449+ @Test func playerIsValueType( ) {
450+ var player1 = Player (
451+ name: " Aldric " , maxHP: 6 , maxStress: 6 ,
452+ evasion: 12 , thresholdMajor: 8 , thresholdSevere: 15 , armorSlots: 3
453+ )
454+ let player2 = player1
455+ player1. name = " Modified "
456+ #expect( player2. name == " Aldric " )
457+ }
458+
459+ @Test func playerCodableRoundTrip( ) throws {
460+ let player = Player (
461+ name: " Sera " , maxHP: 8 , maxStress: 6 ,
462+ evasion: 14 , thresholdMajor: 10 , thresholdSevere: 18 , armorSlots: 4
463+ )
464+ let data = try JSONEncoder ( ) . encode ( player)
465+ let decoded = try JSONDecoder ( ) . decode ( Player . self, from: data)
466+
467+ #expect( decoded. id == player. id)
468+ #expect( decoded. name == " Sera " )
469+ #expect( decoded. maxHP == 8 )
470+ #expect( decoded. maxStress == 6 )
471+ #expect( decoded. evasion == 14 )
472+ #expect( decoded. thresholdMajor == 10 )
473+ #expect( decoded. thresholdSevere == 18 )
474+ #expect( decoded. armorSlots == 4 )
475+ }
476+
477+ @Test func asConfigPreservesAllFields( ) {
478+ let player = Player (
479+ name: " Torven " , maxHP: 10 , maxStress: 5 ,
480+ evasion: 11 , thresholdMajor: 7 , thresholdSevere: 14 , armorSlots: 2
481+ )
482+ let config = player. asConfig ( )
483+
484+ #expect( config. id == player. id)
485+ #expect( config. name == player. name)
486+ #expect( config. maxHP == player. maxHP)
487+ #expect( config. maxStress == player. maxStress)
488+ #expect( config. evasion == player. evasion)
489+ #expect( config. thresholdMajor == player. thresholdMajor)
490+ #expect( config. thresholdSevere == player. thresholdSevere)
491+ #expect( config. armorSlots == player. armorSlots)
492+ }
493+ }
494+
495+ // MARK: - Party
496+
497+ struct PartyTests {
498+
499+ @Test func partyIsValueType( ) {
500+ var party1 = Party ( name: " The Wanderers " )
501+ let party2 = party1
502+ party1. name = " Modified "
503+ #expect( party2. name == " The Wanderers " )
504+ }
505+
506+ @Test func partyCodableRoundTrip( ) throws {
507+ let ids = [ UUID ( ) , UUID ( ) , UUID ( ) ]
508+ let party = Party ( name: " Ironclad Company " , playerIDs: ids)
509+ let data = try JSONEncoder ( ) . encode ( party)
510+ let decoded = try JSONDecoder ( ) . decode ( Party . self, from: data)
511+
512+ #expect( decoded. id == party. id)
513+ #expect( decoded. name == " Ironclad Company " )
514+ #expect( decoded. playerIDs == ids)
515+ }
516+
517+ @Test func playerIDsOrderIsPreserved( ) throws {
518+ let ids = ( 0 ..< 5 ) . map { _ in UUID ( ) }
519+ let party = Party ( name: " Order Test " , playerIDs: ids)
520+ let data = try JSONEncoder ( ) . encode ( party)
521+ let decoded = try JSONDecoder ( ) . decode ( Party . self, from: data)
522+
523+ #expect( decoded. playerIDs == ids)
524+ }
525+
526+ @Test func defaultPartyHasNoPlayers( ) {
527+ let party = Party ( name: " Empty " )
528+ #expect( party. playerIDs. isEmpty)
529+ }
530+ }
531+
445532// MARK: - DaggerheartEnvironment
446533
447534struct EnvironmentModelTests {
0 commit comments