diff options
Diffstat (limited to 'frontend/GameController.cpp')
-rw-r--r-- | frontend/GameController.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/frontend/GameController.cpp b/frontend/GameController.cpp index d7b5f96..e015348 100644 --- a/frontend/GameController.cpp +++ b/frontend/GameController.cpp @@ -70,14 +70,17 @@ unique_ptr<Dungeon> GameController::make_dungeon() noexcept { void GameController::gameloop() { this->dungeon = make_dungeon(); Player & player = this->dungeon->get_player(); + GameData & gamedata = GameData::get_instance(); lprtf("Wat is de naam van je karakter?\n"); player.name = rl().c_str(); player.set_location(dungeon->get_start_location()); - player.equip(static_cast<WeaponObject *>(GameData::get_instance().create_object("Dolk"))); + player.equip(static_cast<WeaponObject *>(gamedata.create_object("Dolk"))); cmdset_default(); + bool is_dead = false, last_is_dead = false; + this->playing = true; while (this->playing) { string line = rl(); @@ -88,8 +91,15 @@ void GameController::gameloop() { lprtf("FOUT: %s.\n", e.what()); } - if (player.is_dead()) - cmdset_death(); + last_is_dead = is_dead; + is_dead = player.is_dead(); + bool just_died = last_is_dead == false && is_dead == true; + if (!just_died) continue; + + cmdset_death(); + gamedata.leaderbord_add(player.name.c_str(), player.gold); + str_print(strings::DEATH); + gamedata.leaderbord_print(); } } |