import fc from 'fast-check';
import { describe, it } from 'vitest';
import { Character } from './characters/Character.ts';
import { Level } from './value-objects/Level.ts';

describe('CharacterCreation', () => {
  describe('initial health', () => {
    it('property: new character has health 1000', () => {
      fc.assert(
        fc.property(fc.string({ minLength: 1, maxLength: 50 }), (name) => {
          const c = Character.create({ name, level: Level.create(1) });
          return c.health.value === 1000;
        }),
      );
    });

    it('property: health is always 1000 at creation regardless of level', () => {
      fc.assert(
        fc.property(
          fc.string({ minLength: 1, maxLength: 50 }),
          fc.integer({ min: 1, max: 10 }),
          (name, level) => {
            const c = Character.create({ name, level: Level.create(level) });
            return c.health.value === 1000;
          },
        ),
      );
    });
  });

  describe('initial status', () => {
    it('property: new character is always alive', () => {
      fc.assert(
        fc.property(fc.string({ minLength: 1, maxLength: 50 }), (name) => {
          const c = Character.create({ name, level: Level.create(1) });
          return c.status.kind === 'alive';
        }),
      );
    });
  });

  describe('initial level', () => {
    it('property: character stores the level given at creation', () => {
      fc.assert(
        fc.property(
          fc.string({ minLength: 1, maxLength: 50 }),
          fc.integer({ min: 1, max: 10 }),
          (name, level) => {
            const c = Character.create({ name, level: Level.create(level) });
            return c.level.value === level;
          },
        ),
      );
    });
  });

  describe('initial factions', () => {
    it('property: new character belongs to no factions', () => {
      fc.assert(
        fc.property(fc.string({ minLength: 1, maxLength: 50 }), (name) => {
          const c = Character.create({ name, level: Level.create(1) });
          return c.factions.size === 0;
        }),
      );
    });
  });
});
