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;
}
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) {
#ifdef PRINT_ACHIEVEMENTS

View File

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

View File

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