Moved tabletop characters to left side of the screen
This commit is contained in:
114
app/imports/api/tabletop/Tabletops.ts
Normal file
114
app/imports/api/tabletop/Tabletops.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
export type Tabletop = {
|
||||
name?: string,
|
||||
description?: string,
|
||||
imageUrl?: string,
|
||||
owner: string,
|
||||
gameMasters: string[],
|
||||
players: string[],
|
||||
spectators: string[],
|
||||
public?: true,
|
||||
initiative: {
|
||||
active: boolean,
|
||||
roundNumber: number,
|
||||
initiativeNumber?: number,
|
||||
activeCreature?: string,
|
||||
},
|
||||
}
|
||||
|
||||
const Tabletops = new Mongo.Collection<Tabletop>('tabletops');
|
||||
|
||||
const InitiativeSchema = new SimpleSchema({
|
||||
active: {
|
||||
type: Boolean,
|
||||
defaultValue: false,
|
||||
},
|
||||
roundNumber: {
|
||||
type: SimpleSchema.Integer,
|
||||
defaultValue: 0,
|
||||
},
|
||||
initiativeNumber: {
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
activeCreature: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
// All creatures in a tabletop have a shared time and space.
|
||||
const TabletopSchema = new SimpleSchema({
|
||||
// Details
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
imageUrl: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
|
||||
// Permissions by userId
|
||||
// Who owns this tabletop and can delete it
|
||||
owner: String,
|
||||
// The owner will need to included in one of these arrays for specific permissions
|
||||
// A user should not appear in more than one of the following arrays
|
||||
gameMasters: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'gameMasters.$': {
|
||||
type: String,
|
||||
//@ts-expect-error Index not defined in simpl-schema package
|
||||
index: 1,
|
||||
},
|
||||
players: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'players.$': {
|
||||
type: String,
|
||||
//@ts-expect-error Index not defined in simpl-schema package
|
||||
index: 1,
|
||||
},
|
||||
spectators: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'spectators.$': {
|
||||
type: String,
|
||||
//@ts-expect-error Index not defined in simpl-schema package
|
||||
index: 1,
|
||||
},
|
||||
// Does everyone else have the spectator permission?
|
||||
public: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
//@ts-expect-error Index not defined in simpl-schema package
|
||||
index: 1,
|
||||
},
|
||||
|
||||
// Initiative
|
||||
initiative: {
|
||||
type: InitiativeSchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//@ts-expect-error attachSchema not defined in simpl-schema package
|
||||
Tabletops.attachSchema(TabletopSchema);
|
||||
|
||||
import '/imports/api/tabletop/methods/removeTabletop';
|
||||
import '/imports/api/tabletop/methods/insertTabletop';
|
||||
import '/imports/api/tabletop/methods/updateTabletop';
|
||||
import '/imports/api/tabletop/methods/addCreaturesToTabletop';
|
||||
|
||||
export default Tabletops;
|
||||
Reference in New Issue
Block a user