From 771e0ce4711a7ed723d216c28ab8d1472463d3ef Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 29 Jun 2020 13:52:10 -0700 Subject: [PATCH] empathy: Don't allow a prompt with 0 items Thanks to my clever nephews for finding this degenerate case that I had missed when coding this up originally. --- empathy.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/empathy.js b/empathy.js index a3faf5b..c1d150f 100644 --- a/empathy.js +++ b/empathy.js @@ -115,11 +115,19 @@ class Empathy extends Game { } 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++; -- 2.43.0