achievement_gain_once

This commit is contained in:
Zeno Rogue 2020-03-06 14:22:36 +01:00
parent e53ff34cec
commit ca7f0cb4c3
3 changed files with 16 additions and 11 deletions

View File

@ -128,6 +128,15 @@ EX bool wrongMode(char flags) {
return false; return false;
} }
EX set<string> got_achievements;
EX void achievement_gain_once(const string& s) {
LATE(achievement_gain_once(s));
if(got_achievements.count(s)) return;
got_achievements.insert(s);
achievement_gain(s.c_str());
}
EX void achievement_log(const char* s, char flags) { EX void achievement_log(const char* s, char flags) {
#ifdef PRINT_ACHIEVEMENTS #ifdef PRINT_ACHIEVEMENTS

View File

@ -17,7 +17,7 @@ EX bool seenSevenMines = false;
EX bool hauntedWarning; EX bool hauntedWarning;
/** is the Survivalist achievement still valid? have we received it? */ /** is the Survivalist achievement still valid? have we received it? */
EX bool survivalist, got_survivalist; EX bool survivalist;
EX void fail_survivalist() { EX void fail_survivalist() {
changes.value_set(survivalist, false); changes.value_set(survivalist, false);
@ -336,21 +336,17 @@ bool pcmove::after_move() {
check_total_victory(); check_total_victory();
if(items[itWhirlpool] && cwt.at->land != laWhirlpool && !whirlpool::escaped) { if(items[itWhirlpool] && cwt.at->land != laWhirlpool)
changes.value_set(whirlpool::escaped, true); achievement_gain_once("WHIRL1");
achievement_gain("WHIRL1");
}
if(items[itLotus] >= 25 && !isHaunted(cwt.at->land) && survivalist && !got_survivalist) { if(items[itLotus] >= 25 && !isHaunted(cwt.at->land) && survivalist)
changes.value_set(got_survivalist, true); achievement_gain_once("SURVIVAL");
achievement_gain("SURVIVAL");
}
if(seenSevenMines && cwt.at->land != laMinefield) { if(seenSevenMines && cwt.at->land != laMinefield) {
changes.value_set(seenSevenMines, false); changes.value_set(seenSevenMines, false);
achievement_gain("SEVENMINE"); achievement_gain("SEVENMINE");
} }
DEBB(DF_TURN, ("done")); DEBB(DF_TURN, ("done"));
return true; return true;
} }

View File

@ -360,7 +360,7 @@ EX void initgame() {
#if CAP_CRYSTAL #if CAP_CRYSTAL
crystal::used_compass_inside = false; crystal::used_compass_inside = false;
#endif #endif
got_survivalist = false; got_achievements = {};
#if CAP_INV #if CAP_INV
if(inv::on) inv::init(); if(inv::on) inv::init();
#endif #endif