aboutsummaryrefslogtreecommitdiffstats
path: root/src/Quest.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-10-13 08:51:49 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-10-13 08:51:49 -0400
commit5adabb82443b9b10b25cdd8b4db3cfe890e36fa1 (patch)
tree698e88e97b0fd0c526bec844f345e9aa4ef24321 /src/Quest.cpp
parent3d375c17982f9f459c82364117687d145540fe75 (diff)
parent58716d5e4f20eb5a30025c88fe5119a0e40c4187 (diff)
Added rabbit, and player health
Diffstat (limited to 'src/Quest.cpp')
-rw-r--r--src/Quest.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Quest.cpp b/src/Quest.cpp
index c331e32..5d19795 100644
--- a/src/Quest.cpp
+++ b/src/Quest.cpp
@@ -1,5 +1,6 @@
-#include <Quest.h>
-#include <entities.h>
+#include <common.h>
+//#include <Quest.h>
+//#include <entities.h>
const Quest QuestList[TOTAL_QUESTS]={
Quest("Test","A test quest",(struct item_t){1,TEST_ITEM})
@@ -22,17 +23,26 @@ Quest::~Quest(){
int QuestHandler::assign(const char *t){
unsigned char i;
- for(i=0;i<current.size();i++){
+ for(i=0;i<current.size();i++){ // Make sure we don't already have this quest
if(!strcmp(current[i]->title,t)){
+#ifdef DEBUG
+ DEBUG_printf("The QuestHandler already has this quest: %s\n",t);
+#endif // DEBUG
return -2;
}
}
- for(i=0;i<TOTAL_QUESTS;i++){
+ for(i=0;i<TOTAL_QUESTS;i++){ // Add the quest (if it really exists)
if(!strcmp(QuestList[i].title,t)){
current.push_back(&QuestList[i]);
+#ifdef DEBUG
+ DEBUG_printf("Added quest %s, now have %u active quests.\n",t,current.size());
+#endif // DEBUG
return current.size();
}
}
+#ifdef DEBUG
+ DEBUG_printf("Quest %s does not exist.\n",t);
+#endif // DEBUG
return -1;
}
@@ -52,11 +62,20 @@ int QuestHandler::finish(const char *t,void *completer){
unsigned int r;
for(i=0;i<current.size();i++){
if(!strcmp(current[i]->title,t)){
+#ifdef DEBUG
+ DEBUG_printf("Completing quest %s.\n",t);
+#endif // DEBUG
((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);
current.erase(current.begin()+i);
+#ifdef DEBUG
+ DEBUG_printf("QuestHandler now has %u active quests.\n",current.size());
+#endif // DEBUG
return 0;
}
}
+#ifdef DEBUG
+ DEBUG_printf("QuestHandler never had quest %s.\n",t);
+#endif // DEBUG
return -1;
}