diff --git a/client/public/modules/dnd-5e/icon.png b/client/public/modules/dnd-5e/icon.png new file mode 100644 index 00000000..ddbadbb0 Binary files /dev/null and b/client/public/modules/dnd-5e/icon.png differ diff --git a/client/public/modules/dnd-5e/module.json b/client/public/modules/dnd-5e/module.json new file mode 100644 index 00000000..d49c047e --- /dev/null +++ b/client/public/modules/dnd-5e/module.json @@ -0,0 +1,12 @@ +{ + "id": "dnd-5e", + "title": "Dungeons & Dragons 5e", + "description": "Dungeons & Dragons Fifth edition game system support", + "authors": [ + { + "name": "Aran Roig" + } + ], + "version": "1.0.0", + "color": "#e92026" +} \ No newline at end of file diff --git a/client/src/App.vue b/client/src/App.vue index f0fbefbb..7b56d061 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -6,10 +6,43 @@ import { RouterLink, RouterView } from 'vue-router' import { GetUser, UserStatus, LoadUser } from '@/services/User.js' import { IsAdmin } from './services/User' +import useEmitter from '@/services/Emitter'; +const emitter = useEmitter(); + +import { DisplayToast, SetEmitter } from './services/Dragonroll' +import { ImportModule, GetModulesToLoad } from './services/Modules' +import { CreateWindow } from './services/Windows'; + console.clear(); console.log("%cLoaded!!!", "color: #22ff22; font-size: 24px"); LoadUser(); +SetEmitter(emitter); +onMounted(() => { + async function preloadModules(){ + const modules = GetModulesToLoad(); + let moduleLoads = []; + + modules.forEach(moduleName => { + moduleLoads.push(ImportModule(moduleName)); + }); + + await Promise.all(moduleLoads); + DisplayToast('aqua', 'All modules loaded successfully'); + + if(GetUser()){ + CreateWindow('main_menu') + // CreateWindow('test'); + DisplayToast('green', 'Logged in successfully as ' + GetUser().username + '!', 3000) + return; + } + CreateWindow('login'); + } + + preloadModules(); +}) + + diff --git a/client/src/views/windows/campaigns/SystemSelectorWindow.vue b/client/src/views/windows/campaigns/SystemSelectorWindow.vue new file mode 100644 index 00000000..a6d17458 --- /dev/null +++ b/client/src/views/windows/campaigns/SystemSelectorWindow.vue @@ -0,0 +1,63 @@ + + + + + + + \ No newline at end of file diff --git a/client/vite.config.js b/client/vite.config.js index 98f28cda..8ed36b09 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -11,6 +11,7 @@ export default defineConfig({ resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), + 'vue': 'vue/dist/vue.esm-bundler.js' } }, proxy: { diff --git a/server/models/Book.js b/server/models/Book.js new file mode 100644 index 00000000..282a9a66 --- /dev/null +++ b/server/models/Book.js @@ -0,0 +1,12 @@ +const mongoose = require("mongoose"); +const Schema = mongoose.Schema; + +const BookSchema = new Schema({ + title: {type: String, required: true}, + authors: { type: [String] }, + system: {type: String, required: true}, + image: { type: String }, + data: { type: Object }, +}); + +module.exports = mongoose.model('Book', BookSchema); \ No newline at end of file diff --git a/server/models/Campaign.js b/server/models/Campaign.js index 179feb26..919d8fe5 100644 --- a/server/models/Campaign.js +++ b/server/models/Campaign.js @@ -3,6 +3,7 @@ const Schema = mongoose.Schema; const CampaignSchema = new Schema({ name: {type: String, required: true}, + system: {type: String, required: true}, creation_date: { type: Date, default: Date.now}, last_opened: { type: Date, default: Date.now}, invite_code: { type: String, unique: true }, diff --git a/server/models/Character.js b/server/models/Character.js new file mode 100644 index 00000000..396fd4d4 --- /dev/null +++ b/server/models/Character.js @@ -0,0 +1,11 @@ +const mongoose = require("mongoose"); +const Schema = mongoose.Schema; + +const CharacterSchema = new Schema({ + name: {type: String, required: true}, + data: { type: Object }, + campaign_user: {type: mongoose.Types.ObjectId, ref: "CampaignUser"}, + image: { type: String }, +}); + +module.exports = mongoose.model('Character', CharacterSchema); \ No newline at end of file diff --git a/server/models/Entity.js b/server/models/Entity.js new file mode 100644 index 00000000..1f6cb97d --- /dev/null +++ b/server/models/Entity.js @@ -0,0 +1,11 @@ +const mongoose = require("mongoose"); +const Schema = mongoose.Schema; + +const EntitySchema = new Schema({ + name: {type: String, required: true}, + data: { type: Object }, + campaign: {type: mongoose.Types.ObjectId, ref: "Campaign"}, + image: { type: String }, +}); + +module.exports = mongoose.model('Entity', EntitySchema); \ No newline at end of file diff --git a/server/models/Map.js b/server/models/Map.js new file mode 100644 index 00000000..551cf8a4 --- /dev/null +++ b/server/models/Map.js @@ -0,0 +1,12 @@ +const mongoose = require("mongoose"); +const Schema = mongoose.Schema; + +const MapSchema = new Schema({ + name: {type: String, required: true}, + data: { type: Object }, // Data del format dd2vtt + campaign: {type: mongoose.Types.ObjectId, ref: "Campaign"}, + image: { type: String }, + entities: { type: Object } +}); + +module.exports = mongoose.model('Entity', EntitySchema); \ No newline at end of file diff --git a/server/routes/campaign.js b/server/routes/campaign.js index 45687966..ccd59baa 100644 --- a/server/routes/campaign.js +++ b/server/routes/campaign.js @@ -16,10 +16,11 @@ router.post('/register', passport.authenticate('jwt', {session: false}), rateLim router.post('/create', passport.authenticate('jwt', {session: false}), rateLimitMiddleware, (req, res) => { let { - name + name, + system } = req.body; - if(!(name)){ + if(!(name && system)){ res.json({ status: "error", msg: "params" @@ -28,7 +29,7 @@ router.post('/create', passport.authenticate('jwt', {session: false}), rateLimit } // Create the campaign - let campaign = new Campaign({name}); + let campaign = new Campaign({name, system}); campaign.invite_code = Campaign.generateInvite(); campaign.save().then(campaign => {