*
* Specified in seconds
*/
-const PHASE_IDLE_TIMEOUT = 30;
+const PHASE_IDLE_TIMEOUT = 15;
class Empathy extends Game {
constructor(id) {
}
add_prompt(items, prompt_string) {
- if (items > MAX_PROMPT_ITEMS)
+ if (items > MAX_PROMPT_ITEMS) {
return {
valid: false,
message: `Maximum number of items is ${MAX_PROMPT_ITEMS}`
};
+ }
+
+ if (items < 1) {
+ return {
+ valid: false,
+ message: "Category must require at least one item"
+ };
+ }
const prompt = new Prompt(this.next_prompt_id, items, prompt_string);
this.next_prompt_id++;
}
toggle_vote_against(player_name) {
- if (this.votes_against.find(v => v === player_name))
+ if (this.votes_against.find(v => v === player_name)) {
this.votes_against = this.votes_against.filter(v => v !== player_name);
- else
+ } else {
this.votes_against.push(player_name);
+ /* When voting against, we also remove any vote _for_ the same
+ * prompt. */
+ this.votes = this.votes.filter(v => v !== player_name);
+ }
}
}