统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {generateRuntimeItemAiIntents} from '../services/runtimeItemAiDirector';
|
||||
import { generateRuntimeItemAiIntents } from '../services/runtimeItemAiDirector';
|
||||
import type {
|
||||
DirectedRuntimeReward,
|
||||
InventoryItem,
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
RuntimeItemPlan,
|
||||
RuntimeRelationAnchor,
|
||||
} from '../types';
|
||||
import {compileRuntimeItem} from './runtimeItemCompiler';
|
||||
import { compileRuntimeItem } from './runtimeItemCompiler';
|
||||
import {
|
||||
applyRuntimeItemNarrative,
|
||||
buildRuntimeItemAiIntent,
|
||||
@@ -40,21 +40,22 @@ const GAP_TO_TAGS: Record<string, string[]> = {
|
||||
function hashText(value: string) {
|
||||
let hash = 0;
|
||||
for (let index = 0; index < value.length; index += 1) {
|
||||
hash = ((hash << 5) - hash) + value.charCodeAt(index);
|
||||
hash = (hash << 5) - hash + value.charCodeAt(index);
|
||||
hash |= 0;
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
||||
function resolveGapDrivenTags(context: RuntimeItemGenerationContext) {
|
||||
const gapTags = context.playerBuildGaps.flatMap(gap => GAP_TO_TAGS[gap] ?? []);
|
||||
return [...new Set([
|
||||
...gapTags,
|
||||
...context.playerBuildTags,
|
||||
])].slice(0, 3);
|
||||
const gapTags = context.playerBuildGaps.flatMap(
|
||||
(gap) => GAP_TO_TAGS[gap] ?? [],
|
||||
);
|
||||
return [...new Set([...gapTags, ...context.playerBuildTags])].slice(0, 3);
|
||||
}
|
||||
|
||||
function resolveRelationAnchor(context: RuntimeItemGenerationContext): RuntimeRelationAnchor {
|
||||
function resolveRelationAnchor(
|
||||
context: RuntimeItemGenerationContext,
|
||||
): RuntimeRelationAnchor {
|
||||
if (context.encounter?.monsterPresetId) {
|
||||
return {
|
||||
type: 'monster',
|
||||
@@ -91,37 +92,67 @@ function getChannelTemplate(channel: RuntimeItemGenerationChannel) {
|
||||
case 'treasure':
|
||||
return {
|
||||
kinds: ['relic', 'consumable', 'material'] as RuntimeItemKind[],
|
||||
permanence: ['permanent', 'timed', 'resource'] as RuntimeItemPermanence[],
|
||||
permanence: [
|
||||
'permanent',
|
||||
'timed',
|
||||
'resource',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 2,
|
||||
};
|
||||
case 'npc_trade':
|
||||
return {
|
||||
kinds: ['consumable', 'material', 'relic', 'equipment'] as RuntimeItemKind[],
|
||||
permanence: ['timed', 'resource', 'permanent', 'permanent'] as RuntimeItemPermanence[],
|
||||
kinds: [
|
||||
'consumable',
|
||||
'material',
|
||||
'relic',
|
||||
'equipment',
|
||||
] as RuntimeItemKind[],
|
||||
permanence: [
|
||||
'timed',
|
||||
'resource',
|
||||
'permanent',
|
||||
'permanent',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 4,
|
||||
};
|
||||
case 'npc_reward':
|
||||
return {
|
||||
kinds: ['consumable', 'relic', 'equipment'] as RuntimeItemKind[],
|
||||
permanence: ['timed', 'permanent', 'permanent'] as RuntimeItemPermanence[],
|
||||
permanence: [
|
||||
'timed',
|
||||
'permanent',
|
||||
'permanent',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 1,
|
||||
};
|
||||
case 'monster_drop':
|
||||
return {
|
||||
kinds: ['material', 'consumable', 'relic'] as RuntimeItemKind[],
|
||||
permanence: ['resource', 'timed', 'permanent'] as RuntimeItemPermanence[],
|
||||
permanence: [
|
||||
'resource',
|
||||
'timed',
|
||||
'permanent',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 2,
|
||||
};
|
||||
case 'quest_reward':
|
||||
return {
|
||||
kinds: ['equipment', 'relic', 'consumable'] as RuntimeItemKind[],
|
||||
permanence: ['permanent', 'permanent', 'timed'] as RuntimeItemPermanence[],
|
||||
permanence: [
|
||||
'permanent',
|
||||
'permanent',
|
||||
'timed',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 2,
|
||||
};
|
||||
default:
|
||||
return {
|
||||
kinds: ['consumable', 'material', 'relic'] as RuntimeItemKind[],
|
||||
permanence: ['timed', 'resource', 'permanent'] as RuntimeItemPermanence[],
|
||||
permanence: [
|
||||
'timed',
|
||||
'resource',
|
||||
'permanent',
|
||||
] as RuntimeItemPermanence[],
|
||||
defaultCount: 2,
|
||||
};
|
||||
}
|
||||
@@ -135,20 +166,28 @@ function planRuntimeItems(
|
||||
const count = Math.max(1, options.itemCount ?? template.defaultCount);
|
||||
const relationAnchor = resolveRelationAnchor(context);
|
||||
const targetBuildDirection = resolveGapDrivenTags(context);
|
||||
const seed = hashText(`${options.seedKey}:${options.variant ?? 'default'}:${context.generationChannel}`);
|
||||
const seed = hashText(
|
||||
`${options.seedKey}:${options.variant ?? 'default'}:${context.generationChannel}`,
|
||||
);
|
||||
|
||||
return Array.from({length: count}, (_, index) => {
|
||||
const kinds = options.fixedKinds?.length ? options.fixedKinds : template.kinds;
|
||||
const permanences = options.fixedPermanence?.length ? options.fixedPermanence : template.permanence;
|
||||
return Array.from({ length: count }, (_, index) => {
|
||||
const kinds = options.fixedKinds?.length
|
||||
? options.fixedKinds
|
||||
: template.kinds;
|
||||
const permanences = options.fixedPermanence?.length
|
||||
? options.fixedPermanence
|
||||
: template.permanence;
|
||||
const itemKind = kinds[(seed + index) % kinds.length] ?? 'consumable';
|
||||
const permanence = permanences[(seed + index) % permanences.length] ?? 'timed';
|
||||
const permanence =
|
||||
permanences[(seed + index) % permanences.length] ?? 'timed';
|
||||
|
||||
return {
|
||||
slot: index === 0 ? 'primary' : index === 1 ? 'secondary' : 'support',
|
||||
itemKind,
|
||||
permanence,
|
||||
narrativeWeight: index === 0 ? 'heavy' : 'medium',
|
||||
targetBuildDirection: targetBuildDirection.length > 0 ? targetBuildDirection : ['均衡'],
|
||||
targetBuildDirection:
|
||||
targetBuildDirection.length > 0 ? targetBuildDirection : ['均衡'],
|
||||
relationAnchor,
|
||||
} satisfies RuntimeItemPlan;
|
||||
});
|
||||
@@ -201,7 +240,11 @@ export function buildDirectedRuntimeReward(
|
||||
): DirectedRuntimeReward {
|
||||
const plans = planRuntimeItems(context, options);
|
||||
const compiledItems = plans.map((plan, index) =>
|
||||
compilePlannedItem(context, plan, `${options.seedKey}:${plan.slot}:${index}`),
|
||||
compilePlannedItem(
|
||||
context,
|
||||
plan,
|
||||
`${options.seedKey}:${plan.slot}:${index}`,
|
||||
),
|
||||
);
|
||||
|
||||
return buildDirectedRewardFromItems(compiledItems, options);
|
||||
@@ -229,7 +272,10 @@ export async function generateDirectedRuntimeReward(
|
||||
|
||||
return buildDirectedRewardFromItems(compiledItems, options);
|
||||
} catch (error) {
|
||||
console.warn('[RuntimeItemDirector] falling back to deterministic item intent', error);
|
||||
console.warn(
|
||||
'[RuntimeItemDirector] falling back to deterministic item intent',
|
||||
error,
|
||||
);
|
||||
return buildDirectedRuntimeReward(context, options);
|
||||
}
|
||||
}
|
||||
@@ -238,5 +284,7 @@ export function buildRuntimeInventoryStock(
|
||||
context: RuntimeItemGenerationContext,
|
||||
options: RuntimeRewardOptions,
|
||||
): InventoryItem[] {
|
||||
return flattenDirectedRuntimeRewardItems(buildDirectedRuntimeReward(context, options));
|
||||
return flattenDirectedRuntimeRewardItems(
|
||||
buildDirectedRuntimeReward(context, options),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user