eqemu-server/common/repositories/raid_members_repository.h
Mitch Freeman b01486d767
[Feature] Update raid features (#3443)
* [RAID] Add Raid Features

[RAID] Add Raid Features

- Add delegate main assist
- Add delegate main marker
- Add target ring for main assisters.  Uses MA1, then MA2, then MA3
- Add /assist raid respecting /assist on and /assist off
- Add Raid Notes.  Functions across zones
- Add Raid XTarget functional
- Raid Leader can mark without being delegated Main Marker.  Must have the appropriate AA

* Update to new db routines

* Updated several formatting issues based on review

* Update to pp->tribute_time_remaining to avoid edge case.  Unrelated to raid updates.

* Updates to resolve comments/review.
Added a few edge case updates as well.

* Refactored to use database repositories for raid_details and raid_members.  Other updates as noted in review.

* Updated database manifest and fixed potential leak within Client::Handle_OP_AssistGroup

* Update for remaining review items

* Refactor SendAssistTarget to use struct/vector loop

* Have IsAssister use range based for loop and return bool

* General cleanup

* Simplify SendRaidAssistTarget to use struct / vector

* Formatting in Handle_OP_RaidDelegateAbility

* Format SendRemoveRaidXTargets and clean up error statements

* Format SendRemoveAllRaidXTargets

* Formatting

* Default return FindNextRaidDelegateSlot to -1

* Change fields to marked_npc_1/2/3 (missing last underscore)

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-07-12 22:04:50 -05:00

103 lines
2.9 KiB
C++

#ifndef EQEMU_RAID_MEMBERS_REPOSITORY_H
#define EQEMU_RAID_MEMBERS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_raid_members_repository.h"
class RaidMembersRepository: public BaseRaidMembersRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* RaidMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* RaidMembersRepository::GetWhereNeverExpires()
* RaidMembersRepository::GetWhereXAndY()
* RaidMembersRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
static int UpdateRaidNote(
Database& db,
int32_t raid_id,
const std::string& note,
const std::string& character_name
) {
auto results = db.QueryDatabase(
fmt::format("UPDATE `{}` SET `note` = '{}' WHERE raidid = '{}' AND name = '{}';",
TableName(),
Strings::Escape(note),
raid_id,
Strings::Escape(character_name)
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static int UpdateRaidAssister(
Database& db,
int32_t raid_id,
const std::string& character_name,
uint8_t value
) {
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `is_assister` = '{}' WHERE raidid = '{}' AND `name` = '{}';",
TableName(),
value,
raid_id,
Strings::Escape(character_name)
)
);
return results.Success() ? results.RowsAffected() : 0;
}
static int UpdateRaidMarker(
Database& db,
int32_t raid_id,
const std::string& character_name,
uint8_t value
) {
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `is_marker` = '{}' WHERE raidid = '{}' AND `name` = '{}';",
TableName(),
value,
raid_id,
Strings::Escape(character_name)
)
);
return results.Success() ? results.RowsAffected() : 0;
}
};
#endif //EQEMU_RAID_MEMBERS_REPOSITORY_H