统一 Rust 与 TypeScript 格式化门禁
纳入 AGC Cargo workspace 的统一 rustfmt 检查与格式化入口 完成项目 TypeScript/Prettier 与 Rust 全量格式化 修复 Pingora expected executable 门禁的空白敏感误报 同步开发运维文档与 AGC skill pack 格式化忽略规则
This commit is contained in:
+101
-48
@@ -10,9 +10,15 @@ import type {
|
||||
RuntimeItemPlan,
|
||||
TimedBuildBuff,
|
||||
} from '../types';
|
||||
import {normalizeBuildRole, normalizeBuildTags} from './buildTags';
|
||||
import { normalizeBuildRole, normalizeBuildTags } from './buildTags';
|
||||
|
||||
const RARITY_ORDER: ItemRarity[] = ['common', 'uncommon', 'rare', 'epic', 'legendary'];
|
||||
const RARITY_ORDER: ItemRarity[] = [
|
||||
'common',
|
||||
'uncommon',
|
||||
'rare',
|
||||
'epic',
|
||||
'legendary',
|
||||
];
|
||||
|
||||
function clampIndex(index: number) {
|
||||
return Math.max(0, Math.min(RARITY_ORDER.length - 1, index));
|
||||
@@ -21,7 +27,7 @@ function clampIndex(index: number) {
|
||||
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);
|
||||
@@ -46,7 +52,10 @@ function buildStructuralTags(plan: RuntimeItemPlan) {
|
||||
|
||||
function resolveEquipmentSlotId(plan: RuntimeItemPlan) {
|
||||
if (plan.itemKind === 'equipment') {
|
||||
if (plan.targetBuildDirection.includes('守御') || plan.targetBuildDirection.includes('护体')) {
|
||||
if (
|
||||
plan.targetBuildDirection.includes('守御') ||
|
||||
plan.targetBuildDirection.includes('护体')
|
||||
) {
|
||||
return 'armor' as const;
|
||||
}
|
||||
return 'weapon' as const;
|
||||
@@ -79,23 +88,38 @@ function buildRuntimeBudget(
|
||||
plan: RuntimeItemPlan,
|
||||
seedKey: string,
|
||||
): RuntimeItemCompileBudget {
|
||||
const seed = hashText(`${context.generationChannel}:${seedKey}:${plan.slot}:${plan.itemKind}`);
|
||||
const channelBaseIndex = context.generationChannel === 'quest_reward'
|
||||
? 2
|
||||
: context.generationChannel === 'treasure'
|
||||
? 1
|
||||
: context.generationChannel === 'monster_drop'
|
||||
? 0
|
||||
: 1;
|
||||
const seed = hashText(
|
||||
`${context.generationChannel}:${seedKey}:${plan.slot}:${plan.itemKind}`,
|
||||
);
|
||||
const channelBaseIndex =
|
||||
context.generationChannel === 'quest_reward'
|
||||
? 2
|
||||
: context.generationChannel === 'treasure'
|
||||
? 1
|
||||
: context.generationChannel === 'monster_drop'
|
||||
? 0
|
||||
: 1;
|
||||
const slotBonus = plan.slot === 'primary' ? 1 : 0;
|
||||
const permanenceBonus = plan.permanence === 'permanent' ? 1 : 0;
|
||||
const rarityIndex = clampIndex(channelBaseIndex + slotBonus + permanenceBonus + (seed % 2));
|
||||
const rarityIndex = clampIndex(
|
||||
channelBaseIndex + slotBonus + permanenceBonus + (seed % 2),
|
||||
);
|
||||
const rarity = RARITY_ORDER[rarityIndex] ?? 'common';
|
||||
|
||||
return {
|
||||
rarity,
|
||||
buildTagLimit: rarity === 'legendary' ? 2 : rarity === 'epic' || rarity === 'rare' ? 2 : 1,
|
||||
timedBuffTagLimit: rarity === 'legendary' ? 3 : rarity === 'epic' || rarity === 'rare' ? 2 : 1,
|
||||
buildTagLimit:
|
||||
rarity === 'legendary'
|
||||
? 2
|
||||
: rarity === 'epic' || rarity === 'rare'
|
||||
? 2
|
||||
: 1,
|
||||
timedBuffTagLimit:
|
||||
rarity === 'legendary'
|
||||
? 3
|
||||
: rarity === 'epic' || rarity === 'rare'
|
||||
? 2
|
||||
: 1,
|
||||
timedBuffDuration: rarity === 'legendary' ? 3 : rarity === 'epic' ? 3 : 2,
|
||||
statBudgetTier: rarityIndex + 1,
|
||||
};
|
||||
@@ -106,17 +130,22 @@ function buildTimedBuffs(
|
||||
intent: RuntimeItemAiIntent,
|
||||
budget: RuntimeItemCompileBudget,
|
||||
): TimedBuildBuff[] {
|
||||
const tags = normalizeBuildTags(intent.desiredBuildTags, budget.timedBuffTagLimit);
|
||||
const tags = normalizeBuildTags(
|
||||
intent.desiredBuildTags,
|
||||
budget.timedBuffTagLimit,
|
||||
);
|
||||
if (tags.length <= 0) return [];
|
||||
|
||||
return [{
|
||||
id: `${itemId}:buff`,
|
||||
sourceType: 'item',
|
||||
sourceId: itemId,
|
||||
name: `${tags[0]}增益`,
|
||||
tags,
|
||||
durationTurns: budget.timedBuffDuration,
|
||||
}];
|
||||
return [
|
||||
{
|
||||
id: `${itemId}:buff`,
|
||||
sourceType: 'item',
|
||||
sourceId: itemId,
|
||||
name: `${tags[0]}增益`,
|
||||
tags,
|
||||
durationTurns: budget.timedBuffDuration,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function buildUseProfile(
|
||||
@@ -125,7 +154,8 @@ function buildUseProfile(
|
||||
budget: RuntimeItemCompileBudget,
|
||||
itemId: string,
|
||||
): ItemUseProfile | null {
|
||||
if (plan.itemKind !== 'consumable' && plan.permanence === 'permanent') return null;
|
||||
if (plan.itemKind !== 'consumable' && plan.permanence === 'permanent')
|
||||
return null;
|
||||
|
||||
const useProfile: ItemUseProfile = {};
|
||||
|
||||
@@ -136,17 +166,18 @@ function buildUseProfile(
|
||||
useProfile.manaRestore = 14 + budget.statBudgetTier * 8;
|
||||
}
|
||||
if (intent.desiredFunctionalBias.includes('cooldown')) {
|
||||
useProfile.cooldownReduction = budget.rarity === 'legendary' || budget.rarity === 'epic' ? 1 : 0;
|
||||
useProfile.cooldownReduction =
|
||||
budget.rarity === 'legendary' || budget.rarity === 'epic' ? 1 : 0;
|
||||
}
|
||||
if (plan.permanence === 'timed' || plan.itemKind === 'consumable') {
|
||||
useProfile.buildBuffs = buildTimedBuffs(itemId, intent, budget);
|
||||
}
|
||||
|
||||
if (
|
||||
(useProfile.hpRestore ?? 0) <= 0
|
||||
&& (useProfile.manaRestore ?? 0) <= 0
|
||||
&& (useProfile.cooldownReduction ?? 0) <= 0
|
||||
&& (useProfile.buildBuffs?.length ?? 0) <= 0
|
||||
(useProfile.hpRestore ?? 0) <= 0 &&
|
||||
(useProfile.manaRestore ?? 0) <= 0 &&
|
||||
(useProfile.cooldownReduction ?? 0) <= 0 &&
|
||||
(useProfile.buildBuffs?.length ?? 0) <= 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
@@ -164,15 +195,32 @@ function buildStatProfile(
|
||||
const statProfile: ItemStatProfile = {};
|
||||
const tier = budget.statBudgetTier;
|
||||
|
||||
if (plan.itemKind === 'equipment' || plan.itemKind === 'relic' || plan.itemKind === 'quest') {
|
||||
if (intent.desiredFunctionalBias.includes('guard') || plan.targetBuildDirection.includes('守御')) {
|
||||
statProfile.maxHpBonus = 6 * tier + (plan.itemKind === 'equipment' ? 10 : 4);
|
||||
statProfile.incomingDamageMultiplier = Number(Math.max(0.84, 1 - tier * 0.03).toFixed(2));
|
||||
if (
|
||||
plan.itemKind === 'equipment' ||
|
||||
plan.itemKind === 'relic' ||
|
||||
plan.itemKind === 'quest'
|
||||
) {
|
||||
if (
|
||||
intent.desiredFunctionalBias.includes('guard') ||
|
||||
plan.targetBuildDirection.includes('守御')
|
||||
) {
|
||||
statProfile.maxHpBonus =
|
||||
6 * tier + (plan.itemKind === 'equipment' ? 10 : 4);
|
||||
statProfile.incomingDamageMultiplier = Number(
|
||||
Math.max(0.84, 1 - tier * 0.03).toFixed(2),
|
||||
);
|
||||
}
|
||||
if (intent.desiredFunctionalBias.includes('mana') || plan.targetBuildDirection.includes('法力')) {
|
||||
statProfile.maxManaBonus = 8 * tier + (plan.itemKind === 'relic' ? 10 : 0);
|
||||
if (
|
||||
intent.desiredFunctionalBias.includes('mana') ||
|
||||
plan.targetBuildDirection.includes('法力')
|
||||
) {
|
||||
statProfile.maxManaBonus =
|
||||
8 * tier + (plan.itemKind === 'relic' ? 10 : 0);
|
||||
}
|
||||
if (intent.desiredFunctionalBias.includes('damage') || plan.targetBuildDirection.length > 0) {
|
||||
if (
|
||||
intent.desiredFunctionalBias.includes('damage') ||
|
||||
plan.targetBuildDirection.length > 0
|
||||
) {
|
||||
statProfile.outgoingDamageBonus = Number((0.03 * tier).toFixed(2));
|
||||
}
|
||||
}
|
||||
@@ -186,29 +234,34 @@ function buildProfile(
|
||||
intent: RuntimeItemAiIntent,
|
||||
budget: RuntimeItemCompileBudget,
|
||||
): ItemBuildProfile | null {
|
||||
if (plan.permanence !== 'permanent' || (plan.itemKind !== 'equipment' && plan.itemKind !== 'relic' && plan.itemKind !== 'quest')) {
|
||||
if (
|
||||
plan.permanence !== 'permanent' ||
|
||||
(plan.itemKind !== 'equipment' &&
|
||||
plan.itemKind !== 'relic' &&
|
||||
plan.itemKind !== 'quest')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tags = normalizeBuildTags(intent.desiredBuildTags, budget.buildTagLimit);
|
||||
const tags = normalizeBuildTags(
|
||||
intent.desiredBuildTags,
|
||||
budget.buildTagLimit,
|
||||
);
|
||||
if (tags.length <= 0) return null;
|
||||
|
||||
return {
|
||||
role: normalizeBuildRole(tags[0]),
|
||||
tags,
|
||||
synergy: normalizeBuildTags([
|
||||
...plan.targetBuildDirection,
|
||||
...intent.desiredBuildTags,
|
||||
], 3),
|
||||
synergy: normalizeBuildTags(
|
||||
[...plan.targetBuildDirection, ...intent.desiredBuildTags],
|
||||
3,
|
||||
),
|
||||
craftTags: tags,
|
||||
forgeRank: 0,
|
||||
};
|
||||
}
|
||||
|
||||
function buildValue(
|
||||
budget: RuntimeItemCompileBudget,
|
||||
plan: RuntimeItemPlan,
|
||||
) {
|
||||
function buildValue(budget: RuntimeItemCompileBudget, plan: RuntimeItemPlan) {
|
||||
const baseValue = {
|
||||
common: 18,
|
||||
uncommon: 32,
|
||||
@@ -248,7 +301,7 @@ export function compileRuntimeItem(params: {
|
||||
plan: RuntimeItemPlan;
|
||||
intent: RuntimeItemAiIntent;
|
||||
}) {
|
||||
const {seedKey, context, plan, intent} = params;
|
||||
const { seedKey, context, plan, intent } = params;
|
||||
const budget = buildRuntimeBudget(context, plan, seedKey);
|
||||
const itemId = `runtime:${context.generationChannel}:${hashText(seedKey).toString(36)}`;
|
||||
const runtimeMetadata = {
|
||||
|
||||
Reference in New Issue
Block a user