aboutsummaryrefslogtreecommitdiff
path: root/rush01/ex00/helper.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-15 08:15:37 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-15 08:15:37 +0200
commit3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f (patch)
tree25b02c02f5140dbefbabd7720f292d8be3d5cc51 /rush01/ex00/helper.c
parentc2bf9fcefbb4453cee271ccd1af9674ad2f3a181 (diff)
downloadpiscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.tar.gz
piscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.tar.bz2
piscine-3b9a1d7dcc5683b962f2bf24795e80e1c449cd1f.zip
c07 passed, c08 in progress, rush01(+ 6x6 try)
Diffstat (limited to 'rush01/ex00/helper.c')
-rw-r--r--rush01/ex00/helper.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/rush01/ex00/helper.c b/rush01/ex00/helper.c
new file mode 100644
index 0000000..bab12d5
--- /dev/null
+++ b/rush01/ex00/helper.c
@@ -0,0 +1,69 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* helper.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/13 12:52:42 by cacharle #+# #+# */
+/* Updated: 2019/07/14 17:44:58 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <unistd.h>
+#include "include.h"
+
+void ft_putchar(char c)
+{
+ write(1, &c, 1);
+}
+
+void ft_putnbr(int nb)
+{
+ unsigned int p_nb;
+
+ p_nb = nb;
+ if (nb < 0)
+ {
+ write(1, "-", 1);
+ p_nb = -nb;
+ }
+ if (p_nb > 9)
+ ft_putnbr(p_nb / 10);
+ ft_putchar(p_nb % 10 + '0');
+}
+
+int get_with_view(t_board board, t_view_point view, int view_line,
+ int line_index)
+{
+ if (view == row_left)
+ return (board[view_line][line_index]);
+ if (view == row_right)
+ return (board[view_line][3 - line_index]);
+ if (view == col_up)
+ return (board[line_index][view_line]);
+ if (view == col_down)
+ return (board[3 - line_index][view_line]);
+ return (-1);
+}
+
+int check_arg(char *str)
+{
+ int i;
+
+ i = 0;
+ while (str[i])
+ {
+ if (!(str[i] >= '1' && str[i] <= '4'))
+ return (FALSE);
+ i++;
+ if (!str[i])
+ break ;
+ if (str[i] != ' ')
+ return (FALSE);
+ i++;
+ }
+ if (i != 31)
+ return (FALSE);
+ return (TRUE);
+}