|
| 1 | +import { getModelForClass, prop } from '@typegoose/typegoose' |
| 2 | +import { DocumentType } from '@typegoose/typegoose/lib/types' |
| 3 | +import { Field, ObjectType } from 'type-graphql' |
| 4 | + |
| 5 | +import { APIReference } from '@/models/common/apiReference' |
| 6 | +import { srdModelOptions } from '@/util/modelOptions' |
| 7 | + |
| 8 | +import { EquipmentCategory2024 } from './equipmentCategory' |
| 9 | + |
| 10 | +@ObjectType({ description: 'The rarity level of a 2024 magic item.' }) |
| 11 | +export class Rarity2024 { |
| 12 | + @Field(() => String, { |
| 13 | + description: 'The name of the rarity level (e.g., Common, Uncommon, Rare).' |
| 14 | + }) |
| 15 | + @prop({ required: true, index: true, type: () => String }) |
| 16 | + public name!: string |
| 17 | +} |
| 18 | + |
| 19 | +@ObjectType({ description: 'An item imbued with magical properties in D&D 5e 2024.' }) |
| 20 | +@srdModelOptions('2024-magic-items') |
| 21 | +export class MagicItem2024 { |
| 22 | + @Field(() => String, { |
| 23 | + description: 'The unique identifier for this magic item (e.g., bag-of-holding).' |
| 24 | + }) |
| 25 | + @prop({ required: true, index: true, type: () => String }) |
| 26 | + public index!: string |
| 27 | + |
| 28 | + @Field(() => String, { description: 'The name of the magic item.' }) |
| 29 | + @prop({ required: true, index: true, type: () => String }) |
| 30 | + public name!: string |
| 31 | + |
| 32 | + @Field(() => String, { description: 'A description of the magic item.' }) |
| 33 | + @prop({ required: true, type: () => String }) |
| 34 | + public desc!: string |
| 35 | + |
| 36 | + @Field(() => String, { nullable: true, description: 'URL of an image for the magic item.' }) |
| 37 | + @prop({ type: () => String, index: true }) |
| 38 | + public image?: string |
| 39 | + |
| 40 | + @Field(() => EquipmentCategory2024, { |
| 41 | + description: 'The category of equipment this magic item belongs to.' |
| 42 | + }) |
| 43 | + @prop({ type: () => APIReference, index: true }) |
| 44 | + public equipment_category!: APIReference |
| 45 | + |
| 46 | + @Field(() => Boolean, { |
| 47 | + description: 'Whether this magic item requires attunement.' |
| 48 | + }) |
| 49 | + @prop({ required: true, index: true, type: () => Boolean }) |
| 50 | + public attunement!: boolean |
| 51 | + |
| 52 | + @Field(() => Boolean, { |
| 53 | + description: 'Indicates if this magic item is a variant of another item.' |
| 54 | + }) |
| 55 | + @prop({ required: true, index: true, type: () => Boolean }) |
| 56 | + public variant!: boolean |
| 57 | + |
| 58 | + @Field(() => [MagicItem2024], { |
| 59 | + nullable: true, |
| 60 | + description: 'Other magic items that are variants of this item.' |
| 61 | + }) |
| 62 | + @prop({ type: () => [APIReference], index: true }) |
| 63 | + public variants!: APIReference[] |
| 64 | + |
| 65 | + @Field(() => Rarity2024, { description: 'The rarity of the magic item.' }) |
| 66 | + @prop({ required: true, index: true, type: () => Rarity2024 }) |
| 67 | + public rarity!: Rarity2024 |
| 68 | + |
| 69 | + @Field(() => String, { |
| 70 | + nullable: true, |
| 71 | + description: 'Class restriction for attunement (e.g., "by a wizard").' |
| 72 | + }) |
| 73 | + @prop({ type: () => String, index: true }) |
| 74 | + public limited_to?: string |
| 75 | + |
| 76 | + @prop({ required: true, index: true, type: () => String }) |
| 77 | + public url!: string |
| 78 | + |
| 79 | + @Field(() => String, { description: 'Timestamp of the last update.' }) |
| 80 | + @prop({ required: true, index: true, type: () => String }) |
| 81 | + public updated_at!: string |
| 82 | +} |
| 83 | + |
| 84 | +export type MagicItemDocument = DocumentType<MagicItem2024> |
| 85 | +const MagicItemModel = getModelForClass(MagicItem2024) |
| 86 | + |
| 87 | +export default MagicItemModel |
0 commit comments