Skip to content

Commit

Permalink
Output list of items on ground when player walks over them
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyle-Tafoya committed Aug 18, 2023
1 parent 96ff31b commit 1142dbd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions movef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#include "glob.h"

#include <vector>

extern void queue_message(const std::string &);
extern void append_message(const std::string &, bool);

void p_movefunction(int movef)
{
/* loc functs above traps should be activated whether levitating or not */
Expand Down Expand Up @@ -395,6 +400,33 @@ void p_movefunction(int movef)
dataprint();
}
}
pol item_list = Level->site[Player.x][Player.y].things;
if(item_list)
{
if(!item_list->next)
{
queue_message("You see here a " + itemid(item_list->thing) + ".");
}
else
{
std::string items = itemid(item_list->thing);
std::string item_characters(1, item_list->thing->objchar & A_CHARTEXT);
for(pol item = item_list->next; item; item = item->next)
{
items += ", " + itemid(item->thing);
item_characters += item->thing->objchar & A_CHARTEXT;
}
if(items.length() > static_cast<unsigned int>(COLS))
{
queue_message("Items here: " + item_characters);
}
else
{
queue_message("Things that are here: ");
append_message(items, true);
}
}
}
}

/* execute some move function for a monster */
Expand Down

0 comments on commit 1142dbd

Please sign in to comment.