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>
This commit is contained in:
56
apps/api/src/rewards/entities/combat-reward-item.entity.ts
Normal file
56
apps/api/src/rewards/entities/combat-reward-item.entity.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { CharacterItem } from '../../items/entities/character-item.entity';
|
||||
import { ItemDefinition } from '../../items/entities/item-definition.entity';
|
||||
import { CombatReward } from './combat-reward.entity';
|
||||
|
||||
/**
|
||||
* What this specific combat dropped.
|
||||
*
|
||||
* Needed because `CharacterItem.quantity` is a running stack total: after a
|
||||
* duplicate drop it no longer says how much *this* victory granted, and a
|
||||
* refreshed reward screen must replay the original result (spec §25, §48).
|
||||
*/
|
||||
@Entity({ name: 'combat_reward_items' })
|
||||
@Index('IDX_combat_reward_items_reward', ['combatRewardId'])
|
||||
@Index('IDX_combat_reward_items_reward_item', ['combatRewardId', 'itemDefinitionId'], {
|
||||
unique: true,
|
||||
})
|
||||
export class CombatRewardItem {
|
||||
@PrimaryGeneratedColumn('uuid', { name: 'id' })
|
||||
id!: string;
|
||||
|
||||
@Column({ name: 'combat_reward_id', type: 'uuid' })
|
||||
combatRewardId!: string;
|
||||
|
||||
@Column({ name: 'character_item_id', type: 'uuid' })
|
||||
characterItemId!: string;
|
||||
|
||||
@Column({ name: 'item_definition_id', type: 'uuid' })
|
||||
itemDefinitionId!: string;
|
||||
|
||||
@Column({ name: 'quantity', type: 'integer' })
|
||||
quantity!: number;
|
||||
|
||||
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => CombatReward, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'combat_reward_id' })
|
||||
combatReward!: CombatReward;
|
||||
|
||||
@ManyToOne(() => CharacterItem, { onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'character_item_id' })
|
||||
characterItem!: CharacterItem;
|
||||
|
||||
@ManyToOne(() => ItemDefinition, { onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'item_definition_id' })
|
||||
itemDefinition!: ItemDefinition;
|
||||
}
|
||||
Reference in New Issue
Block a user