- if (typeof document !== "undefined") //client side
- {
- const V = eval(vname + "Rules");
- // Allow custom FEN (and check it) only for individual challenges
- if (c.fen.length > 0 && playerCount > 0)
- {
- if (!V.IsGoodFen(c.fen))
- return "Bad FEN string";
- }
- else
- {
- // Generate a FEN
- c.fen = V.GenRandInitFen();
- }
- }
- else
- {
- // Just characters check on server:
- if (!c.fen.match(/^[a-zA-Z0-9, /-]*$/))
- return "Bad FEN string";
- }
-}
+ // Allow custom FEN (and check it) only for individual challenges
+ if (c.fen.length > 0 && !!c.to) {
+ if (!V.IsGoodFen(c.fen)) return "Errors in FEN";
+ }
+ else c.fen = "";