46 lines
1.8 KiB
JavaScript
46 lines
1.8 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const MapSchema = new Schema({
|
|
name: { type: String, required: true, trim: true },
|
|
// Uploaded image, served from /api/public/<filename>
|
|
image: { type: String, default: '' },
|
|
// Grid cell size in image pixels
|
|
gridSize: { type: Number, min: 1, default: 50 },
|
|
// Grid origin, in image pixels from the top left corner of the image
|
|
offsetX: { type: Number, default: 0 },
|
|
offsetY: { type: Number, default: 0 },
|
|
// Distance each grid cell stands for (feet, metres...)
|
|
scale: { type: Number, min: 0.01, default: 5 },
|
|
// Notes pinned onto the map like markers. x/y are image pixels from the top left corner of the
|
|
// image, so a pin keeps its place whatever the zoom or the grid settings are.
|
|
pins: [{
|
|
note: { type: Schema.Types.ObjectId, ref: 'Note', required: true },
|
|
x: { type: Number, default: 0 },
|
|
y: { type: Number, default: 0 }
|
|
}],
|
|
// Actors dragged onto the map to stand on it as tokens. x/y are image pixels of the centre of the
|
|
// token, like a pin, and the viewer keeps them snapped onto a grid cell so a token sits where the
|
|
// square it stands in is.
|
|
tokens: [{
|
|
actor: { type: Schema.Types.ObjectId, ref: 'Actor', required: true },
|
|
x: { type: Number, default: 0 },
|
|
y: { type: Number, default: 0 }
|
|
}],
|
|
campaign: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'Campaign',
|
|
required: true
|
|
},
|
|
// The folder this map stands in: a Folder of the same campaign whose target is
|
|
// 'map' (null = the root of the map list).
|
|
folder: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'Folder',
|
|
default: null
|
|
},
|
|
date: { type: Date, default: Date.now }
|
|
});
|
|
|
|
module.exports = mongoose.model('Map', MapSchema);
|