Moved tabletop characters to left side of the screen

This commit is contained in:
Thaum Rystra
2024-04-12 17:05:20 +02:00
parent 4793b34a55
commit 08640f2bf2
27 changed files with 496 additions and 1370 deletions

View File

@@ -1,8 +1,7 @@
import { ValidatedMethod } from 'meteor/mdg:validated-method';
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
import Tabletops from '../Tabletops';
import { assertAdmin } from '/imports/api/sharing/sharingPermissions';
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers';
import { assertUserHasPaidBenefits, getUserTier } from '/imports/api/users/patreon/tiers';
const insertTabletop = new ValidatedMethod({
@@ -11,8 +10,9 @@ const insertTabletop = new ValidatedMethod({
validate: null,
mixins: [RateLimiterMixin],
// @ts-expect-error Rate limit not defined
rateLimit: {
numRequests: 5,
numRequests: 2,
timeInterval: 5000,
},
@@ -22,13 +22,24 @@ const insertTabletop = new ValidatedMethod({
'You need to be logged in to insert a tabletop');
}
assertUserHasPaidBenefits(this.userId);
assertAdmin(this.userId);
let tier = getUserTier(this.userId);
const currentTabletopCount = Tabletops.find({ owner: this.userId }).count();
if (tier.tabletopSlots !== -1 && tier.tabletopSlots <= currentTabletopCount) {
throw new Meteor.Error('limit-reached', 'You have reached your maximum number of tabletops');
}
return Tabletops.insert({
gameMaster: this.userId,
owner: this.userId,
gameMasters: [this.userId],
players: [],
spectators: [],
initiative: {
active: false,
roundNumber: 0,
},
});
},
});
export default insertTabletop;