From 314aa1044b78ad58e0a9e53b38c91de8714b5922 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 22 Jun 2014 16:47:24 -0400 Subject: Added map, improved logon garbage --- MAP | 15 +++++++++++++++ Makefile | 2 +- README.md | 3 +++ chatbot.c | 17 +++++++++++++++++ chatbot.h | 1 + joshua.c | 38 ++++++++++---------------------------- util.c | 13 +++++++++++++ util.h | 2 ++ 8 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 MAP create mode 100644 README.md create mode 100644 chatbot.c create mode 100644 chatbot.h create mode 100644 util.c create mode 100644 util.h diff --git a/MAP b/MAP new file mode 100644 index 0000000..64f6b85 --- /dev/null +++ b/MAP @@ -0,0 +1,15 @@ + + __________--^-^-\ ___ __-/^^\ + /. \__. ___/ || __/ _/ _-_ + \ \. / / _ __/^ /__/ \/^^\___-__ + / L-^-/ / | \_-- \ +/ ( / /\/ +| | _/ __ __/ +\ / / ___/_// + \__ / | / \/ + \________ __ _____ \ \_ __--_ ^\_ \ + \__ / V \ \ \__ _/ \-/ // + \ / \/ \ _/ // + \_/ \_/ + + UNITED STATES SOVIET UNION \ No newline at end of file diff --git a/Makefile b/Makefile index b021949..d437816 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCES=joshua.o main.o +SOURCES=joshua.o main.o util.o chatbot.o CXXFLAGS=-I. -lncurses CFLAGS=-I. -std=gnu99 all: $(SOURCES) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8facc37 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +==WarGames== + +Program to simulate the W.O.P.R. from WarGames. \ No newline at end of file diff --git a/chatbot.c b/chatbot.c new file mode 100644 index 0000000..89e5cc5 --- /dev/null +++ b/chatbot.c @@ -0,0 +1,17 @@ +#include +#include +#include +void do_chatbot(void) +{ + while(1) + { + char buf[513]; + int ret=getnstr(buf, 512); + if(ret==ERR) + { + print_string("\n\n"); + print_string(cantUnderstand_respond[sizeof(cantUnderstand_respond)/sizeof(const char*)]); + print_string("\n\n"); + } + } +} diff --git a/chatbot.h b/chatbot.h new file mode 100644 index 0000000..c3c1db0 --- /dev/null +++ b/chatbot.h @@ -0,0 +1 @@ +void do_chatbot(void); diff --git a/joshua.c b/joshua.c index 29083a0..cf6311b 100644 --- a/joshua.c +++ b/joshua.c @@ -1,8 +1,9 @@ #include +#include #include #include +#include #define RANDOM_TIME 1 -#define SLEEP_TIME 50000 void allLower(char* str) { for(int i=0;str[i];++i) @@ -10,36 +11,15 @@ void allLower(char* str) str[i]=tolower(str[i]); } } -void print_string(const char* str) /* print string, slowly */ -{ - int i=0; - while(str[i]) - { - addch(str[i]); - usleep(SLEEP_TIME); - beep(); - refresh(); - ++i; - } -} void random_stuff(void) /* print random junk on the screen for about 3 seconds */ { - int maxx, maxy; - int stop=time(0)+RANDOM_TIME; - getmaxyx(stdscr, maxy, maxx); clear(); - for(;time(0)<=stop;) - { - for(int x=0;x +#include +void print_string(const char* str) /* print string, slowly */ +{ + int i=0; + while(str[i]) + { + addch(str[i]); + usleep(SLEEP_TIME); + refresh(); + ++i; + } +} diff --git a/util.h b/util.h new file mode 100644 index 0000000..0f08cdb --- /dev/null +++ b/util.h @@ -0,0 +1,2 @@ +#define SLEEP_TIME 5000 +void print_string(const char*); -- cgit v1.1