From 145e094684f291d3ca2c6ee87a7d7ffd92b0d5d8 Mon Sep 17 00:00:00 2001 From: Peisong Xiao Date: Thu, 18 Jul 2024 18:59:30 -0400 Subject: [PATCH] fixed issue with player not being able to pick up multiple piles of gold on the same tile --- src/player.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/player.cc b/src/player.cc index 52075ee..0fbace7 100644 --- a/src/player.cc +++ b/src/player.cc @@ -182,13 +182,17 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) { } else if (cmd >= move_north && cmd <= move_southwest) { auto res = move(lvl, pos + MOVE[cmd - move_north]); - gold g = get_gold_at(pos, lvl->get_glist()); - gold_cnt += g.get_amount(); + gold g{{0, 0}, 0}; + int gold_tmp = 0; - if (g.get_amount()) - res.msg += "PC picked up " + std::to_string(g.get_amount()) + + while ((g = get_gold_at(pos, lvl->get_glist())).get_amount() != 0) + gold_tmp += g.get_amount(); + + if (gold_tmp) + res.msg += "PC picked up " + std::to_string(gold_tmp) + " pieces of gold. "; + if (enabled_features & FEATURE_INVENTORY) { size_t idx = get_potion_at(pos, lvl->get_plist());