From fc260dc97c539006c4eb94a24863134d09655017 Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Sun, 14 Jun 2026 11:36:37 +0100 Subject: [PATCH] phase 1: refactor directory structure (value-objects, factions, characters) --- src/Character.ts | 12 ++++++------ src/HealingObject.ts | 2 +- src/character-creation.spec.ts | 2 +- src/{ => characters}/CharacterState.ts | 8 ++++---- src/damage-and-health.spec.ts | 2 +- src/factions.spec.ts | 4 ++-- src/{ => factions}/Faction.ts | 0 src/healing.spec.ts | 2 +- src/levels.spec.ts | 2 +- src/magical-objects.spec.ts | 2 +- src/{ => value-objects}/Health.ts | 0 src/{ => value-objects}/Level.ts | 0 src/{ => value-objects}/Status.ts | 0 13 files changed, 18 insertions(+), 18 deletions(-) rename src/{ => characters}/CharacterState.ts (63%) rename src/{ => factions}/Faction.ts (100%) rename src/{ => value-objects}/Health.ts (100%) rename src/{ => value-objects}/Level.ts (100%) rename src/{ => value-objects}/Status.ts (100%) diff --git a/src/Character.ts b/src/Character.ts index 054dcb8..b7c81a2 100644 --- a/src/Character.ts +++ b/src/Character.ts @@ -4,12 +4,12 @@ * "I can't believe it's not Haskell": invariants at boundaries. * State is encapsulated in a CharacterState record type. */ -import { Health } from './Health.ts'; -import { Level } from './Level.ts'; -import type { Status } from './Status.ts'; -import { StatusAlive, StatusDead } from './Status.ts'; -import type { CharacterState } from './CharacterState.ts'; -import type { Faction } from './Faction.ts'; +import { Health } from './value-objects/Health.ts'; +import { Level } from './value-objects/Level.ts'; +import type { Status } from './value-objects/Status.ts'; +import { StatusAlive, StatusDead } from './value-objects/Status.ts'; +import type { CharacterState } from './characters/CharacterState.ts'; +import type { Faction } from './factions/Faction.ts'; import type { DamageDealer } from './magical-objects/magical-object-types.ts'; import type { Healer } from './magical-objects/magical-object-types.ts'; diff --git a/src/HealingObject.ts b/src/HealingObject.ts index 9ce47e9..4567326 100644 --- a/src/HealingObject.ts +++ b/src/HealingObject.ts @@ -7,7 +7,7 @@ */ import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; import { MagicalObject } from './MagicalObject.ts'; import type { Healer } from './magical-objects/magical-object-types.ts'; diff --git a/src/character-creation.spec.ts b/src/character-creation.spec.ts index 0f8e3b1..bb1c118 100644 --- a/src/character-creation.spec.ts +++ b/src/character-creation.spec.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; describe('CharacterCreation', () => { describe('initial health', () => { diff --git a/src/CharacterState.ts b/src/characters/CharacterState.ts similarity index 63% rename from src/CharacterState.ts rename to src/characters/CharacterState.ts index 5b228a3..6a4e2af 100644 --- a/src/CharacterState.ts +++ b/src/characters/CharacterState.ts @@ -4,10 +4,10 @@ * Groups the five character properties into a single value type, * keeping the Character constructor at one parameter. */ -import type { Health } from './Health.ts'; -import type { Level } from './Level.ts'; -import type { Status } from './Status.ts'; -import type { Faction } from './Faction.ts'; +import type { Health } from '../value-objects/Health.ts'; +import type { Level } from '../value-objects/Level.ts'; +import type { Status } from '../value-objects/Status.ts'; +import type { Faction } from '../factions/Faction.ts'; export type CharacterState = { readonly name: string; diff --git a/src/damage-and-health.spec.ts b/src/damage-and-health.spec.ts index 6febdff..8210d3f 100644 --- a/src/damage-and-health.spec.ts +++ b/src/damage-and-health.spec.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; describe('DamageAndHealth', () => { describe('DamageReducesHealth', () => { diff --git a/src/factions.spec.ts b/src/factions.spec.ts index 7e6e37e..0085bf0 100644 --- a/src/factions.spec.ts +++ b/src/factions.spec.ts @@ -1,8 +1,8 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Faction } from './Faction.ts'; -import { Level } from './Level.ts'; +import { Faction } from './factions/Faction.ts'; +import { Level } from './value-objects/Level.ts'; describe('Factions', () => { const hero = () => Character.create({ name: 'hero', level: Level.create(1) }); diff --git a/src/Faction.ts b/src/factions/Faction.ts similarity index 100% rename from src/Faction.ts rename to src/factions/Faction.ts diff --git a/src/healing.spec.ts b/src/healing.spec.ts index 05a5169..9761a77 100644 --- a/src/healing.spec.ts +++ b/src/healing.spec.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; describe('Healing', () => { describe('SelfHealIncreasesHealth', () => { diff --git a/src/levels.spec.ts b/src/levels.spec.ts index 3ae288f..ded8b0f 100644 --- a/src/levels.spec.ts +++ b/src/levels.spec.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; describe('Levels', () => { describe('CloseLevelNoModifier', () => { diff --git a/src/magical-objects.spec.ts b/src/magical-objects.spec.ts index 6a6fc36..02dd90b 100644 --- a/src/magical-objects.spec.ts +++ b/src/magical-objects.spec.ts @@ -1,7 +1,7 @@ import fc from 'fast-check'; import { describe, it } from 'vitest'; import { Character } from './Character.ts'; -import { Level } from './Level.ts'; +import { Level } from './value-objects/Level.ts'; import { MagicalWeapon } from './MagicalWeapon.ts'; import { HealingObject } from './HealingObject.ts'; diff --git a/src/Health.ts b/src/value-objects/Health.ts similarity index 100% rename from src/Health.ts rename to src/value-objects/Health.ts diff --git a/src/Level.ts b/src/value-objects/Level.ts similarity index 100% rename from src/Level.ts rename to src/value-objects/Level.ts diff --git a/src/Status.ts b/src/value-objects/Status.ts similarity index 100% rename from src/Status.ts rename to src/value-objects/Status.ts