phase 1: refactor directory structure (value-objects, factions, characters)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Faction value type — a named group that characters can belong to.
|
||||
*
|
||||
* Invariant: faction names are non-empty trimmed strings.
|
||||
*/
|
||||
export class Faction {
|
||||
#value: string;
|
||||
|
||||
private constructor(value: string) {
|
||||
this.#value = value;
|
||||
}
|
||||
|
||||
static create(value: string): Faction {
|
||||
const trimmed = value.trim();
|
||||
if (trimmed.length === 0) {
|
||||
throw new Error('Faction name cannot be empty');
|
||||
}
|
||||
return new Faction(trimmed);
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return this.#value;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `Faction(${this.#value})`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user