feat: add trivia category selection and sync trivia fixes
This commit is contained in:
@@ -144,7 +144,7 @@ class TriviaService {
|
||||
/**
|
||||
* Start a trivia session - deducts entry fee and creates session
|
||||
*/
|
||||
async startTrivia(userId: string, username: string): Promise<TriviaSession> {
|
||||
async startTrivia(userId: string, username: string, categoryId?: number): Promise<TriviaSession> {
|
||||
// Check cooldown
|
||||
const cooldownCheck = await this.canPlayTrivia(userId);
|
||||
if (!cooldownCheck.canPlay) {
|
||||
@@ -184,9 +184,12 @@ class TriviaService {
|
||||
});
|
||||
|
||||
// Fetch question
|
||||
const category = config.trivia.categories.length > 0
|
||||
? config.trivia.categories[Math.floor(Math.random() * config.trivia.categories.length)]
|
||||
: undefined;
|
||||
let category = categoryId;
|
||||
if (!category) {
|
||||
category = config.trivia.categories.length > 0
|
||||
? config.trivia.categories[Math.floor(Math.random() * config.trivia.categories.length)]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
const difficulty = config.trivia.difficulty;
|
||||
const question = await this.fetchQuestion(category, difficulty);
|
||||
|
||||
Reference in New Issue
Block a user