feat: architecture DDD hexagonale + tooling Vite/TypeScript
Migration complète du monolithe vers une architecture en couches : - Domain : entités, value objects, services purs, ports - Application : CQRS avec CommandBus/QueryBus, 15+ commandes, 9 requêtes - Tooling : Vite + TypeScript strict + Vitest + path aliases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
59
src/domain/entities/Enclos.ts
Normal file
59
src/domain/entities/Enclos.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import type { Dragodinde } from './Dragodinde';
|
||||
import { createDragodinde } from './Dragodinde';
|
||||
import type { GaugeType } from '@domain/value-objects/GaugeType';
|
||||
|
||||
export const MAX_DD = 10;
|
||||
export const MAX_ENCLOS = 6;
|
||||
export const MAX_GAUGES = 2;
|
||||
|
||||
export interface GaugeRecharge {
|
||||
atSec: number; // secondes écoulées au moment de la recharge
|
||||
level: number; // nouveau niveau de jauge
|
||||
}
|
||||
|
||||
export interface TimerData {
|
||||
running: boolean;
|
||||
startTime: number | null;
|
||||
pausedAt: number | null;
|
||||
pausedMs: number;
|
||||
snapGauges: Record<string, number>;
|
||||
snapStats: Record<string, Record<string, number>>;
|
||||
gaugeRecharges: Record<string, GaugeRecharge[]>;
|
||||
}
|
||||
|
||||
export interface Enclos {
|
||||
readonly id: number;
|
||||
name: string;
|
||||
activeGauges: GaugeType[];
|
||||
gaugeLevels: Record<GaugeType, number>;
|
||||
dragodindes: Dragodinde[];
|
||||
nextDdId: number;
|
||||
timer: TimerData;
|
||||
alerted: Record<string, boolean>;
|
||||
}
|
||||
|
||||
export function createEnclos(id: number, name?: string): Enclos {
|
||||
return {
|
||||
id,
|
||||
name: name ?? `Enclos ${id}`,
|
||||
activeGauges: [],
|
||||
gaugeLevels: { baffeur: 0, caresseur: 0, foudroyeur: 0, abreuvoir: 0, dragofesse: 0, mangeoire: 0 },
|
||||
dragodindes: [],
|
||||
nextDdId: 1,
|
||||
timer: { running: false, startTime: null, pausedAt: null, pausedMs: 0, snapGauges: {}, snapStats: {}, gaugeRecharges: {} },
|
||||
alerted: {},
|
||||
};
|
||||
}
|
||||
|
||||
export function addDragodinde(enc: Enclos): Enclos {
|
||||
if (enc.dragodindes.length >= MAX_DD) return enc;
|
||||
const usedIds = new Set(enc.dragodindes.map(d => d.id));
|
||||
let newId = 1;
|
||||
while (usedIds.has(newId)) newId++;
|
||||
const dd = createDragodinde(newId);
|
||||
return { ...enc, dragodindes: [...enc.dragodindes, dd], nextDdId: newId + 1 };
|
||||
}
|
||||
|
||||
export function removeDragodinde(enc: Enclos, ddId: number): Enclos {
|
||||
return { ...enc, dragodindes: enc.dragodindes.filter(d => d.id !== ddId) };
|
||||
}
|
||||
Reference in New Issue
Block a user