aboutsummaryrefslogtreecommitdiffstats
path: root/src/Quest.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-08 17:01:40 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-08 17:01:40 -0400
commit60c7924097814686a2fb826b87fd7a3e1ff684de (patch)
tree3fd2c80bacf521960cbebcf48707c05c1bf0904e /src/Quest.cpp
parent51e40764ce718283c89422cd5e3d02d324c7d16c (diff)
Added quests
Diffstat (limited to 'src/Quest.cpp')
-rw-r--r--src/Quest.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Quest.cpp b/src/Quest.cpp
new file mode 100644
index 0000000..52ab3a8
--- /dev/null
+++ b/src/Quest.cpp
@@ -0,0 +1,64 @@
+#include <Quest.h>
+
+Quest QuestList[TOTAL_QUESTS]={
+ Quest("Test","A test quest",0)
+};
+
+Quest::Quest(){
+}
+Quest::Quest(const char *t,const char *d,unsigned int x){
+ size_t len;
+ title=(char *)malloc((len=strlen(t)));
+ strncpy(title,t,len);
+ desc=(char *)malloc((len=strlen(d)));
+ strncpy(desc,d,len);
+ xp=x;
+}
+Quest::~Quest(){
+ free(title);
+ free(desc);
+ xp=0;
+}
+
+QuestHandler::QuestHandler(){
+ ccnt=0;
+}
+int QuestHandler::assign(const char *t){
+ unsigned int i=0;
+ if(ccnt==QUEST_LIMIT)
+ return -1;
+ for(;i<TOTAL_QUESTS;i++){
+ if(!strcmp(QuestList[i].title,t)){
+ current[ccnt++]=&QuestList[i];
+ return ccnt;
+ }
+ }
+ return -1;
+}
+int QuestHandler::drop(const char *t){
+ unsigned char i=0;
+ for(;i<ccnt;i++){
+ if(!strcmp(current[i]->title,t)){
+ for(i++;i<ccnt;i++){
+ current[i-1]=current[i];
+ }
+ return (--ccnt);
+ }
+ }
+ return -1;
+}
+int QuestHandler::finish(const char *t){
+ unsigned char i=0;
+ unsigned int j;
+ for(;i<ccnt;i++){
+ if(!strcmp(current[i]->title,t)){
+ j=current[i]->xp;
+ for(i++;i<ccnt;i++){
+ current[i-1]=current[i];
+ }
+ ccnt--;
+ return j;
+ }
+ }
+ return -1;
+}