1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

leaderboards rewrite

This commit is contained in:
Zeno Rogue 2018-05-15 23:23:12 +02:00
parent 14f9c3b325
commit 9b55240d1e
3 changed files with 46 additions and 25 deletions

View File

@ -3,15 +3,10 @@
#define NUMLEADER 78
#define SCORE_UNKNOWN (-1)
#define NO_SCORE_YET (-2)
bool offlineMode = false;
int syncstate = 0;
int currentscore[NUMLEADER];
const char* leadernames[NUMLEADER] = {
"Score", "Diamonds", "Gold", "Spice", "Rubies", "Elixirs",
"Shards100", "Totems", "Daisies", "Statues", "Feathers", "Sapphires",
@ -73,8 +68,6 @@ const char* leadernames[NUMLEADER] = {
#define LB_STATISTICS 62
#define LB_HALLOWEEN 63
bool haveLeaderboard(int id);
void upload_score(int id, int v);
string achievementMessage[3];
@ -480,9 +473,9 @@ int specific_what = 0;
void improve_score(int i, eItem what) {
if(offlineMode) return;
#ifdef HAVE_ACHIEVEMENTS
if(haveLeaderboard(i)) updateHi(what, currentscore[i]);
if(haveLeaderboard(i)) updateHi(what, get_currentscore(i));
if(items[what] && haveLeaderboard(i)) {
if(items[what] > currentscore[i] && currentscore[i] != SCORE_UNKNOWN) {
if(items[what] > get_currentscore(i) && score_loaded(i)) {
specific_improved++; specific_what = what;
}
upload_score(i, items[what]);
@ -593,6 +586,13 @@ void achievement_final(bool really_final) {
return;
}
#ifdef CAP_DAILY
if(daily::on) {
upload_score(daily::find_daily_lbid(daily::daily_id), gold(NO_LOVE));
return;
}
#endif
if(geometry) return;
// no leaderboards for two special modes at once
@ -623,8 +623,8 @@ void achievement_final(bool really_final) {
int tg = gold();
if(tg && haveLeaderboard(sid)) {
if(tg > currentscore[sid] && currentscore[sid] != SCORE_UNKNOWN) {
if(currentscore[sid] < 0) total_improved += 2;
if(tg > get_currentscore(sid) && score_loaded(sid)) {
if(get_currentscore(sid) <= 0) total_improved += 2;
total_improved++; // currentscore[sid] = tg;
}
upload_score(sid, tg);
@ -692,15 +692,17 @@ void achievement_victory(bool hyper) {
int ih2 = hyper ? 16 : inv::on ? 71 : shmup::on ? 30 : 14;
int improved = 0;
if(currentscore[ih1] == NO_SCORE_YET || currentscore[ih2] == NO_SCORE_YET)
if(score_loaded(ih1) && score_loaded(ih2)) {
if(get_currentscore(ih1) == score_default(ih1) || get_currentscore(ih2) == score_default(ih2))
improved += 4;
if(currentscore[ih1] < 0 || currentscore[ih1] > t) {
improved++; // currentscore[ih1] = t;
if(get_currentscore(ih1) > t) {
improved++;
}
if(currentscore[ih2] < 0 || currentscore[ih2] > turncount) {
improved+=2; // currentscore[ih2] = turncount;
if(get_currentscore(ih2) > turncount) {
improved+=2;
}
}
if(hyper)
@ -768,3 +770,12 @@ bool isAscending(int i) {
return i == 13 || i == 14 || i == 15 || i == 16 || i == 29 || i == 30 || i == 45;
};
int score_default(int i) {
if(isAscending(i)) return 1999999999;
else return 0;
}
#ifndef HAVE_ACHIEVEMENTS
int get_sync_status() { return 0; }
void set_priority_board(int) { }
#endif

10
hyper.h
View File

@ -307,9 +307,6 @@ int hrand(int i);
template<class T> int size(const T& x) {return int(x.size()); }
#endif
extern int currentscore[NUMLEADER];
extern int syncstate;
// initialize the achievement system.
void achievement_init();
@ -3369,3 +3366,10 @@ void queuechr(const transmatrix& V, double size, char chr, int col, int frame =
extern bool just_gmatrix;
void drawrec(const heptspin& hs, hstate s, const transmatrix& V);
bool haveLeaderboard(int id);
int get_currentscore(int id);
void set_priority_board(int id);
int get_sync_status();
bool score_loaded(int id);
int score_default(int id);

View File

@ -20,7 +20,7 @@ typedef vector<pair<int, string> > subscoreboard;
void displayScore(subscoreboard& s, int x) {
int vf = min((vid.yres-64) / 70, vid.xres/80);
if(syncstate == 1) {
if(get_sync_status() == 1) {
displayfr(x, 56, 1, vf, "(syncing)", 0xC0C0C0, 0);
}
else {
@ -433,6 +433,7 @@ namespace yendor {
}
void showMenu() {
set_priority_board(LB_YENDOR_CHALLENGE);
int s = vid.fsize;
vid.fsize = vid.fsize * 4/5;
dialog::init(XLAT("Yendor Challenge"), iinf[itOrbYendor].color, 150, 100);
@ -663,6 +664,13 @@ namespace tactic {
}
void showMenu() {
int xc = modecode();
if(xc == 0) set_priority_board(LB_PURE_TACTICS);
if(xc == 2) set_priority_board(LB_PURE_TACTICS_SHMUP);
if(xc == 4) set_priority_board(LB_PURE_TACTICS_COOP);
cmode = sm::ZOOMABLE;
mouseovers = XLAT("pure tactics mode") + " - " + mouseovers;
@ -682,8 +690,6 @@ namespace tactic {
if(on) record(specialland, items[treasureType(specialland)]);
int xc = modecode();
getcstat = SDLK_ESCAPE;
for(int i=0; i<nl; i++) {