Extend variant configuration checks
authorFabian Fichter <ianfab@users.noreply.github.com>
Mon, 29 Mar 2021 19:07:37 +0000 (21:07 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Mon, 29 Mar 2021 19:07:37 +0000 (21:07 +0200)
src/parser.cpp
src/variant.h

index de075a5..7d53842 100644 (file)
@@ -369,17 +369,29 @@ Variant* VariantParser<DoCheck>::parse(Variant* v) {
             }
         }
 
+        // Contradictory options
+        if (!v->checking && v->checkCounting)
+            std::cerr << "checkCounting=true requires checking=true." << std::endl;
+        if (v->doubleStep && v->doubleStepRankMin > v->doubleStepRank)
+            std::cerr << "Inconsistent settings: doubleStepRankMin > doubleStepRank." << std::endl;
+        if (v->castling && v->castlingRank > v->maxRank)
+            std::cerr << "Inconsistent settings: castlingRank > maxRank." << std::endl;
+        if (v->castling && v->castlingQueensideFile > v->castlingKingsideFile)
+            std::cerr << "Inconsistent settings: castlingQueensideFile > castlingKingsideFile." << std::endl;
+
         // Check for limitations
 
         // Options incompatible with royal kings
         if (v->pieceTypes.find(KING) != v->pieceTypes.end())
         {
             if (v->blastOnCapture)
-                std::cerr << "Can not use kings with blastOnCapture" << std::endl;
+                std::cerr << "Can not use kings with blastOnCapture." << std::endl;
             if (v->flipEnclosedPieces)
-                std::cerr << "Can not use kings with flipEnclosedPieces" << std::endl;
+                std::cerr << "Can not use kings with flipEnclosedPieces." << std::endl;
+            const PieceInfo* pi = pieceMap.find(v->kingType)->second;
+            if (pi->lameLeaper || pi->hopperQuiet.size() || pi->hopperCapture.size())
+                std::cerr << pi->name << " is not supported as kingType." << std::endl;
         }
-
     }
     return v;
 }
index 3575ee9..14f74c8 100644 (file)
@@ -99,6 +99,7 @@ struct Variant {
   bool flyingGeneral = false;
   Rank soldierPromotionRank = RANK_1;
   EnclosingRule flipEnclosedPieces = NO_ENCLOSING;
+
   // game end
   int nMoveRule = 50;
   int nFoldRule = 3;