Skip to content

Commit

Permalink
feat: lower player limit for free servers, removed point interval set…
Browse files Browse the repository at this point in the history
… from setup
  • Loading branch information
stijnvdkolk committed Jul 28, 2024
1 parent 1cbf8ed commit 3bd45e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/commands/game/sub/addPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SubcommandFunction } from '../../../util/Command';
import { getGame, prisma } from '../../../util/prisma';
import { GameStatus } from '@prisma/client';
import { Util } from '../../../util/Util';
import { isPremiumCheck } from '../../../util/SKU';

export const gameAddPlayerSubCommand: SubcommandFunction<
(typeof GameCommand)['options']['add-player']
Expand All @@ -18,6 +19,10 @@ export const gameAddPlayerSubCommand: SubcommandFunction<
content: 'This command can only be used in a forum post.',
});

const isPremium = interaction.entitlements.some((sku) =>
isPremiumCheck(sku.skuId)
);

const game = await getGame(
interaction.channel.parent.id,
interaction.channelId,
Expand All @@ -41,9 +46,12 @@ export const gameAddPlayerSubCommand: SubcommandFunction<
});
}

if (game.players.length === 20) {
// game limit for premium is 20, non-premium is 10
if (game.players.length === (isPremium ? 20 : 10)) {
return respond(interaction, {
content: 'This game is full, there can be no more than 20 players.',
content: `This game is full, there can be no more than ${
isPremium ? 20 : 10
} players.`,
});
}

Expand Down
4 changes: 1 addition & 3 deletions src/commands/game/sub/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ export const gameSetupSubCommand: SubcommandFunction<
},
});

const pointInterval = args['point-interval'] * 60e3;

const game = await prisma.game.createSetupGame({
guildId: interaction.guildId,
channelId: tankTacticsChannel.id,
threadId: forumThread.id,
createdById: interaction.user.id,
pointInterval,
pointInterval: 10 * 60 * 1_000,
type,
});

Expand Down
1 change: 0 additions & 1 deletion src/interactions/commands/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const GameCommand = {
description: 'Set up a game',
options: {
type: GameTypeOption,
'point-interval': PointIntervalOption,
},
},
'add-player': {
Expand Down
6 changes: 6 additions & 0 deletions src/util/SKU.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const premiumSkus = process.env.SKU_IDS_PREMIUM?.split(',');

export const isPremiumCheck = (skuId: string) => {
if (!premiumSkus) return true;
return premiumSkus.includes(skuId);
};

0 comments on commit 3bd45e2

Please sign in to comment.