Refine NPC interactions and runtime item generation
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
||||
RuntimeItemPlan,
|
||||
RuntimeRelationAnchor,
|
||||
} from '../types';
|
||||
import {generateRuntimeItemAiIntents} from '../services/runtimeItemAiDirector';
|
||||
import {compileRuntimeItem} from './runtimeItemCompiler';
|
||||
import {
|
||||
applyRuntimeItemNarrative,
|
||||
@@ -157,8 +158,9 @@ function compilePlannedItem(
|
||||
context: RuntimeItemGenerationContext,
|
||||
plan: RuntimeItemPlan,
|
||||
seedKey: string,
|
||||
intentOverride?: ReturnType<typeof buildRuntimeItemAiIntent>,
|
||||
) {
|
||||
const intent = buildRuntimeItemAiIntent(context, plan);
|
||||
const intent = intentOverride ?? buildRuntimeItemAiIntent(context, plan);
|
||||
const compiled = compileRuntimeItem({
|
||||
seedKey,
|
||||
context,
|
||||
@@ -174,15 +176,10 @@ function compilePlannedItem(
|
||||
});
|
||||
}
|
||||
|
||||
export function buildDirectedRuntimeReward(
|
||||
context: RuntimeItemGenerationContext,
|
||||
function buildDirectedRewardFromItems(
|
||||
compiledItems: InventoryItem[],
|
||||
options: RuntimeRewardOptions,
|
||||
): DirectedRuntimeReward {
|
||||
const plans = planRuntimeItems(context, options);
|
||||
const compiledItems = plans.map((plan, index) =>
|
||||
compilePlannedItem(context, plan, `${options.seedKey}:${plan.slot}:${index}`),
|
||||
);
|
||||
|
||||
const reward: DirectedRuntimeReward = {
|
||||
primaryItem: compiledItems[0] ?? null,
|
||||
supportItems: compiledItems.slice(1),
|
||||
@@ -198,6 +195,45 @@ export function buildDirectedRuntimeReward(
|
||||
};
|
||||
}
|
||||
|
||||
export function buildDirectedRuntimeReward(
|
||||
context: RuntimeItemGenerationContext,
|
||||
options: RuntimeRewardOptions,
|
||||
): DirectedRuntimeReward {
|
||||
const plans = planRuntimeItems(context, options);
|
||||
const compiledItems = plans.map((plan, index) =>
|
||||
compilePlannedItem(context, plan, `${options.seedKey}:${plan.slot}:${index}`),
|
||||
);
|
||||
|
||||
return buildDirectedRewardFromItems(compiledItems, options);
|
||||
}
|
||||
|
||||
export async function generateDirectedRuntimeReward(
|
||||
context: RuntimeItemGenerationContext,
|
||||
options: RuntimeRewardOptions,
|
||||
): Promise<DirectedRuntimeReward> {
|
||||
const plans = planRuntimeItems(context, options);
|
||||
|
||||
try {
|
||||
const aiIntents = await generateRuntimeItemAiIntents({
|
||||
context,
|
||||
plans,
|
||||
});
|
||||
const compiledItems = plans.map((plan, index) =>
|
||||
compilePlannedItem(
|
||||
context,
|
||||
plan,
|
||||
`${options.seedKey}:${plan.slot}:${index}`,
|
||||
aiIntents[index],
|
||||
),
|
||||
);
|
||||
|
||||
return buildDirectedRewardFromItems(compiledItems, options);
|
||||
} catch (error) {
|
||||
console.warn('[RuntimeItemDirector] falling back to deterministic item intent', error);
|
||||
return buildDirectedRuntimeReward(context, options);
|
||||
}
|
||||
}
|
||||
|
||||
export function buildRuntimeInventoryStock(
|
||||
context: RuntimeItemGenerationContext,
|
||||
options: RuntimeRewardOptions,
|
||||
|
||||
Reference in New Issue
Block a user