shithub: puzzles

Download patch

ref: 69e63a810e0bd6f85a46d8490c6e366237e061ef
parent: af2d992af0d11ad2a91b4c1f7c04d6c69dbe6e55
author: Chris Boyle <chris@boyle.name>
date: Tue Dec 20 04:13:20 EST 2016

magnets: Area constraints; fix message.

(The restriction on 2x2 puzzles is because the board layer-out doesn't
use neutral pieces on such small boards, and the only soluble 2x2 boards
have neutral pieces.  I haven't investigated the Tricky size limit, but
it seems entirely reasonable that all the smaller boards are too easy.
--bjh21)

(cherry picked from Android port, commit
133794977a13767e0c1596be6a5b26f2cf2d1fd1)

--- a/magnets.c
+++ b/magnets.c
@@ -230,8 +230,15 @@
 
 static const char *validate_params(const game_params *params, bool full)
 {
-    if (params->w < 2) return "Width must be at least one";
-    if (params->h < 2) return "Height must be at least one";
+    if (params->w < 2) return "Width must be at least two";
+    if (params->h < 2) return "Height must be at least two";
+    if (params->diff >= DIFF_TRICKY) {
+        if (params->w < 5 && params->h < 5)
+            return "Either width or height must be at least five for Tricky";
+    } else {
+        if (params->w < 3 && params->h < 3)
+            return "Either width or height must be at least three";
+    }
     if (params->diff < 0 || params->diff >= DIFFCOUNT)
         return "Unknown difficulty level";