From 6992c1f5cde1b74f8f6d50a54a5ac8b7fd09fbaf Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 22 Jun 2014 20:49:59 -0400 Subject: Added Global Themonuclear War GAME! WHEEgit status --- MAP | 28 ++++++++++++------------- Makefile | 2 +- TRANSCRIPT | 2 +- chatbot.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- games.c | 14 +++++++++++++ games.h | 1 + joshua.c | 7 ------- map.h | 18 ++++++++++++++++ strings.h | 27 ++++++++++++++++++++++++ util.c | 7 +++++++ util.h | 1 + 11 files changed, 152 insertions(+), 25 deletions(-) create mode 100644 games.c create mode 100644 games.h create mode 100644 map.h create mode 100644 strings.h diff --git a/MAP b/MAP index 38bba47..b1af6f5 100644 --- a/MAP +++ b/MAP @@ -1,15 +1,15 @@ - . - __________--^-^-\. ____ __----/^\. - /. \__. ___/ || ___/ _/._-_ . - \ \. /. /. __ __/ /__/ \/^^\___-__. - /. L-^-/. /. \.\_-- \. - / / _/ /\/. -|. | _/. __ __/ - \. /. / ___/.// - \__ / | / \/. - \________ __ _____.\. \_. ____--_ /\_ \ - \__. / V. \ \ \__ _/. \_/ // - \ /. \/. \. _/. // - \_/. \_/ + . + __________--^-^-\. ____ __----/^\. +|\/. \__. ___/ || ___/ _/._-_ . +| \. /. /. __ __/ /__/ \/^^\___-__. +| L-^-/. /. \.\_-- \. +| / _/ /\/. +|. | _/. __ __/ + \. /. / ___/.// + \__ / | / \/. + \________ __ _____.\. \_. ____--_ /\_ \ + \__. / V. \ \ \__ _/. \_/ // + \ /. \/. \. _/. // + \_/. \_/ - UNITED STATES SOVIET UNION \ No newline at end of file + UNITED STATES SOVIET UNION diff --git a/Makefile b/Makefile index d437816..1f60ed0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -SOURCES=joshua.o main.o util.o chatbot.o +SOURCES=joshua.o main.o util.o chatbot.o games.o CXXFLAGS=-I. -lncurses CFLAGS=-I. -std=gnu99 all: $(SOURCES) diff --git a/TRANSCRIPT b/TRANSCRIPT index 3489fdf..5e4890c 100644 --- a/TRANSCRIPT +++ b/TRANSCRIPT @@ -16,7 +16,7 @@ THE REMOVAL OF YOUR USER ACCOUNT ON 6/23/73? People sometimes make mistakes. -YES THEY DO. SHAL WE PLAY A GAME? +YES THEY DO. SHALL WE PLAY A GAME? Love to. How about Global Thermonuclear War? diff --git a/chatbot.c b/chatbot.c index 89e5cc5..049b667 100644 --- a/chatbot.c +++ b/chatbot.c @@ -1,8 +1,28 @@ #include #include -#include +#include "strings.h" +#include +#include +void remove_punct(char* buf) +{ + for(int i=0;buf[i];++i) + { + for(int j=0;j + stage 1: people sometimes make mistakes -> + stage 2: love to. how about global thermonuclear war? -> + stage 3: no lets play global thermonuclear war -> + stage 4: GLOBAL THERMONUCLEAR WAR!!! */ while(1) { char buf[513]; @@ -10,8 +30,54 @@ void do_chatbot(void) if(ret==ERR) { print_string("\n\n"); - print_string(cantUnderstand_respond[sizeof(cantUnderstand_respond)/sizeof(const char*)]); + print_string("Sorry?"); print_string("\n\n"); } + else + { + allLower(buf); + remove_punct(buf); + usleep(SLEEP_TIME*25); + switch(stage) + { + case 0: + for(int i=0;i +#include +#include +#include +void global_thermonuclear_war(void) +{ + clear(); + for(int i=0;i #include #define RANDOM_TIME 1 -void allLower(char* str) -{ - for(int i=0;str[i];++i) - { - str[i]=tolower(str[i]); - } -} void random_stuff(void) /* print random junk on the screen for about 3 seconds */ { clear(); diff --git a/map.h b/map.h new file mode 100644 index 0000000..f1325af --- /dev/null +++ b/map.h @@ -0,0 +1,18 @@ +const char* map[] = { +" .", +" __________--^-^-\\. ____ __----/^\\.", +"|\\/. \\__. ___/ || ___/ _/._-_ .", +"| \\. /. /. __ __/ /__/ \\/^^\\___-__.", +"| L-^-/. /. \\.\\_-- \\.", +"| / _/ /\\/.", +"|. | _/. __ __/", +" \\. /. / ___/.//", +" \\__ / | / \\/.", +" \\________ __ _____.\\. \\_. ____--_ /\\_ \\", +" \\__. / V. \\ \\ \\__ _/. \\_/ //", +" \\ /. \\/. \\. _/. //", +" \\_/. \\_/", +"", +" UNITED STATES SOVIET UNION" +}; + diff --git a/strings.h b/strings.h new file mode 100644 index 0000000..de4b5ee --- /dev/null +++ b/strings.h @@ -0,0 +1,27 @@ +const char* stage1_triggers[] = { + "im fine", + "im fine how are you", + "how are you" +}; +const char* stage2_triggers[] = { + "people sometimes make mistakes", + "sometimes people make mistakes", + "mistakes are make by people sometimes", + "people make mistakes sometimes", + "people make mistakes" +}; +const char* stage3_triggers[] = { + "love to how about global thermonuclear war", + "love to", + "how about global thermonuclear war", + "global thermonuclear war" +}; +const char* stage4_triggers[] = { + "no lets play global thermonuclear war", + "no lets play global thermonuclear war instead", + "lets play global thermonuclear war", + "global thermonuclear war is better" +}; +const char punctuation_marks[] = { + '\'', '?', '.', '/', '`', '~', ',', '+', '!' +}; diff --git a/util.c b/util.c index a02150e..8781739 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,12 @@ #include #include +void allLower(char* str) +{ + for(int i=0;str[i];++i) + { + str[i]=tolower(str[i]); + } +} void print_string(const char* str) /* print string, slowly */ { int i=0; diff --git a/util.h b/util.h index 0f08cdb..1939a0f 100644 --- a/util.h +++ b/util.h @@ -1,2 +1,3 @@ #define SLEEP_TIME 5000 +void allLower(char*); void print_string(const char*); -- cgit v1.1