0% found this document useful (0 votes)
2 views

Header File

Header file

Uploaded by

ladnp14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Header File

Header file

Uploaded by

ladnp14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Page 1

#ifndef DYNAMIC_DIFFICULTY_H // Include guard to prevent multiple inclusions


#define DYNAMIC_DIFFICULTY_H

#include <vector>

class PlayerPerformance {
private:
int health;
int damageDealt;
float accuracy;
int resourcesCollected;
float timeElapsed;

public:
PlayerPerformance(int h, int d, float a, int r, float t); // Constructor
int getHealth() const;
int getDamageDealt() const;
float getAccuracy() const;
int getResourcesCollected() const;
float getTimeElapsed() const;
// ... other getters if needed
};

class Player {
private:
int health;
int damageDealt;
float accuracy;
int resourcesCollected;
int deaths;
int level;
std::vector<PlayerPerformance> performanceHistory; // Store performance snapshots

public:
Player(int h, int d, float a, int r, int l); // Constructor
void takeDamage(int damage);
void dealDamage(int damage);
void collectResources(int resources);
void die();
void addPerformanceSnapshot(const PlayerPerformance& snapshot);
int getHealth() const;
int getDamageDealt() const;
float getAccuracy() const;
int getResourcesCollected() const;
int getDeaths() const;
int getLevel() const;
const std::vector<PlayerPerformance>& getPerformanceHistory() const;
Page 2

};

class EnemyAIController {
private:
float aggressionLevel;
float reactionTime;
float attackFrequency;

public:
EnemyAIController(); // Constructor
void setAggression(float aggression);
void setReactionTime(float reactionTime);
void setAttackFrequency(float frequency);
float getAggression() const;
float getReactionTime() const;
float getAttackFrequency() const;
};

class ResourceManager {
private:
float dropRate;
int resourceQuantity;

public:
ResourceManager(); // Constructor
void setDropRate(float rate);
void setResourceQuantity(int quantity);
float getDropRate() const;
int getResourceQuantity() const;
};

class GameParameterManager {
private:
float enemyHealthMultiplier;
float damageTakenMultiplier;

public:
GameParameterManager(); // Constructor
void setEnemyHealthMultiplier(float multiplier);
void setDamageTakenMultiplier(float multiplier);
float getEnemyHealthMultiplier() const;
float getDamageTakenMultiplier() const;

};

class DifficultyAdjuster {
private:
Page 3

float currentDifficultyLevel;
Player* player; // Pointer to the player object
EnemyAIController* aiController;
ResourceManager* resourceManager;
GameParameterManager* gameParams;

public:
DifficultyAdjuster(Player* p, EnemyAIController* ai, ResourceManager* rm,
GameParameterManager* gp); // Constructor
void calculateDifficulty();
void adjustEnemyAI();
void adjustResourceDrops();
void adjustGameParameters();
float getCurrentDifficulty() const;

};

#endif

Key improvements and explanations:

●​ Include Guards: The #ifndef, #define, and #endif preprocessor directives


prevent the header file from being included multiple times, which can cause
compilation errors.
●​ Constructors: Each class now has a constructor. This is crucial for initializing the
object's member variables when the object is created.
●​ Getters: Added getter methods (e.g., getHealth(), getAggression()) for
accessing private member variables from outside the class. This follows good
encapsulation principles.
●​ PlayerPerformance Class: This class now stores snapshots of player performance
data.
●​ Player Class: The Player class now includes a performanceHistory vector to
store multiple PlayerPerformancesnapshots over time. This allows the
DifficultyAdjuster to analyze past performance. It also includes a method
addPerformanceSnapshot() to record the player's stats.
●​ Pointers in DifficultyAdjuster: The DifficultyAdjuster now holds pointers
(Player*, EnemyAIController*, etc.) to instances of the other classes. This is
essential because the DifficultyAdjuster needs to interact with and modify
these objects. It doesn't own them, so pointers are the correct choice.
●​ Clearer Method Stubs: The method declarations are now more descriptive (e.g.,
takeDamage(int damage)instead of just takeDamage()).
●​ Includes: Added #include <vector> for using the std::vector in the Player
class.
Page 4

This improved header file provides a more robust and complete foundation for your class
implementations. Remember that this is just the interface – the actual logic for each method
will be written in the corresponding .cpp source files.

You might also like