Skip to content

Commit

Permalink
* add stat biome level, add char level
Browse files Browse the repository at this point in the history
  • Loading branch information
WALL OF JUSTICE committed Oct 31, 2024
1 parent 46b1791 commit 8f704b0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9638,9 +9638,6 @@ void doEndgame(bool saveHighscore, bool onServerDisconnect) {
conductGameChallenges[CONDUCT_BOOTS_SPEED] = 1;
}
achievementObserver.updateGlobalStat(STEAM_GSTAT_GAMES_WON, clientnum);
#ifdef USE_PLAYFAB
playfabUser.gameEnd();
#endif

for ( int c = 0; c < MAXPLAYERS; ++c )
{
Expand Down Expand Up @@ -9700,6 +9697,7 @@ void doEndgame(bool saveHighscore, bool onServerDisconnect) {
{
playfabUser.postScore(clientnum);
}
playfabUser.gameEnd();
#endif
}
saveAllScores(SCORESFILE);
Expand Down
22 changes: 22 additions & 0 deletions src/mod_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See LICENSE for details.
#include "shops.hpp"
#include "interface/ui.hpp"
#include "ui/GameUI.hpp"
#include "playfab.hpp"
#endif
#include "init.hpp"
#include "ui/LoadingScreen.hpp"
Expand Down Expand Up @@ -15130,6 +15131,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 4 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "mines", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "mines",
Expand All @@ -15144,6 +15148,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 9 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "swamps", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "swamps",
Expand All @@ -15158,6 +15165,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 14 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "labyrinth", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "labyrinth",
Expand All @@ -15172,6 +15182,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 19 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "ruins", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "ruins",
Expand All @@ -15190,6 +15203,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 23 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "hell", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "hell",
Expand All @@ -15212,6 +15228,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 29 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "crystal caves", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "crystal caves",
Expand All @@ -15226,6 +15245,9 @@ void Compendium_t::Events_t::onLevelChangeEvent(const int playernum, const int p
if ( prevlevel == 34 )
{
eventUpdateWorld(playernum, Compendium_t::CPDM_LEVELS_BIOME_CLEAR, "arcane citadel", 1);
#ifdef USE_PLAYFAB
playfabUser.biomeLeave();
#endif
commitUniqueValue = true; // commit at end of biome to save to file
}
eventUpdateWorld(playernum, Compendium_t::CPDM_BIOMES_MIN_COMPLETION, "arcane citadel",
Expand Down
46 changes: 46 additions & 0 deletions src/playfab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void PlayfabUser_t::gameEnd()
{
return;
}

PlayFab::EventsModels::WriteEventsRequest eventRequest;
PlayFab::EventsModels::EventContents eventContent;
eventContent.EventNamespace = "custom.game";
Expand All @@ -76,6 +77,7 @@ void PlayfabUser_t::gameEnd()
eventContent.Payload["version"] = VERSION;
eventContent.Payload["splitscreen"] = (multiplayer == SINGLE && splitscreen) ? 1 : 0;
eventContent.Payload["race"] = stats[clientnum]->playerRace;
eventContent.Payload["charlvl"] = stats[clientnum]->LVL;
eventContent.Payload["appearance"] = stats[clientnum]->stat_appearance;
eventContent.Payload["sex"] = stats[clientnum]->sex;
eventContent.Payload["controller"] = inputs.hasController(clientnum) ? 1 : 0;
Expand All @@ -84,6 +86,48 @@ void PlayfabUser_t::gameEnd()
PlayFab::PlayFabEventsAPI::WriteTelemetryEvents(eventRequest, OnEventsWrite, OnCloudScriptFailure);
}

void PlayfabUser_t::biomeLeave()
{
if ( !bLoggedIn )
{
return;
}

if ( gameModeManager.getMode() != GameModeManager_t::GAME_MODE_DEFAULT )
{
return;
}
PlayFab::EventsModels::WriteEventsRequest eventRequest;
PlayFab::EventsModels::EventContents eventContent;
eventContent.EventNamespace = "custom.game";
eventContent.Name = "biomeleave";
eventContent.Payload["class"] = client_classes[clientnum];
eventContent.Payload["multiplayer"] = multiplayer;
int players = 1;
if ( multiplayer == SERVER || (multiplayer == SINGLE && splitscreen) )
{
for ( int i = 1; i < MAXPLAYERS; ++i )
{
if ( !client_disconnected[i] )
{
++players;
}
}
}
eventContent.Payload["level"] = currentlevel;
eventContent.Payload["secret"] = secretlevel;
eventContent.Payload["numplayers"] = players;
eventContent.Payload["version"] = VERSION;
eventContent.Payload["splitscreen"] = (multiplayer == SINGLE && splitscreen) ? 1 : 0;
eventContent.Payload["race"] = stats[clientnum]->playerRace;
eventContent.Payload["charlvl"] = stats[clientnum]->LVL;
eventContent.Payload["appearance"] = stats[clientnum]->stat_appearance;
eventContent.Payload["sex"] = stats[clientnum]->sex;
eventContent.Payload["controller"] = inputs.hasController(clientnum) ? 1 : 0;
eventRequest.Events.push_back(eventContent);
PlayFab::PlayFabEventsAPI::WriteTelemetryEvents(eventRequest, OnEventsWrite, OnCloudScriptFailure);
}

void PlayfabUser_t::gameBegin()
{
if ( !bLoggedIn )
Expand Down Expand Up @@ -152,11 +196,13 @@ void PlayfabUser_t::globalStat(int index, int player)
{
eventContent.Payload["class"] = client_classes[player];
eventContent.Payload["race"] = stats[player]->playerRace;
eventContent.Payload["charlvl"] = stats[player]->LVL;
}
else
{
eventContent.Payload["class"] = -1;
eventContent.Payload["race"] = -1;
eventContent.Payload["charlvl"] = -1;
}
eventRequest.Events.push_back(eventContent);
PlayFab::PlayFabEventsAPI::WriteTelemetryEvents(eventRequest, OnEventsWrite, OnCloudScriptFailure);
Expand Down
1 change: 1 addition & 0 deletions src/playfab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PlayfabUser_t
void getLeaderboardTop100Alternate(std::string lid);
void gameBegin();
void gameEnd();
void biomeLeave();
void compendiumResearch(std::string category, std::string section);
void globalStat(int index, int player);

Expand Down

0 comments on commit 8f704b0

Please sign in to comment.