BlueBubble 1.0
A recommendation algorithm for movies based on a Netlfix database
Loading...
Searching...
No Matches
utilities.cc
Go to the documentation of this file.
1#include "utilities.h"
2#include "coordinates.h"
3#include <iostream>
4
11 return (end.get_x() - start.get_x() == movement.get_x()) && (end.get_y() - start.get_y() == movement.get_y());
12}
13
17 switch (color)
18 {
19 case terminal_black:
20 std::cout << "\033[30m";
21 break;
22 case terminal_red:
23 std::cout << "\033[31m";
24 break;
25 case terminal_green:
26 std::cout << "\033[32m";
27 break;
28 case terminal_yellow:
29 std::cout << "\033[33m";
30 break;
31 case terminal_blue:
32 std::cout << "\033[34m";
33 break;
35 std::cout << "\033[35m";
36 break;
37 case terminal_cyan:
38 std::cout << "\033[36m";
39 break;
40 case terminal_white:
41 std::cout << "\033[37m";
42 break;
43 }
44}
45
49 switch (color)
50 {
51 case terminal_black:
52 std::cout << "\033[40m";
53 break;
54 case terminal_red:
55 std::cout << "\033[41m";
56 break;
57 case terminal_green:
58 std::cout << "\033[42m";
59 break;
60 case terminal_yellow:
61 std::cout << "\033[43m";
62 break;
63 case terminal_blue:
64 std::cout << "\033[44m";
65 break;
67 std::cout << "\033[45m";
68 break;
69 case terminal_cyan:
70 std::cout << "\033[46m";
71 break;
72 case terminal_white:
73 std::cout << "\033[47m";
74 break;
75 }
76}
77
80 std::cout << "\033[0m";
81}
82
86bool correct_input(std::string const & cmd){
87 std::regex mouvmtpattern("[a-h][1-8][a-h][1-8]");
88 std::regex kingcastlemouvmtpattern("(O|o|0)-(O|o|0)");
89 std::regex queencastlemouvmtpattern("(O|o|0)-(O|o|0)-(O|o|0)");
90 return regex_match(cmd,mouvmtpattern) || regex_match(cmd,kingcastlemouvmtpattern) || regex_match(cmd,queencastlemouvmtpattern);
91}
92
96bool standard_input(std::string const & cmd){
97 std::regex mouvmtpattern("[a-h][1-8][a-h][1-8]");
98 return regex_match(cmd,mouvmtpattern);
99}
100
104bool king_castle_input(std::string const & cmd){
105 std::regex kingcastlemouvmtpattern("(O|o|0)-(O|o|0)");
106 return regex_match(cmd,kingcastlemouvmtpattern);
107}
108
112bool queen_castle_input(std::string const & cmd){
113 std::regex queencastlemouvmtpattern("(O|o|0)-(O|o|0)-(O|o|0)");
114 return regex_match(cmd,queencastlemouvmtpattern);
115}
116
119void print_debug(int i){
120 std::cout << "test" << i << std::endl;
121}
a class representing coordinates
Definition coordinates.h:5
int get_x()
a function to get the x-axis attribute
Definition coordinates.cc:6
int get_y()
a function to get the y-axis attribute
terminal_color
a type for terminal colors, used in the print functions.
Definition config.h:5
@ terminal_blue
Definition config.h:5
@ terminal_cyan
Definition config.h:5
@ terminal_magenta
Definition config.h:5
@ terminal_green
Definition config.h:5
@ terminal_white
Definition config.h:5
@ terminal_black
Definition config.h:5
@ terminal_yellow
Definition config.h:5
@ terminal_red
Definition config.h:5
void print_debug(int i)
Print a message to the standard output : "test i". Used for debug purposes.
Definition utilities.cc:119
bool king_castle_input(std::string const &cmd)
Check if an input correponds to a king castling move.
Definition utilities.cc:104
void terminal_reset_all()
reset all terminal attributes
Definition utilities.cc:79
bool standard_input(std::string const &cmd)
Check if an input corresponds to a standard move.
Definition utilities.cc:96
bool correct_input(std::string const &cmd)
Check if an input is conform.
Definition utilities.cc:86
void terminal_set_background_color(terminal_color color)
set the terminal background color to the input
Definition utilities.cc:48
bool queen_castle_input(std::string const &cmd)
Check if an input corresponds to a queen castling move.
Definition utilities.cc:112
void terminal_set_text_color(terminal_color color)
set the terminal font color to the input
Definition utilities.cc:16
bool is_corresponding(coordinates start, coordinates end, coordinates movement)
verify if a movement is corresponding to a starting and ending coordinates
Definition utilities.cc:10