2022-08-06 03:01:59 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "Mission.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An expression that checks if a mission may be accepted or not
|
|
|
|
*/
|
|
|
|
class PrerequisiteExpression final
|
|
|
|
{
|
|
|
|
bool m_or;
|
|
|
|
uint32_t a;
|
|
|
|
uint32_t sub;
|
|
|
|
PrerequisiteExpression* b;
|
|
|
|
|
|
|
|
public:
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Executes the prerequisite, checking its contents and returning whether or not the mission may be accepted
|
|
|
|
* @param missions the list of missions to check the prerequisites against (f.e. whether they're completed)
|
|
|
|
* @return whether or not all the prerequisites are met
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool Execute(const std::unordered_map<uint32_t, Mission*>& missions) const;
|
|
|
|
|
|
|
|
explicit PrerequisiteExpression(const std::string& str);
|
|
|
|
~PrerequisiteExpression();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility class for checking whether or not a mission can be accepted using its prerequisites
|
|
|
|
*/
|
|
|
|
class MissionPrerequisites final
|
|
|
|
{
|
|
|
|
public:
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks whether or not the mission identified by the specified ID can be accepted based on the mission inventory passed.
|
|
|
|
* Also performs checks for daily missions (e.g. if the time out is valid).
|
|
|
|
* @param missionId the mission ID to check prerequisites for
|
|
|
|
* @param missions the mission inventory to check the prerequisites against
|
|
|
|
* @return whether or not the mission identified by the specified ID can be accepted
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
static bool CanAccept(uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions);
|
|
|
|
private:
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Cache of all the executed prerequisites
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
static std::unordered_map<uint32_t, PrerequisiteExpression*> expressions;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Checks the prerequisites for a mission
|
|
|
|
* @param missionId the mission ID to check prerequisites for
|
|
|
|
* @param missions the mission inventory to check the prerequisites against
|
|
|
|
* @return whether or not the mission identified by the specified ID can be accepted
|
|
|
|
*/
|
|
|
|
static bool CheckPrerequisites(uint32_t missionId, const std::unordered_map<uint32_t, Mission*>& missions);
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|