Foundry and discord bot
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 1m51s
This commit is contained in:
47
backend/src/models/Actor.js
Normal file
47
backend/src/models/Actor.js
Normal file
@@ -0,0 +1,47 @@
|
||||
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);
|
||||
@@ -11,7 +11,14 @@ const CampaignSchema = new Schema({
|
||||
required: true
|
||||
},
|
||||
date: { type: Date, default: Date.now},
|
||||
settings: { type: Object }
|
||||
settings: { type: Object },
|
||||
foundryWorldId: { type: String, unique: true, sparse: true },
|
||||
foundryWorldTitle: { type: String },
|
||||
foundrySystem: { type: String },
|
||||
foundrySyncTokenHash: { type: String, select: false },
|
||||
// Discord server ("guild") this campaign is linked to. A campaign serves
|
||||
// at most one guild, and a guild selects one campaign.
|
||||
discordGuildId: { type: String, index: true }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Campaign', CampaignSchema);
|
||||
module.exports = mongoose.model('Campaign', CampaignSchema);
|
||||
|
||||
11
backend/src/models/DiscordGuildLink.js
Normal file
11
backend/src/models/DiscordGuildLink.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const DiscordGuildLinkSchema = new Schema({
|
||||
guildId: { type: String, required: true, unique: true, index: true },
|
||||
discordUserId: { type: String, required: true },
|
||||
dragonrollUser: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||
connectedAt: { type: Date, default: Date.now }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('DiscordGuildLink', DiscordGuildLinkSchema);
|
||||
20
backend/src/models/DiscordLinkRequest.js
Normal file
20
backend/src/models/DiscordLinkRequest.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const DiscordLinkRequestSchema = new Schema({
|
||||
codeHash: { type: String, required: true, unique: true },
|
||||
guildId: { type: String, required: true },
|
||||
guildName: { type: String, required: true },
|
||||
discordUserId: { type: String, required: true },
|
||||
discordUserName: { type: String, required: true },
|
||||
dragonrollUser: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
createdAt: { type: Date, default: Date.now },
|
||||
expiresAt: { type: Date, required: true },
|
||||
completedAt: { type: Date },
|
||||
// Quan el bot ja ha confirmat a Discord que aquesta autoritzacio s'ha fet.
|
||||
notifiedAt: { type: Date }
|
||||
});
|
||||
|
||||
DiscordLinkRequestSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
||||
|
||||
module.exports = mongoose.model('DiscordLinkRequest', DiscordLinkRequestSchema);
|
||||
24
backend/src/models/FoundryLinkRequest.js
Normal file
24
backend/src/models/FoundryLinkRequest.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const FoundryLinkRequestSchema = new Schema({
|
||||
codeHash: { type: String, required: true, unique: true },
|
||||
// Kept in clear text so the campaign settings screen can re-display a pending
|
||||
// pairing code after a reload or a backend restart. It is only ever returned
|
||||
// to the user who created the request and is cleared once the link completes.
|
||||
code: { type: String },
|
||||
source: { type: String, enum: ['dragonroll'], required: true },
|
||||
campaign: { type: Schema.Types.ObjectId, ref: 'Campaign' },
|
||||
createdBy: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
worldId: { type: String },
|
||||
worldTitle: { type: String },
|
||||
system: { type: String },
|
||||
foundryUrl: { type: String },
|
||||
createdAt: { type: Date, default: Date.now },
|
||||
expiresAt: { type: Date, required: true },
|
||||
completedAt: { type: Date }
|
||||
});
|
||||
|
||||
FoundryLinkRequestSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
||||
|
||||
module.exports = mongoose.model('FoundryLinkRequest', FoundryLinkRequestSchema);
|
||||
28
backend/src/models/Item.js
Normal file
28
backend/src/models/Item.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const ItemSchema = new Schema({
|
||||
name: { type: String, required: true, trim: true },
|
||||
category: {
|
||||
type: String,
|
||||
enum: ['weapon', 'armor', 'shield', 'adventuring-gear', 'magic-item', 'consumable', 'tool', 'treasure', 'other'],
|
||||
default: 'adventuring-gear'
|
||||
},
|
||||
rarity: {
|
||||
type: String,
|
||||
enum: ['common', 'uncommon', 'rare', 'very-rare', 'legendary', 'artifact'],
|
||||
default: 'common'
|
||||
},
|
||||
quantity: { type: Number, min: 1, default: 1 },
|
||||
weight: { type: Number, min: 0 },
|
||||
properties: { type: String, default: '' },
|
||||
description: { type: String, default: '' },
|
||||
campaign: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: 'Campaign',
|
||||
required: true
|
||||
},
|
||||
date: { type: Date, default: Date.now }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Item', ItemSchema);
|
||||
Reference in New Issue
Block a user