diff options
| -rw-r--r-- | Makefile | 11 | ||||
| -rw-r--r-- | joshua.c | 15 | ||||
| -rw-r--r-- | strings.c | 14 | ||||
| -rw-r--r-- | strings.h | 1 | ||||
| -rw-r--r-- | util.h | 2 |
5 files changed, 34 insertions, 9 deletions
@@ -1,8 +1,9 @@ SOURCES=joshua.o main.o util.o chatbot.o games.o strings.o HEADERS=chatbot.h games.h joshua.h location.h strings.h map.h util.h -CXXFLAGS=-I. -lncurses -g -CFLAGS=-I. -std=gnu99 -g -all: $(SOURCES) $(HEADERS) - g++ $(SOURCES) -lncurses +CXXFLAGS=-I. -lncurses -g -O3 +CFLAGS=-I. -std=gnu99 -g -O3 +wargames: $(SOURCES) $(HEADERS) + g++ $(SOURCES) $(CXXFLAGS) -lncurses -o wargames +all: wargames Makefile clean: - rm -f $(SOURCES) a.out *~ + rm -f $(SOURCES) a.out wargames *~ @@ -6,6 +6,7 @@ #include <signal.h> #include <unistd.h> #include <string.h> +#include "strings.h" void cleanup(int signum) { endwin(); @@ -70,7 +71,19 @@ void be_joshua() usleep(SLEEP_TIME*100); print_string("GREETINGS, PROFESSOR FALKEN.\n\n"); refresh(); - getnstr(buf, 32); /* ignore this */ + getnstr(buf, 32); + allLower(buf); + remove_punct(buf); + for(int i=0;i<sizeof(exit_triggers)/sizeof(const char*);++i) + { + if(strcmp(buf, exit_triggers[i])==0) + { + print_string("\n\n"); + print_string(exit_responses[rand()%sizeof(exit_responses)/sizeof(const char*)]); + print_string("\n--CONNECTION TERMINATED--"); + return; + } + } print_string("\n\nHOW ARE YOU FEELING TODAY?\n\n"); refresh(); do_chatbot(); @@ -29,6 +29,16 @@ const char* stage4_triggers[] = { "lets play global thermonuclear war", "global thermonuclear war is better" }; +const char* tictactoe_triggers[] = { + "lets play tic tac toe", + "lets play tic-tac-toe", + "lets play tictactoe", + "how about tic-tac-toe", + "how about tic tac toe", + "play tic-tac-toe", + "play tictactoe", + "play tic tac toe" +}; const char* exit_triggers[] = { "goodbye", "good-bye", @@ -39,8 +49,8 @@ const char* exit_triggers[] = { }; const char* exit_responses[] = { "GOODBYE.", - "BYE!", - "BYE-BYE!", + "BYE.", + "BYE-BYE.", "GOOD-BYE.", }; const char punctuation_marks[] = { @@ -4,6 +4,7 @@ const char* stage1_triggers[5]; const char* stage2_triggers[6]; const char* stage3_triggers[4]; const char* stage4_triggers[7]; +const char* tictactoe_triggers[]; const char punctuation_marks[9]; const char* exit_triggers[6]; const char* exit_responses[4]; @@ -1,4 +1,4 @@ -#define SLEEP_TIME 0 +#define SLEEP_TIME 10000 void allLower(char*); void print_string(const char*); void remove_punct(char*); |