int handle_buffer(const char *buffer, t_vec *database, t_term *term)
{
- if (!ft_strcmp(buffer, "\033[A"))
+ if (!ft_strcmp(buffer, "\033[A") || !ft_strcmp(buffer, "k"))
{
if (term->y > 1)
{
--term->y;
- ft_putstr_fd(buffer, STDOUT_FILENO);
+ ft_putstr_fd("\033[A", STDOUT_FILENO);
}
else if (term->top_row > 0)
--term->top_row;
}
- else if (!ft_strcmp(buffer, "\033[B"))
+ else if (!ft_strcmp(buffer, "\033[B") || !ft_strcmp(buffer, "j"))
{
if (term->y < term->height && term->y < database->size - term->top_row)
{
++term->y;
- ft_putstr_fd(buffer, STDOUT_FILENO);
+ ft_putstr_fd("\033[B", STDOUT_FILENO);
}
else if (database->size - term->top_row > term->height)
++term->top_row;
}
- else if (!ft_strcmp(buffer, "k") && term->top_row + term->y - 1 < database->size)
- kill_entry(database, term->top_row + term->y - 1);
+ else if (!ft_strcmp(buffer, "d") && term->top_row + term->y - 1 < database->size)
+ defeat_entry(database, term->top_row + term->y - 1);
else if (!ft_strcmp(buffer, "q") || !ft_strcmp(buffer, "\033"))
return (1);
return (0);
entry->name,
entry->level,
entry->biome,
- entry->kill_time);
+ entry->defeat_time);
return (0);
}
char *color;
static const char *reset_color = "\033[0m";
- countdown = 3600 - (get_time_sec() - entry->kill_time);
+ countdown = 3600 - (get_time_sec() - entry->defeat_time);
countdown = ft_max(0, countdown);
if (countdown == 0)
color = "\033[42m";
new_entry.biome = line;
if (advance_line(&line))
return (1);
- new_entry.kill_time = ft_atoi(line);
+ new_entry.defeat_time = ft_atoi(line);
if (advance_line(&line))
return (1);
if (*line != '\0')
entry->name = datastr;
entry->level = ft_atoi(argv[3]);
entry->biome = datastr + namelen + 1;
- entry->kill_time = 0;
+ entry->defeat_time = 0;
return (0);
}
}
else if (argc == 3)
{
- if (ft_strcmp(argv[1], "-k") && ft_strcmp(argv[1], "-r"))
+ if (ft_strcmp(argv[1], "-d") && ft_strcmp(argv[1], "-r"))
return (1);
command->entry.name = argv[2];
- if (argv[1][1] == 'k')
- command->basic = basic_kill;
+ if (argv[1][1] == 'd')
+ command->basic = basic_defeat;
else if (argv[1][1] == 'r')
command->basic = basic_remove;
return (0);
return (1);
}
-void kill_entry(t_vec *database, size_t ind)
+void defeat_entry(t_vec *database, size_t ind)
{
t_entry entry;
entry = *(t_entry *)ft_vec_access(database, ind);
- entry.kill_time = get_time_sec();
+ entry.defeat_time = get_time_sec();
ft_vec_forget(database, ind);
ft_vec_append(database, &entry);
return ;
"\t\tPrint this help.\n"
"\t-l\n"
"\t\tPrint the list in a loop. End by using Q key.\n"
- "\t-k boss\n"
- "\t\tMark the boss as killed, setting the counter to 60 minutes.\n"
+ "\t-d boss\n"
+ "\t\tMark the boss as defeated, setting the counter to 60 minutes.\n"
"\t-a boss level location\n"
"\t\tAdd a boss to the database. Long strings may break formatting.\n"
"\t-r boss\n"
ft_printf("Problem with the name!\n");
return ;
}
- if (com->basic == basic_kill)
- kill_entry(database, ind);
+ if (com->basic == basic_defeat)
+ defeat_entry(database, ind);
else if (com->basic == basic_remove)
ft_vec_erase(database, ind, free_entry);
else if (com->basic == basic_add)