add more languages
authorLaurent Mazet <mazet@softndesign.org>
Sat, 1 Jun 2024 13:24:06 +0000 (15:24 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sat, 1 Jun 2024 13:24:17 +0000 (15:24 +0200)
bag-de.h
bag-es.h [new file with mode: 0644]
bag-it.h [new file with mode: 0644]
bag-nl.h [new file with mode: 0644]
constant.c
constant.h
display.c
display.h
scrabble.c

index fca3c9e676ba7309ef07b2fbb8a056200ca257ba..9b05f9c38578e979813db1f894bb7616311ef6b1 100644 (file)
--- a/bag-de.h
+++ b/bag-de.h
@@ -27,11 +27,11 @@ static char _tiles_de[NB_TILES_DE] = {
     'F', 'F',
     'K', 'K',
     'P',
-    'Ä',
+    'a', /* 'Ä' */
     'J',
-    'Ü',
+    'u', /* 'Ü' */
     'V',
-    'Ö',
+    'o', /* 'Ö' */
     'X',
     'Q',
     'Y'
@@ -61,16 +61,18 @@ static lettervalue_t _lettervalues_de[NB_LETTERVALUES_DE] = {
     {'F', 4},
     {'K', 4},
     {'P', 4},
-    {'Ä', 6},
+    {'a' /* 'Ä' */, 6},
     {'J', 6},
-    {'Ü', 6},
+    {'u' /* 'Ü' */, 6},
     {'V', 6},
-    {'Ö', 8},
+    {'o' /* 'Ö' */, 8},
     {'X', 8},
     {'Q', 10},
     {'Y', 10}
 };
 
+static char *_extra_help_de = "a, u, o for AE, UE, OE";
+
 #endif /*  __BAG_DE__ */
 
 /* vim: set ts=4 sw=4 et: */
diff --git a/bag-es.h b/bag-es.h
new file mode 100644 (file)
index 0000000..974f396
--- /dev/null
+++ b/bag-es.h
@@ -0,0 +1,76 @@
+#ifndef __BAG_ES__
+#define __BAG_ES__
+
+#include "type.h"
+
+#define NB_TILES_ES 100
+static char _tiles_es[NB_TILES_ES] = {
+    '.', '.',
+    'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+    'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
+    'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O',
+    'I', 'I', 'I', 'I', 'I', 'I',
+    'S', 'S', 'S', 'S', 'S', 'S',
+    'N', 'N', 'N', 'N', 'N',
+    'R', 'R', 'R', 'R', 'R',
+    'U', 'U', 'U', 'U', 'U',
+    'L', 'L', 'L', 'L',
+    'T', 'T', 'T', 'T',
+    'D', 'D', 'D', 'D', 'D',
+    'G', 'G',
+    'C', 'C', 'C', 'C',
+    'B', 'B',
+    'M', 'M',
+    'P', 'P',
+    'H', 'H',
+    'F',
+    'V',
+    'Y',
+    'c', /* 'CH' */
+    'Q',
+    'J',
+    'l', /* 'LL' */
+    'n', /* 'Ñ' */
+    'r', /* 'RR' */
+    'X',
+    'Z'
+};
+
+#define NB_LETTERVALUES_ES 29
+static lettervalue_t _lettervalues_es[NB_LETTERVALUES_ES] = {
+    {'.', 0},
+    {'A', 1},
+    {'E', 1},
+    {'O', 1},
+    {'I', 1},
+    {'S', 1},
+    {'N', 1},
+    {'R', 1},
+    {'U', 1},
+    {'L', 1},
+    {'T', 1},
+    {'D', 2},
+    {'G', 2},
+    {'C', 3},
+    {'B', 3},
+    {'M', 3},
+    {'P', 3},
+    {'H', 4},
+    {'F', 4},
+    {'V', 4},
+    {'Y', 4},
+    {'c' /* 'CH' */, 5},
+    {'Q', 5},
+    {'J', 8},
+    {'l' /* 'LL' */ , 8},
+    {'n' /* 'Ñ' */, 8},
+    {'r' /* 'RR' */, 8},
+    {'X', 8},
+    {'Z', 10}
+};
+
+static char *_extra_help_es = "c, l, n, r for CH, LL, NN, RR";
+
+#endif /*  __BAG_ES__ */
+
+/* vim: set ts=4 sw=4 et: */
diff --git a/bag-it.h b/bag-it.h
new file mode 100644 (file)
index 0000000..cfeef03
--- /dev/null
+++ b/bag-it.h
@@ -0,0 +1,60 @@
+#ifndef __BAG_IT__
+#define __BAG_IT__
+
+#include "type.h"
+
+#define NB_TILES_IT 120
+static char _tiles_it[NB_TILES_IT] = {
+    '.', '.',
+    'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O',
+    'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
+    'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I', 'I',
+    'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
+    'C', 'C', 'C', 'C', 'C', 'C',
+    'R', 'R', 'R', 'R', 'R', 'R',
+    'S', 'S', 'S', 'S', 'S', 'S',
+    'T', 'T', 'T', 'T', 'T', 'T',
+    'L', 'L', 'L', 'L', 'L',
+    'M', 'M', 'M', 'M', 'M',
+    'N', 'N', 'N', 'N', 'N',
+    'U', 'U', 'U', 'U', 'U',
+    'B', 'B', 'B',
+    'D', 'D', 'D',
+    'F', 'F', 'F',
+    'P', 'P', 'P',
+    'V', 'V', 'V',
+    'G', 'G',
+    'H', 'H',
+    'Z', 'Z',
+    'Q'
+};
+
+#define NB_LETTERVALUES_IT 22
+static lettervalue_t _lettervalues_it[NB_LETTERVALUES_IT] = {
+    {'.', 0},
+    {'O', 1},
+    {'A', 1},
+    {'I', 1},
+    {'E', 1},
+    {'C', 2},
+    {'R', 2},
+    {'S', 2},
+    {'T', 2},
+    {'L', 3},
+    {'M', 3},
+    {'N', 3},
+    {'U', 3},
+    {'B', 5},
+    {'D', 5},
+    {'F', 5},
+    {'P', 5},
+    {'V', 5},
+    {'G', 8},
+    {'H', 8},
+    {'Z', 8},
+    {'Q', 10}
+};
+
+#endif /*  __BAG_IT__ */
+
+/* vim: set ts=4 sw=4 et: */
diff --git a/bag-nl.h b/bag-nl.h
new file mode 100644 (file)
index 0000000..cd6794f
--- /dev/null
+++ b/bag-nl.h
@@ -0,0 +1,74 @@
+#ifndef __BAG_NL__
+#define __BAG_NL__
+
+#include "type.h"
+
+#define NB_TILES_NL 102
+static char _tiles_nl[NB_TILES_NL] = {
+    '.', '.',
+    'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
+    'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N',
+    'A', 'A', 'A', 'A', 'A', 'A',
+    'O', 'O', 'O', 'O', 'O', 'O',
+    'I', 'I', 'I', 'I',
+    'D', 'D', 'D', 'D', 'D',
+    'R', 'R', 'R', 'R', 'R',
+    'T', 'T', 'T', 'T', 'T',
+    'S', 'S', 'S', 'S',
+    'G', 'G', 'G',
+    'K', 'K', 'K',
+    'L', 'L', 'L',
+    'M', 'M', 'M',
+    'B', 'B',
+    'P', 'P',
+    'U', 'U', 'U',
+    'H', 'H',
+    'J', 'J',
+    'V', 'V',
+    'Z', 'Z',
+    'i', 'i', /* IJ */
+    'F',
+    'C', 'C',
+    'W', 'W',
+    'X',
+    'Y',
+    'Q'
+};
+
+#define NB_LETTERVALUES_NL 28
+static lettervalue_t _lettervalues_nl[NB_LETTERVALUES_NL] = {
+    {'.', 0},
+    {'E', 1},
+    {'N', 1},
+    {'A', 1},
+    {'O', 1},
+    {'I', 1},
+    {'D', 2},
+    {'R', 2},
+    {'T', 2},
+    {'S', 2},
+    {'G', 3},
+    {'K', 3},
+    {'L', 3},
+    {'M', 3},
+    {'B', 3},
+    {'P', 3},
+    {'U', 4},
+    {'H', 4},
+    {'J', 4},
+    {'V', 4},
+    {'Z', 4},
+    {'i' /* 'IJ */, 4},
+    {'F', 4},
+    {'C', 5},
+    {'W', 5},
+    {'X', 8},
+    {'Y', 8},
+    {'Q', 10}
+};
+
+static char *_extra_help_nl = "i for IJ";
+
+#endif /*  __BAG_NL__ */
+
+/* vim: set ts=4 sw=4 et: */
index 390ec7dfee789754011f25e2639908f9b96dd28e..a8fc214c3ff9fecf4fb5a08b975643e74726e61c 100644 (file)
@@ -28,8 +28,11 @@ board_t *getboard (char *name)
 }
 
 #include "bag-de.h"
+#include "bag-es.h"
 #include "bag-en.h"
 #include "bag-fr.h"
+#include "bag-it.h"
+#include "bag-nl.h"
 
 static bag_t _bag = {0};
 
@@ -49,15 +52,46 @@ bag_t *getbag (char *lang)
         pt->tiles = _tiles_en;
         pt->nbletters = NB_LETTERVALUES_EN;
         pt->lettervalues = _lettervalues_en;
+    } else if (strcmp (lang, "es") == 0) {
+        pt = &_bag;
+        pt->nbtiles = NB_TILES_ES;
+        pt->tiles = _tiles_es;
+        pt->nbletters = NB_LETTERVALUES_ES;
+        pt->lettervalues = _lettervalues_es;
     } else if (strcmp (lang, "fr") == 0) {
         pt = &_bag;
         pt->nbtiles = NB_TILES_FR;
         pt->tiles = _tiles_fr;
         pt->nbletters = NB_LETTERVALUES_FR;
         pt->lettervalues = _lettervalues_fr;
+    } else if (strcmp (lang, "it") == 0) {
+        pt = &_bag;
+        pt->nbtiles = NB_TILES_IT;
+        pt->tiles = _tiles_it;
+        pt->nbletters = NB_LETTERVALUES_IT;
+        pt->lettervalues = _lettervalues_it;
+    } else if (strcmp (lang, "nl") == 0) {
+        pt = &_bag;
+        pt->nbtiles = NB_TILES_NL;
+        pt->tiles = _tiles_nl;
+        pt->nbletters = NB_LETTERVALUES_NL;
+        pt->lettervalues = _lettervalues_nl;
     }
 
     return pt;
 }
 
+char *getextrahelp (char *lang)
+{
+    char *pt = NULL;
+    if (strcmp (lang, "de") == 0) {
+        pt = _extra_help_de;
+    } else if (strcmp (lang, "es") == 0) {
+        pt = _extra_help_es;
+    } else if (strcmp (lang, "nl") == 0) {
+        pt = _extra_help_nl;
+    }
+    return pt;
+}
+
 /* vim: set ts=4 sw=4 et: */
index 5cb82ffbd58127443a7f8ce858c863019d4fc5f2..1d7f0f40862a3ee918f69b92e89506799a8f4142 100644 (file)
@@ -7,6 +7,8 @@ board_t *getboard (char *name);
 
 bag_t *getbag (char *lang);
 
+char *getextrahelp (char *lang);
+
 #endif /* __CONSTANT_H__ */
 
 /* vim: set ts=4 sw=4 et: */
index db14c788a50965843d3ff58ce8fbee3bd468d55c..ac2b682ae5604a8906cfb8da5f13c452404024cb 100644 (file)
--- a/display.c
+++ b/display.c
@@ -120,19 +120,11 @@ void showboard (play_t *play, board_t *board, int xoffset, int yoffset, int full
     }
 }
 
-void helpwindow (char *msg, int xoffset, int yoffset, int length)
+int _helpwindow (char *msg, int xoffset, int yoffset, int length)
 {
-    char *title = "Help message";
-    int i;
-
-    for (i = 0; (i < length) && (title[i] != '\0'); i++) {
-        mvaddch (yoffset , xoffset + i, title[i]);
-        mvaddch (yoffset + 1, xoffset + i, ACS_HLINE);
-    }
-
-    i = 0;
-    int j = 2;
-    while (*msg != '\0') {
+    int i = 0;
+    int j = 0;
+    while ((msg) && (*msg != '\0')) {
         if ((*msg == '\n') || (i  == length)) {
             i = 0;
             j++;
@@ -143,6 +135,22 @@ void helpwindow (char *msg, int xoffset, int yoffset, int length)
         }
         msg++;
     }
+    return j;
+}
+
+void helpwindow (char *msg, char *msg2, int xoffset, int yoffset, int length)
+{
+    char *title = "Help message";
+    int i;
+
+    for (i = 0; (i < length) && (title[i] != '\0'); i++) {
+        mvaddch (yoffset , xoffset + i, title[i]);
+        mvaddch (yoffset + 1, xoffset + i, ACS_HLINE);
+    }
+    int j = 2;
+    j += _helpwindow (msg, xoffset, yoffset + j, length);
+    j++;
+    j += _helpwindow (msg2, xoffset, yoffset + j, length);
 }
 
 void valuewindow (bag_t *bag, int xoffset, int yoffset, int length)
index 6e817fb870380660334ad904f70d92eac3c15b0d..66d8189f7fb8ad17af653a6947e5d0093c80b3bd 100644 (file)
--- a/display.h
+++ b/display.h
@@ -9,7 +9,7 @@ void showletter (char letter, int x, int y, int mode);
 
 void showboard (play_t *play, board_t *board, int xoffset, int yoffset, int full);
 
-void helpwindow (char *msg, int xoffset, int yoffset, int length);
+void helpwindow (char *msg, char *msg2, int xoffset, int yoffset, int length);
 
 void valuewindow (bag_t *bag, int xoffset, int yoffset, int length);
 
index 206a1c9498f32202c652a52268db35fbf69c2d6a..474311ccb58ad9b11d4baa7efb624cc4f8f6e6a0 100644 (file)
@@ -145,7 +145,7 @@ int main (int argc, char *argv[])
     int ydrawwin = 2 * yoffset + max (board->ysize, 1 + (bag->nbletters + 1) /2);
 
     valuewindow (bag, xvaluewin, yvaluewin, 10);
-    helpwindow (help, xhelpwin, yhelpwin, 30);
+    helpwindow (help, getextrahelp (language), xhelpwin, yhelpwin, 30);
 
     int mode = 0;
     showboard (play, board, xoffset, yoffset, mode);