give output-group eligibility one home
The rule that decides whether a group may be picked -- every item it yields unlocked, the group judged whole because its items are produced together (REQ-LOCK-OUTPUT-POOL) -- was written out inside rollOutputGroup, where nothing outside the sim could reach it. It moves next to producesItem and getProducibleItems in RecipesConfig.h, which is where the recipe-level queries already shared between lib and ui live. Deliberately narrow: the helper says whether a group is eligible, not whether eligibility is asked about at all. rollOutputGroup keeps its own reason for not asking when a recipe has a single group. No behaviour change; the pool's end-to-end test still covers the rule and a direct one now pins the judged-whole semantics. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -82,6 +83,24 @@ inline bool producesItem(const RecipeDef& recipe, const std::string& itemId)
|
||||
return false;
|
||||
}
|
||||
|
||||
// True when every item this group yields is unlocked. A group is judged whole -- its
|
||||
// items are produced together, so one locked item disqualifies the group entirely, since
|
||||
// taking it would hand the player a locked item (REQ-LOCK-OUTPUT-POOL).
|
||||
//
|
||||
// This says whether a group is eligible, not whether eligibility is asked about at all:
|
||||
// that is the caller's, because the callers differ. A cycle picking its result does not
|
||||
// ask where there is only one group to pick (see ProductionSystem::rollOutputGroup).
|
||||
inline bool isOutputGroupUnlocked(
|
||||
const RecipeOutputGroup& group,
|
||||
const std::function<bool(const std::string&)>& isItemUnlocked)
|
||||
{
|
||||
for (const RecipeOutput& out : group.items)
|
||||
{
|
||||
if (!isItemUnlocked(out.item)) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
struct RecipesConfig
|
||||
{
|
||||
std::vector<RecipeDef> recipes;
|
||||
|
||||
Reference in New Issue
Block a user