Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions logic/Fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,28 @@ static FillError fastFill(ItemPool& items, LocationPool& locations)
static FillError fillTheRest(WorldPool& worlds, ItemPool& items, LocationPool& locations)
{
FillError err;
// First place the junk already in the pool
// First place the non consumable junk already in the pool
// Filter out the consumable junk to place afterwards
auto consumableJunk = filterAndEraseFromPool(items, [](const Item& i){return i.isConsumableJunkItem();});
FILL_ERROR_CHECK(fastFill(items, locations));

// When the item pool is empty, get random junk for the remaining locations
// For the remaining locations, get items from the consumable junk. If the consumable junk runs out, just get more random
// consumable junk
for (auto location : locations)
{
if (location->currentItem.getGameItemId() == GameItem::INVALID)
{
auto item = getRandomJunk();
location->currentItem = location->world->getItem(item);
LOG_TO_DEBUG("Placed " + item + " at " + location->getName() + " in world " + std::to_string(location->world->getWorldId() + 1));
Item item;
if (!consumableJunk.empty())
{
item = popRandomElement(consumableJunk);
}
else
{
item = location->world->getItem(getRandomJunk());
}
location->currentItem = item;
LOG_TO_DEBUG("Placed " + item.getName() + " at " + location->getName() + " in world " + std::to_string(location->world->getWorldId() + 1));
}
}
return FillError::NONE;
Expand Down
10 changes: 10 additions & 0 deletions logic/GameItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,11 @@ Item::Item(GameItem gameItemId_, World* world_) :
gameItemId(gameItemId_),
world(world_)
{
if (junkConsumables.contains(gameItemId))
{
junkConsumable = true;
}

if (junkItems.contains(gameItemId) || (isAnyOf(gameItemId, GameItem::HeartContainer, GameItem::PieceOfHeart) && world && world->getStartingHeartCount() >= 3))
{
originallyJunk = true;
Expand Down Expand Up @@ -891,6 +896,11 @@ bool Item::isJunkItem() const
return junkItem;
}

bool Item::isConsumableJunkItem() const
{
return junkConsumable;
}

bool Item::wasAlwaysJunkItem() const
{
return originallyJunk;
Expand Down
34 changes: 34 additions & 0 deletions logic/GameItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,38 @@ static const std::set<GameItem> junkItems = {
GameItem::TinglesChart
};

static const std::set<GameItem> junkConsumables = {
GameItem::HeartDrop,
GameItem::GreenRupee,
GameItem::BlueRupee,
GameItem::YellowRupee,
GameItem::RedRupee,
GameItem::PurpleRupee,
GameItem::OrangeRupee,
GameItem::SmallMagicDrop,
GameItem::LargeMagicDrop,
GameItem::FiveBombs,
GameItem::TenBombs,
GameItem::TwentyBombs,
GameItem::ThirtyBombs,
GameItem::SilverRupee,
GameItem::TenArrows,
GameItem::TwentyArrows,
GameItem::ThirtyArrows,
GameItem::Fairy,
GameItem::YellowRupee2, //joke message
GameItem::ThreeHearts,
GameItem::JoyPendant,
GameItem::SkullNecklace,
GameItem::BokoBabaSeed,
GameItem::GoldenFeather,
GameItem::KnightsCrest,
GameItem::RedChuJelly,
GameItem::GreenChuJelly,
GameItem::AllPurposeBait,
GameItem::HyoiPear,
};

static const std::set<GameItem> dungeonItems = {
GameItem::DRCSmallKey,
GameItem::DRCBigKey,
Expand Down Expand Up @@ -406,6 +438,7 @@ class Item
void setName(const std::string& language, const Text::Type& type, const std::string& name_);
void setAsJunkItem();
bool isJunkItem() const;
bool isConsumableJunkItem() const;
bool wasAlwaysJunkItem() const;
bool isDungeonItem() const;
bool isMap() const;
Expand All @@ -425,6 +458,7 @@ class Item
std::unordered_set<Location*> chainLocations = {};
bool dungeonItem = false;
bool junkItem = false;
bool junkConsumable = false;
bool originallyJunk = false;
World* world = nullptr; // The world that this item is *FOR*
};
Expand Down