From: Carl Worth Date: Sun, 14 Jun 2020 17:18:12 +0000 (-0700) Subject: Rename "/judging" endpoint to "/judged" X-Git-Url: https://git.cworth.org/git?p=empires-server;a=commitdiff_plain;h=94e1835efd0f912f1a3eab7b996d86dd3137187c Rename "/judging" endpoint to "/judged" This is to make room for a new "/judging" endpoint to capture the notification that a player is in the process of performing judging, (that they've started clicking on some of the words in the list). This commit also fixes the test suite to track this change. Note: "judged" isn't really a perfect name here. By analogy with "answer" what we want here is a noun, which would imply "judgment" but that suggests an entirely different meaning to my ears. So, for now, we're going with the slightly inconsistent "judged". --- diff --git a/empathy.js b/empathy.js index eaf12bf..7e53486 100644 --- a/empathy.js +++ b/empathy.js @@ -178,7 +178,7 @@ class Empathy extends Game { this.broadcast_event_object('ambiguities', this.state.ambiguities); } - receive_judging(prompt_id, session_id, word_groups) { + receive_judged(prompt_id, session_id, word_groups) { const player = this.players_by_session[session_id]; if (! player) return { valid: false, message: "Player not found" }; @@ -439,13 +439,13 @@ router.post('/end-answers/:prompt_id([0-9]+)', (request, response) => { game.perform_judging(); }); -router.post('/judging/:prompt_id([0-9]+)', (request, response) => { +router.post('/judged/:prompt_id([0-9]+)', (request, response) => { const game = request.game; const prompt_id = parseInt(request.params.prompt_id, 10); - const result = game.receive_judging(prompt_id, - request.session.id, - request.body.word_groups); + const result = game.receive_judged(prompt_id, + request.session.id, + request.body.word_groups); response.json(result); }); diff --git a/test b/test index f117234..8454ba8 100755 --- a/test +++ b/test @@ -561,23 +561,23 @@ result=$(echo $(empathy_ambiguities_list $alice)) test "$result" = '"Grains of Sand" "people" "sand" "sands" "sun" "SunLight" "SunShine" "towels" "wafer" "water"' TEST_END -empathy_judging() +empathy_judged() { - curl_post $empathy_game_path/judging/$2 "{ \"word_groups\": $3}" "-b $1" + curl_post $empathy_game_path/judged/$2 "{ \"word_groups\": $3}" "-b $1" } TEST "Submit word groups from alice" -result=$(empathy_judging $alice $prompt_id '[["sun","SunLight","SunShine"],["sand","sands","Grains of Sand"],["water","wafer"]]') +result=$(empathy_judged $alice $prompt_id '[["sun","SunLight","SunShine"],["sand","sands","Grains of Sand"],["water","wafer"]]') test "$result" = '{"valid":true}' TEST_END TEST "Submit word groups from bob" -result=$(empathy_judging $bob $prompt_id '[["sands","grains of sand"],["water","wafer"]]') +result=$(empathy_judged $bob $prompt_id '[["sands","grains of sand"],["water","wafer"]]') test "$result" = '{"valid":true}' TEST_END TEST "Submit word groups from charlie" -result=$(empathy_judging $charlie $prompt_id '[["SunLight","SunShine"],["sand","Grains of Sand"]]') +result=$(empathy_judged $charlie $prompt_id '[["SunLight","SunShine"],["sand","Grains of Sand"]]') test "$result" = '{"valid":true}' TEST_END