summaryrefslogtreecommitdiff
path: root/dartboat.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-25 02:49:40 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-25 02:49:40 -0700
commit0517dcffe7ac66b604143d9457ba6591d34ae07e (patch)
tree5c83278e4a842178b10a5c2ff7ff1a96a8ddf809 /dartboat.c
parent9edcd68e7ddcdc4deca8c07b5b1c3c59cef13255 (diff)
downloaddartboat-0517dcffe7ac66b604143d9457ba6591d34ae07e.tar.gz
dartboat-0517dcffe7ac66b604143d9457ba6591d34ae07e.tar.xz
curses: use suggested checkout function from lib
Diffstat (limited to 'dartboat.c')
-rw-r--r--dartboat.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/dartboat.c b/dartboat.c
index 58cddfc..743c91b 100644
--- a/dartboat.c
+++ b/dartboat.c
@@ -7,6 +7,7 @@
#include <ncurses.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
void test_match(int start_points)
@@ -38,27 +39,12 @@ void user_visit(struct leg *l, char *name)
char status[100];
int len = sprintf(status, " %s has %d remaining", name, l->rem);
- if (l->rem <= 170) {
- char *target = CHECKOUTS[2][l->rem-1];
- if (target) {
- int trem = l->rem - segment_points(
- segment_from_name(target));
- len += sprintf(status + len, " (%s", target);
- if (trem) {
- target = CHECKOUTS[1][trem-1];
- len += sprintf(status + len, "-%s", target);
- trem = trem - segment_points(
- segment_from_name(target));
-
- if (trem) {
- target = CHECKOUTS[0][trem-1];
- len += sprintf(status + len,
- "-%s", target);
- }
- }
- len += sprintf(status + len, ")");
- }
+ int len_co = checkouts_suggested(status + len + 2, l->rem, 3);
+ if (len_co) {
+ memcpy(status + len, " (", 2);
+ memcpy(status + len + 2 + len_co, ")", 2);
}
+
char prompt[] = " enter points> ";
curses_status(status);
curses_prompt(prompt);