Files
ashen-realms/apps/api/src/characters/entities/character.entity.ts
Bastian Wagner af9d422e8b feat(loot): add item, loot table, and combat reward entities
Declares every new TypeORM entity Slice 0.4 needs (ItemDefinition,
CharacterItem, LootTable, LootTableEntry, CombatReward, CombatRewardItem)
plus the ItemType/EquipmentSlot/ItemRarity enums, and adds the two columns
existing entities gain: Character.silver and MonsterDefinition.lootTableId.
No migration SQL or service logic yet - just schema declarations backed by
a metadata-driven schema spec.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 23:29:30 +02:00

53 lines
1.3 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { LocationDefinition } from '../../world/entities/location-definition.entity';
@Entity({ name: 'characters' })
export class Character {
@PrimaryGeneratedColumn('uuid', { name: 'id' })
id!: string;
@Column({ name: 'name', type: 'varchar', length: 150 })
name!: string;
@Column({ name: 'level', type: 'integer' })
level!: number;
@Column({ name: 'experience', type: 'integer' })
experience!: number;
@Column({ name: 'silver', type: 'integer' })
silver!: number;
@Column({ name: 'base_hp', type: 'integer' })
baseHp!: number;
@Column({ name: 'base_attack', type: 'integer' })
baseAttack!: number;
@Column({ name: 'current_hp', type: 'integer' })
currentHp!: number;
@Column({ name: 'current_location_id', type: 'uuid' })
currentLocationId!: string;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt!: Date;
@ManyToOne(() => LocationDefinition, (location) => location.characters, {
onDelete: 'RESTRICT',
})
@JoinColumn({ name: 'current_location_id' })
currentLocation!: LocationDefinition;
}