-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.h
More file actions
159 lines (116 loc) · 4.62 KB
/
Player.h
File metadata and controls
159 lines (116 loc) · 4.62 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#ifndef PLAYER_H
#define PLAYER_H
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <fstream> // for file operations
#include "Enemy.h"
#include "Table.h"
#include "ItemList.h"
#include "ScrapList.h"
class ShopItem; // prevent ciruclar dependencies
class Player {
private:
static Player *instance; // Static pointer to hold the single instance of Player
std::string playerName;
int playerReputation;
sf::CircleShape circle; // Circle shape for to represent the Player
float fSpeed;
bool hasFortuneCat; // Track if the player has purchased Fortune Cat
bool hasFortunePig; // Track if the player has purchased Fortune Pig
bool hasFortuneMask; // Track if the player has purchased Fortune Mask
sf::Clock fortuneCatTimer; // Timer for reputation gain
sf::Clock fortunePigTimer; // Timer for reputation gain
sf::Clock fortuneMaskTimer; // Timer for reputation gain
ItemList bag; // ItemList instance
ScrapList apron; // ScrapList instance
Enemy enemy; // Enemy instance
// Private constructors to prevent instantiation
Player();
Player(std::string playerName, int playerReputation);
public:
// Static method to access the single instance of Player
static Player *getInstance();
// Getter & Setter for playerName
std::string getPlayerID();
void setPlayerID(const std::string &playerName);
// Getter & Setter for playerReputation
int getPlayerReputation();
void setPlayerReputation(int playerReputation);
// Get player's circle
sf::CircleShape getCircle();
// Get position of the player
sf::Vector2f getPosition();
// Method to set the player's position
void setPosition(const sf::Vector2f& position);
// Draw the Player
void draw(sf::RenderWindow& window);
// Method for Click handling
bool isClicked(float mouseX, float mouseY);
// Method to get the global bounds of the player
sf::FloatRect getGlobalBounds() const;
// Method to get the player's speed
float getPlayerSpeed() const;
// Method to set the player's speed
void setPlayerSpeed(float speed);
// Friend extraction operator
// Inputs data from an input stream (e.g., std::cin) to populate a Player object's fields.
friend std::istream &operator>>(std::istream &aIstream, Player &aPlayer);
// Setter for FortuneCat status
void setHasFortuneCat(bool status);
// Getter for FortuneCat status
bool getHasFortuneCat() const;
// Setter for FortunePig status
void setHasFortunePig(bool status);
// Getter for FortunePig status
bool getHasFortunePig() const;
// Setter for FortuneMask status
void setHasFortuneMask(bool status);
// Getter for FortuneMask status
bool getHasFortuneMask() const;
// Method to update reputation based on the Fortune Cat
void updateReputationForFortuneCat();
// Method to update reputation based on the Fortune Pig
void updateReputationForFortunePig();
// Method to update reputation based on the Fortune Mask
void updateReputationForFortuneMask();
// Method to add an item to the Bag
void addItemToBag(const std::string& itemName, int itemPoints);
// Method to add an item to the Bag by itemName
void removeItemFromBag(const std::string& itemName);
// Method to check if Bag is empty
bool isBagEmpty() const;
// Method to list all items in the Bag
void listItemsInBag() const;
// Method to check if an item is in the Bag
bool IsItemInBag(const std::string& itemName);
// Handles user input for interacting with the Bag
void handleBagMenu();
// Method to move left in the Bag
void moveLeftInBag();
// Method to move right in the Bag
void moveRightInBag();
// Method to activate an item in the Bag
void activateItem();
// Method to get the current item in the Bag
void getCurrentItemInBag();
// Method to check if an item is activated in the Bag
bool isItemActivated(const std::string& itemName) const;
// Method to add a scrap to the apron
void addScrapToApron(const std::string& name);
// Method to remove a scrap from the apron by scrapName
void removeScrapFromApron(const std::string& scrapName);
// Method to check if the apron is empty
bool isApronEmpty() const;
// Method to list all scraps in the apron
void listScrapsInApron() const;
// Method to find scrap in the apron
bool findScrapFromApron(const std::string& scrapName) const;
// Handles user input for interacting with the Apron
void handleApronMenu();
// Destructor
~Player();
};
#endif