From afa02f645056c5823b0d8a29d37c1ff10aedce7a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Feb 2024 21:53:44 -0600 Subject: init --- robber.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 robber.h (limited to 'robber.h') 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 cop; + +template +class robber : public npc { + 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 unsigned int robber::total_loot_value = 0; + +#include "robber.hpp" + +#endif -- cgit v1.2.3