Files
dragonroll/backend/src/models/Actor.js
Aran Roig 1402045001
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s
Foundry and discord bot
2026-10-11 22:26:29 +02:00

48 lines
1.8 KiB
JavaScript

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ActorSchema = new Schema({
name: { type: String, required: true, trim: true },
type: { type: String, enum: ['character', 'npc', 'creature'], default: 'character' },
species: { type: String, default: '' },
className: { type: String, default: '' },
subclass: { type: String, default: '' },
level: { type: Number, min: 1, max: 20, default: 1 },
background: { type: String, default: '' },
challengeRating: { type: String, default: '' },
description: { type: String, default: '' },
image: { type: String, default: '' },
abilityScores: {
str: { type: Number, min: 1, max: 30, default: 10 },
dex: { type: Number, min: 1, max: 30, default: 10 },
con: { type: Number, min: 1, max: 30, default: 10 },
int: { type: Number, min: 1, max: 30, default: 10 },
wis: { type: Number, min: 1, max: 30, default: 10 },
cha: { type: Number, min: 1, max: 30, default: 10 }
},
armorClass: { type: Number, min: 0, default: 10 },
speed: { type: Number, min: 0, default: 30 },
proficiencies: { type: String, default: '' },
inventory: [{
name: { type: String, trim: true, default: '' },
quantity: { type: Number, min: 1, default: 1 },
weight: { type: Number, min: 0, default: 0 }
}],
traits: { type: String, default: '' },
spells: { type: String, default: '' },
campaign: {
type: Schema.Types.ObjectId,
ref: 'Campaign',
required: true
},
foundryActorId: { type: String },
date: { type: Date, default: Date.now }
});
ActorSchema.index(
{ campaign: 1, foundryActorId: 1 },
{ unique: true, partialFilterExpression: { foundryActorId: { $type: 'string' } } }
);
module.exports = mongoose.model('Actor', ActorSchema);