Code cleanup and fix the logic behind the player constants number
[Project_algorithmic_C.git] / lib / ui.c
index c75e3b01ca69f981a1544455fc6aaf51494968b3..ae14d1df861be54fe1d6160ecef48c86d660d3f2 100644 (file)
--- a/lib/ui.c
+++ b/lib/ui.c
@@ -56,6 +56,12 @@ void print_board(int y, int x) {
     mvprintw(y+25, x, " -----+----+----+----+----+----+----+-----");
 }
 
+static void set_default_colors() {
+
+    init_pair(1, COLOR_WHITE, COLOR_BLACK);
+    attron(COLOR_PAIR(1));
+}
+
 static void print_o(int y, int x, unsigned int type) {
 
     if (type == black) {
@@ -69,8 +75,7 @@ static void print_o(int y, int x, unsigned int type) {
     mvprintw(y, x, "/\\");
     mvprintw(y+1, x, "\\/");
     /* reset to default */
-    init_pair(1, COLOR_WHITE, COLOR_BLACK);
-    attron(COLOR_PAIR(1));
+    set_default_colors();
 }
 
 /* will be used for pawn placement hints */
@@ -86,8 +91,7 @@ static void print_x(int y, int x, unsigned int type) {
     mvprintw(y, x, "\\/");
     mvprintw(y+1, x,"/\\");
     /* reset to default */
-    init_pair(1, COLOR_WHITE, COLOR_BLACK);
-    attron(COLOR_PAIR(1));
+    set_default_colors();
 }
 
 /* y = 1: y -> 0      x = 1: 1 -> 1