forked from opentibiabr/canary
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5100679
commit 4097edf
Showing
20 changed files
with
875 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
/** | ||
* Canary - A free and open-source MMORPG server emulator | ||
* Copyright (©) 2019-2024 OpenTibiaBR <[email protected]> | ||
* Repository: https://github.com/opentibiabr/canary | ||
* License: https://github.com/opentibiabr/canary/blob/main/LICENSE | ||
* Contributors: https://github.com/opentibiabr/canary/graphs/contributors | ||
* Website: https://docs.opentibiabr.com/ | ||
*/ | ||
|
||
#include "pch.hpp" | ||
|
||
#include "player_cyclopedia.hpp" | ||
|
||
#include "creatures/players/player.hpp" | ||
#include "game/game.hpp" | ||
#include "kv/kv.hpp" | ||
|
||
PlayerCyclopedia::PlayerCyclopedia(Player &player) : | ||
m_player(player) {} | ||
|
||
// Badge | ||
bool PlayerCyclopedia::hasBadge(uint8_t id) { | ||
if (auto it = std::find_if(badges.begin(), badges.end(), [id](uint8_t it) { | ||
return it == id; | ||
}); it != badges.end()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void PlayerCyclopedia::addBadge(uint8_t id) { | ||
if (hasBadge(id)) { | ||
return; | ||
} | ||
|
||
badges.emplace_back(id); | ||
} | ||
|
||
// Title | ||
std::vector<uint8_t> PlayerCyclopedia::getTitles() const { | ||
return titles; | ||
} | ||
|
||
uint8_t PlayerCyclopedia::getCurrentTitle() const { | ||
return m_currentTitle; | ||
} | ||
|
||
std::string PlayerCyclopedia::getCurrentTitleName() const { | ||
auto currentTitle = getCurrentTitle(); | ||
if (currentTitle == 0) { | ||
return ""; | ||
} | ||
|
||
auto title = g_game().getTitle(currentTitle); | ||
return (m_player.getSex() == PLAYERSEX_MALE) ? title.maleName : title.femaleName; | ||
} | ||
|
||
void PlayerCyclopedia::setCurrentTitle(uint8_t id) { | ||
if (id != 0 && !isTitleUnlocked(id)) { | ||
return; | ||
} | ||
|
||
m_currentTitle = id; | ||
} | ||
|
||
void PlayerCyclopedia::addTitle(uint8_t id) { | ||
if (isTitleUnlocked(id)) { | ||
return; | ||
} | ||
|
||
titles.emplace_back(id); | ||
} | ||
|
||
|
||
|
||
bool PlayerCyclopedia::isTitleUnlocked(uint8_t id) const { | ||
if (auto it = std::find_if(titles.begin(), titles.end(), [id](uint8_t title_it) { | ||
return title_it == id; | ||
}); it != titles.end()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
// Death History | ||
std::vector<RecentDeathEntry> PlayerCyclopedia::getDeathHistory() const { | ||
return m_deathHistory; | ||
} | ||
|
||
void PlayerCyclopedia::insertDeathOnHistory(std::string cause, uint32_t timestamp) { | ||
m_deathHistory.emplace_back(std::move(cause), timestamp); | ||
} | ||
|
||
std::vector<RecentPvPKillEntry> PlayerCyclopedia::getPvpKillsHistory() const { | ||
return m_pvpKillsHistory; | ||
} | ||
|
||
void PlayerCyclopedia::insertPvpKillOnHistory(std::string cause, uint32_t timestamp, uint8_t status) { | ||
m_pvpKillsHistory.emplace_back(std::move(cause), timestamp, status); | ||
} | ||
|
||
// Player summary region | ||
// Get: | ||
//std::vector<uint16_t> getHirelinsOutfitsObtained() const { | ||
// return m_player.hirelingOutfitsObtained; | ||
//} | ||
// | ||
//std::vector<uint8_t> getHirelinsJobsObtained() const { | ||
// return hirelingJobsObtained; | ||
//} | ||
// | ||
//std::map<Blessings_t, uint16_t> getBlessingsObtained() const { | ||
// return blessingsObtained; | ||
//} | ||
// | ||
//StashItemList getHouseItemsObtained() const { | ||
// return houseItemsObtained; | ||
//} | ||
// | ||
//uint16_t getXpBoostsObtained() const { | ||
// return storeXpBoostsObtained; | ||
//} | ||
// | ||
//uint16_t getRewardCollectionObtained() const { | ||
// return dailyRewardCollectionsObtained; | ||
//} | ||
// | ||
//uint16_t getHirelingsObtained() const { | ||
// return hirelingsObtained; | ||
//} | ||
// | ||
//uint16_t getPreyCardsObtained() const { | ||
// return preyCardsObtained; | ||
//} | ||
// | ||
//uint16_t getCharmsPointsObtained() const { | ||
// return charmsObtained; | ||
//} | ||
// | ||
//uint16_t getGoshnarTaintsObtained() const { | ||
// return goshnarObtained; | ||
//} | ||
// | ||
//uint16_t getDromePointsObtained() const { | ||
// return dromeObtained; | ||
//} | ||
// | ||
//uint16_t getLoginStreak() const { | ||
// return loginStreak; | ||
//} | ||
// | ||
//uint16_t getTaskHuntingPointsObtained() const { | ||
// return taskHuntingPointsObtained; | ||
//} | ||
// | ||
//uint16_t getMapAreaDiscoveredPercentage() const { | ||
// return mapAreaDiscoveredPercentage; | ||
//} | ||
// | ||
//// Player summary region | ||
//// Set: | ||
//void addHirelingOutfitObtained(uint16_t lookType) { | ||
// hirelingOutfitsObtained.push_back(lookType); | ||
//} | ||
// | ||
//void addHirelingJobsObtained(uint8_t jobId) { | ||
// hirelingJobsObtained.push_back(jobId); | ||
//} | ||
// | ||
//void addBlessingsObtained(Blessings_t id, uint16_t amount) { | ||
// blessingsObtained[id] += amount; | ||
//} | ||
// | ||
//void addHouseItemsObtained(uint16_t itemId, uint32_t amount) { | ||
// houseItemsObtained[itemId] += amount; | ||
//} | ||
// | ||
//void addXpBoostsObtained(uint16_t amount) { | ||
// storeXpBoostsObtained += amount; | ||
//} | ||
// | ||
//void addRewardCollectionObtained(uint16_t amount) { | ||
// dailyRewardCollectionsObtained += amount; | ||
//} | ||
// | ||
//void addHirelingsObtained(uint16_t amount) { | ||
// hirelingsObtained += amount; | ||
//} | ||
// | ||
//void addPreyCardsObtained(uint16_t amount) { | ||
// preyCardsObtained += amount; | ||
//} | ||
// | ||
//void addCharmsPointsObtained(uint16_t amount) { | ||
// charmsObtained += amount; | ||
//} | ||
// | ||
//void addGoshnarTaintsObtained(uint16_t amount) { | ||
// goshnarObtained += amount; | ||
//} | ||
// | ||
//void addDromePointsObtained(uint16_t amount) { | ||
// dromeObtained += amount; | ||
//} | ||
// | ||
//void addLoginStreak(uint16_t amount) { | ||
// loginStreak += amount; | ||
//} | ||
// | ||
//void addTaskHuntingPointsObtained(uint16_t amount) { | ||
// taskHuntingPointsObtained += amount; | ||
//} | ||
// | ||
//void addMapAreaDiscoveredPercentage(uint16_t amount) { | ||
// mapAreaDiscoveredPercentage += amount; | ||
//} | ||
// | ||
|
||
//std::map<uint8_t, std::vector<uint16_t>> getAccountLevelVocation() const { | ||
// return accountLevelSummary; | ||
//} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Canary - A free and open-source MMORPG server emulator | ||
* Copyright (©) 2019-2024 OpenTibiaBR <[email protected]> | ||
* Repository: https://github.com/opentibiabr/canary | ||
* License: https://github.com/opentibiabr/canary/blob/main/LICENSE | ||
* Contributors: https://github.com/opentibiabr/canary/graphs/contributors | ||
* Website: https://docs.opentibiabr.com/ | ||
*/ | ||
|
||
#pragma once | ||
|
||
class Player; | ||
|
||
struct PlayerTitle { | ||
PlayerTitle() {} | ||
|
||
uint16_t id = 0; | ||
std::string maleName; | ||
std::string femaleName; | ||
std::string description; | ||
bool permanent = false; | ||
}; | ||
|
||
class PlayerCyclopedia { | ||
public: | ||
explicit PlayerCyclopedia(Player &player); | ||
bool hasBadge(uint8_t id); | ||
void addBadge(uint8_t id); | ||
|
||
std::vector<uint8_t> getTitles() const; | ||
uint8_t getCurrentTitle() const; | ||
std::string getCurrentTitleName() const; | ||
void setCurrentTitle(uint8_t id); | ||
void addTitle(uint8_t id); | ||
bool isTitleUnlocked(uint8_t id) const; | ||
|
||
std::vector<RecentDeathEntry> getDeathHistory() const; | ||
std::vector<RecentPvPKillEntry> getPvpKillsHistory() const; | ||
void insertDeathOnHistory(std::string cause, uint32_t timestamp); | ||
void insertPvpKillOnHistory(std::string cause, uint32_t timestamp, uint8_t status); | ||
|
||
private: | ||
Player &m_player; | ||
|
||
std::vector<uint8_t> badges; | ||
std::vector<uint8_t> titles; | ||
uint8_t m_currentTitle; | ||
|
||
// std::vector<uint16_t> hirelingOutfitsObtained; | ||
// std::vector<uint8_t> hirelingJobsObtained; | ||
// std::map<Blessings_t, uint16_t> blessingsObtained; | ||
// StashItemList houseItemsObtained; | ||
// uint16_t storeXpBoostsObtained = 0; | ||
// uint16_t dailyRewardCollectionsObtained = 0; | ||
// uint16_t hirelingsObtained = 0; | ||
// uint16_t preyCardsObtained = 0; | ||
// uint16_t charmsObtained = 0; | ||
// uint16_t goshnarObtained = 0; | ||
// uint16_t dromeObtained = 0; | ||
// uint16_t loginStreak = 0; | ||
// uint16_t taskHuntingPointsObtained = 0; | ||
// uint16_t mapAreaDiscoveredPercentage = 0; | ||
|
||
std::vector<RecentDeathEntry> m_deathHistory; | ||
std::vector<RecentPvPKillEntry> m_pvpKillsHistory; | ||
std::map<uint8_t, std::vector<uint16_t>> m_accountLevelSummary; | ||
}; |
Oops, something went wrong.