summaryrefslogtreecommitdiff
path: root/robber.h
blob: 7193ae6eae0f1d2ceaa35120dc7f33811add9a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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