aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <franklin@fwei.tk>2014-06-23 18:23:58 +0000
committerFranklin Wei <franklin@fwei.tk>2014-06-23 18:23:58 +0000
commit7281c95860a5c9e6d3f445b5a884c4d07d56dc77 (patch)
treec50169db30de6c5ff46c7ed0b0fc585c04522e0d
parentd475113ce1b325aa06e875ef0599e03c882da1de (diff)
downloadwargames-server-7281c95860a5c9e6d3f445b5a884c4d07d56dc77.zip
wargames-server-7281c95860a5c9e6d3f445b5a884c4d07d56dc77.tar.gz
wargames-server-7281c95860a5c9e6d3f445b5a884c4d07d56dc77.tar.bz2
wargames-server-7281c95860a5c9e6d3f445b5a884c4d07d56dc77.tar.xz
more bugfixes..
-rw-r--r--Makefile11
-rw-r--r--joshua.c15
-rw-r--r--strings.c14
-rw-r--r--strings.h1
-rw-r--r--util.h2
5 files changed, 34 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index f41cff6..8382f75 100644
--- a/Makefile
+++ b/Makefile
@@ -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 *~
diff --git a/joshua.c b/joshua.c
index fb7190c..33fceb8 100644
--- a/joshua.c
+++ b/joshua.c
@@ -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();
diff --git a/strings.c b/strings.c
index a2be3d9..e0ec652 100644
--- a/strings.c
+++ b/strings.c
@@ -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[] = {
diff --git a/strings.h b/strings.h
index da14086..411a5c4 100644
--- a/strings.h
+++ b/strings.h
@@ -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];
diff --git a/util.h b/util.h
index 63409fa..3070d39 100644
--- a/util.h
+++ b/util.h
@@ -1,4 +1,4 @@
-#define SLEEP_TIME 0
+#define SLEEP_TIME 10000
void allLower(char*);
void print_string(const char*);
void remove_punct(char*);