From 9bf31e86cef62bed76a35353e791768960b14d70 Mon Sep 17 00:00:00 2001 From: dozens Date: Sun, 23 Jun 2024 15:41:31 -0600 Subject: Move error handling to front-end game.validate-move will now return an error code is the move is invalid. default error messages are found in lib/constants.fnl. error handling is now handled on the front end. --- lib/constants.fnl | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/constants.fnl b/lib/constants.fnl index be9a6be..996c11c 100644 --- a/lib/constants.fnl +++ b/lib/constants.fnl @@ -97,9 +97,33 @@ :complete 5 ;; no more cows! jk the cows are fine. the game's just over okay }) -{: board + +;; errror codes +(local errors { + :not-a-space "That space does not exist!\nHint: 1a 1A A1 a1 are all the same move." + :occupied "That space is occupied!" + :not-an-opponent "Choose an opponent's piece to remove." + :is-mill "Ma'am, it is ILLEGAL to break up a mill." + :bad-move-format "Try a move like B2B4 or A7 D7" + :not-yours "That's not yours, don't touch it." + :not-neighbor "That ain't your neighbor, Johnny" +}) + + +;; if you like it then you shoulda put a ... +(local rings { + :outer [ 1 2 3 15 24 23 22 10 ] + :middle [ 4 5 6 14 21 20 19 11 ] + :inner [ 7 8 9 13 18 17 16 12 ] +}) + + +{ + : board + : errors : mills : neighbors + : rings + : spaces : stages - : spaces} - + } -- cgit 1.4.1-2-gfad0