Files
ashen-realms/apps/api/src/items/entities/item-definition.entity.ts
Bastian Wagner 081c9f83f9 docs
2026-08-22 16:41:47 +02:00

95 lines
2.4 KiB
TypeScript

import {
Column,
CreateDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { EquipmentSlot } from '../equipment-slot.enum';
import { ItemRarity } from '../item-rarity.enum';
import { ItemType } from '../item-type.enum';
import { LootCategory } from '../loot-category.enum';
@Entity({ name: 'item_definitions' })
@Index('IDX_item_definitions_key', ['key'], { unique: true })
export class ItemDefinition {
@PrimaryGeneratedColumn('uuid', { name: 'id' })
id!: string;
@Column({ name: 'key', type: 'varchar', length: 100 })
key!: string;
@Column({ name: 'name', type: 'varchar', length: 150 })
name!: string;
@Column({ name: 'description', type: 'text' })
description!: string;
@Column({
name: 'type',
type: 'enum',
enum: ItemType,
enumName: 'item_type_enum',
})
type!: ItemType;
@Column({
name: 'equipment_slot',
type: 'enum',
enum: EquipmentSlot,
enumName: 'equipment_slot_enum',
nullable: true,
})
equipmentSlot!: EquipmentSlot | null;
@Column({
name: 'rarity',
type: 'enum',
enum: ItemRarity,
enumName: 'item_rarity_enum',
})
rarity!: ItemRarity;
// Which carrying bucket this counts against (Playable Slice 0.7.5 §4).
// Null for everything that is not a trade good -- equipment and consumables
// are deliberately unaffected by bag capacity (spec §8).
@Column({
name: 'loot_category',
type: 'enum',
enum: LootCategory,
enumName: 'loot_category_enum',
nullable: true,
})
lootCategory!: LootCategory | null;
@Column({ name: 'tier', type: 'integer' })
tier!: number;
@Column({ name: 'weapon_damage', type: 'integer' })
weaponDamage!: number;
@Column({ name: 'bonus_hp', type: 'integer' })
bonusHp!: number;
@Column({ name: 'bonus_attack', type: 'integer' })
bonusAttack!: number;
@Column({ name: 'bonus_armor', type: 'integer' })
bonusArmor!: number;
// Always 0 in Slice 0.4: there are no merchants, and the balancing doc's
// Grenzmarken table lists purchase prices, not sell prices.
@Column({ name: 'sell_price', type: 'integer' })
sellPrice!: number;
@Column({ name: 'icon_path', type: 'varchar', length: 255 })
iconPath!: string;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
createdAt!: Date;
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
updatedAt!: Date;
}