summaryrefslogtreecommitdiff
path: root/robber.h
diff options
context:
space:
mode:
authorroot <root@bpcserver.bpcserver>2024-02-27 21:53:44 -0600
committerroot <root@bpcserver.bpcserver>2024-02-27 21:53:44 -0600
commitafa02f645056c5823b0d8a29d37c1ff10aedce7a (patch)
tree0bc89e7909c17d8f33538ac9f31a641872b89f40 /robber.h
Diffstat (limited to 'robber.h')
-rw-r--r--robber.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/robber.h b/robber.h
new file mode 100644
index 0000000..7193ae6
--- /dev/null
+++ b/robber.h
@@ -0,0 +1,70 @@
+#ifndef ROBBER_H
+#define ROBBER_H
+
+// Programmer: Brett Weiland
+// Date: 4/30/23
+// File: robber.h
+// Assignment: SP-B-finalProject
+// Purpose: contains robber class, an npc that steals money and runs away from cops.
+// has different characteristics based on greedy variable, wanted to use a single
+// object for both greedy and non-greedy robbers to ensure I was following the assignment.
+
+#include "npc.h"
+
+
+template <class T>
+class cop;
+
+template <class T>
+class robber : public npc<T> {
+ private:
+ //even while our inherited inventory is of inherited constant INVENTORY_SIZE,
+ //we can't pick up more then BAG_SIZE. INVENTORY_SIZE is used due to the fact we can't
+ //change the length of the array during construction; see npc.h for more info.
+ const unsigned int BAG_SIZE = 7;
+
+ //maximum amount of consecutive moves a robber can make if something allows them to make more
+ const unsigned int MAX_MOVES = 3;
+
+ //Desc: called to handle what happens when we run into a certain type of object.
+ //Pre: valid peer passed
+ //Post: interaction is carried out dependent on what type of gameObject we're dealing with
+ bool handleInteractable(gameObject &peer);
+
+ //Desc: finds all gameObjects we are located on and calls handleInteractable
+ //Pre: none
+ //Post: handleInteractable called for each gameObject we are stacked on
+ bool iterateInteractables();
+
+ //changes how the robber moves. If this is set to true,
+ //robber will always move twords a random jewl if available,
+ //and will bribe officer with one inventory item to release all robbers.
+ //if robber is greedy and runs into another rober, half of inventory is dropped.
+ //robber can move up to MAX_MOVES times in a round if they get an item with even value.
+ bool greedy;
+ static unsigned int total_loot_value;
+
+ public:
+ //Desc: called when robber is arrested. returns inventory pointer to caller,
+ // cop uses this to record items in their own stash.
+ //Pre: none
+ //Post: npc is no longer active (can't move), more behavior is defined by cop arrest() function
+ T **getArrested();
+
+ //overriden functions, see respective files
+ void move() override; //npc.h
+ char getIcon() const override; //gameObject.h
+ unsigned int get_drawPriority() const override; //gameObject.h
+
+ //getters and setters
+ void setGreedy(const bool greedy_value);
+ bool isGreedy() const;
+ void free(); //sets us to active
+ unsigned int get_totalRobberValue() const; //returns combined value of ALL robbers
+};
+
+template <class T> unsigned int robber<T>::total_loot_value = 0;
+
+#include "robber.hpp"
+
+#endif