diff --git a/server/src/network/stateSerializer.ts b/server/src/network/stateSerializer.ts index d1b600a..1052207 100644 --- a/server/src/network/stateSerializer.ts +++ b/server/src/network/stateSerializer.ts @@ -1,13 +1,27 @@ import type { EntityState, WorldState, StateUpdate, - Position, Movement, Appearance, Needs, NPCBrain, PlayerControlled, SocialState, + Position, Movement, Appearance, Needs, NPCBrain, PlayerControlled, SocialState, Stats, } from '@dflike/shared'; import { TILE_SIZE } from '@dflike/shared'; import type { World } from '../ecs/World.js'; import type { GameMap } from '../map/GameMap.js'; +import { getEffectiveStat } from '../systems/statHelpers.js'; export function serializeEntity(world: World, entityId: number): EntityState { const socialState = world.getComponent(entityId, 'socialState'); + const statsComponent = world.getComponent(entityId, 'stats'); + const stats = statsComponent ? { + strength: getEffectiveStat(world, entityId, 'strength'), + dexterity: getEffectiveStat(world, entityId, 'dexterity'), + constitution: getEffectiveStat(world, entityId, 'constitution'), + intelligence: getEffectiveStat(world, entityId, 'intelligence'), + perception: getEffectiveStat(world, entityId, 'perception'), + sociability: getEffectiveStat(world, entityId, 'sociability'), + courage: getEffectiveStat(world, entityId, 'courage'), + curiosity: getEffectiveStat(world, entityId, 'curiosity'), + empathy: getEffectiveStat(world, entityId, 'empathy'), + temperament: getEffectiveStat(world, entityId, 'temperament'), + } : undefined; return { id: entityId, position: world.getComponent(entityId, 'position')!, @@ -22,6 +36,7 @@ export function serializeEntity(world: World, entityId: number): EntityState { partnerId: socialState.partnerId, outcome: socialState.outcome, } : undefined, + stats, }; }