implement most remaining BB team functions
This commit is contained in:
+39
-7
@@ -47,6 +47,7 @@ public:
|
||||
enum class RewardFlag {
|
||||
// Only 0x00000001 and 0x00000002 are used by the client; the rest are
|
||||
// free to be used however the server chooses.
|
||||
NONE = 0x00000000,
|
||||
TEAM_FLAG = 0x00000001,
|
||||
DRESSING_ROOM = 0x00000002,
|
||||
MEMBERS_20_LEADERS_3 = 0x00000004,
|
||||
@@ -56,9 +57,12 @@ public:
|
||||
};
|
||||
|
||||
uint32_t team_id = 0;
|
||||
uint32_t points = 0;
|
||||
uint32_t spent_points = 0;
|
||||
std::string name;
|
||||
std::unordered_map<uint32_t, Member> members;
|
||||
uint32_t reward_flags = 0;
|
||||
std::unordered_set<std::string> reward_keys;
|
||||
std::shared_ptr<parray<le_uint16_t, 0x20 * 0x20>> flag_data;
|
||||
|
||||
Team() = default;
|
||||
@@ -86,6 +90,8 @@ public:
|
||||
this->reward_flags &= (~static_cast<uint8_t>(flag));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool has_reward(const std::string& key) const;
|
||||
|
||||
size_t num_members() const;
|
||||
size_t num_leaders() const;
|
||||
size_t max_members() const;
|
||||
@@ -94,20 +100,45 @@ public:
|
||||
bool can_promote_leader() const;
|
||||
};
|
||||
|
||||
explicit TeamIndex(const std::string& directory);
|
||||
struct Reward {
|
||||
uint32_t menu_item_id = 0;
|
||||
std::string key;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::unordered_set<std::string> prerequisite_keys;
|
||||
bool is_unique = true;
|
||||
uint32_t team_points = 0;
|
||||
Team::RewardFlag reward_flag = Team::RewardFlag::NONE;
|
||||
ItemData reward_item;
|
||||
|
||||
Reward(uint32_t menu_item_id, const JSON& def_json);
|
||||
};
|
||||
|
||||
TeamIndex(const std::string& directory, const JSON& reward_defs_json);
|
||||
~TeamIndex() = default;
|
||||
|
||||
size_t count() const;
|
||||
std::shared_ptr<Team> get_by_id(uint32_t team_id);
|
||||
std::shared_ptr<Team> get_by_name(const std::string& name);
|
||||
std::shared_ptr<Team> get_by_serial_number(uint32_t serial_number);
|
||||
std::vector<std::shared_ptr<Team>> all();
|
||||
inline const std::vector<Reward>& reward_definitions() const {
|
||||
return this->reward_defs;
|
||||
}
|
||||
|
||||
std::shared_ptr<Team> create(std::string& name, uint32_t master_serial_number, const std::string& master_name);
|
||||
size_t count() const;
|
||||
std::shared_ptr<const Team> get_by_id(uint32_t team_id) const;
|
||||
std::shared_ptr<const Team> get_by_name(const std::string& name) const;
|
||||
std::shared_ptr<const Team> get_by_serial_number(uint32_t serial_number) const;
|
||||
std::vector<std::shared_ptr<const Team>> all() const;
|
||||
|
||||
std::shared_ptr<const Team> create(std::string& name, uint32_t master_serial_number, const std::string& master_name);
|
||||
void disband(uint32_t team_id);
|
||||
|
||||
void add_member(uint32_t team_id, uint32_t serial_number, const std::string& name);
|
||||
void remove_member(uint32_t serial_number);
|
||||
void update_member_name(uint32_t serial_number, const std::string& name);
|
||||
void add_member_points(uint32_t serial_number, uint32_t points);
|
||||
void set_flag_data(uint32_t team_id, const parray<le_uint16_t, 0x20 * 0x20>& flag_data);
|
||||
bool promote_leader(uint32_t master_serial_number, uint32_t leader_serial_number);
|
||||
bool demote_leader(uint32_t master_serial_number, uint32_t leader_serial_number);
|
||||
void change_master(uint32_t master_serial_number, uint32_t new_master_serial_number);
|
||||
void buy_reward(uint32_t team_id, const std::string& key, uint32_t points, Team::RewardFlag reward_flag);
|
||||
|
||||
protected:
|
||||
std::string directory;
|
||||
@@ -115,6 +146,7 @@ protected:
|
||||
std::unordered_map<uint32_t, std::shared_ptr<Team>> id_to_team;
|
||||
std::unordered_map<std::string, std::shared_ptr<Team>> name_to_team;
|
||||
std::unordered_map<uint32_t, std::shared_ptr<Team>> serial_number_to_team;
|
||||
std::vector<Reward> reward_defs;
|
||||
|
||||
void add_to_indexes(std::shared_ptr<Team> team);
|
||||
void remove_from_indexes(std::shared_ptr<Team> team);
|
||||
|
||||
Reference in New Issue
Block a user