Just to avoid any smart aleck trying to get every player's browser to
try to render a million text input fields.
const express = require("express");
const Game = require("./game.js");
const express = require("express");
const Game = require("./game.js");
+const MAX_PROMPT_ITEMS = 20;
+
class Empathy extends Game {
constructor(id) {
super(id);
class Empathy extends Game {
constructor(id) {
super(id);
}
add_prompt(items, prompt_string) {
}
add_prompt(items, prompt_string) {
+ if (items > MAX_PROMPT_ITEMS)
+ return {
+ valid: false,
+ message: `Maximum number of items is ${MAX_PROMPT_ITEMS}`
+ };
+
const prompt = new Prompt(this.next_prompt_id, items, prompt_string);
this.next_prompt_id++;
const prompt = new Prompt(this.next_prompt_id, items, prompt_string);
this.next_prompt_id++;
this.broadcast_event_object('prompt', prompt);
this.broadcast_event_object('prompt', prompt);
+ return {
+ valid: true,
+ id: prompt.id
+ };
}
/* Returns true if vote toggled, false for player or prompt not found */
}
/* Returns true if vote toggled, false for player or prompt not found */
router.post('/prompts', (request, response) => {
const game = request.game;
router.post('/prompts', (request, response) => {
const game = request.game;
- prompt = game.add_prompt(request.body.items, request.body.prompt);
+ const result = game.add_prompt(request.body.items, request.body.prompt);
- response.json({ id: prompt.id});
});
router.post('/vote/:prompt_id([0-9]+)', (request, response) => {
});
router.post('/vote/:prompt_id([0-9]+)', (request, response) => {