This commit is contained in:
2026-04-16 15:45:00 +08:00
parent 6363267bca
commit 91b63675eb
43 changed files with 5652 additions and 853 deletions

View File

@@ -439,12 +439,19 @@ function mergeInventory(items: InventoryItem[]) {
function buildCharacterInventory(
character: Character,
worldType: WorldType | null,
customWorldProfile = getRuntimeCustomWorldProfile(),
) {
if (worldType === WorldType.CUSTOM && getRuntimeCustomWorldProfile()) {
return sortInventoryItems(buildCustomWorldStarterInventoryItems(character));
if (worldType === WorldType.CUSTOM && customWorldProfile) {
return sortInventoryItems(
buildCustomWorldStarterInventoryItems(character, customWorldProfile),
);
}
const packItems = getInventoryItems(character, worldType).map((item) =>
const packItems = getInventoryItems(
character,
worldType,
customWorldProfile,
).map((item) =>
buildInventoryItem('player', item.category, item.name, item.quantity),
);
return sortInventoryItems(mergeInventory(packItems));
@@ -453,10 +460,17 @@ function buildCharacterInventory(
function buildCharacterNpcInventory(
character: Character,
worldType: WorldType | null,
customWorldProfile = getRuntimeCustomWorldProfile(),
) {
if (worldType === WorldType.CUSTOM && getRuntimeCustomWorldProfile()) {
const starterEquipment = buildCustomWorldStarterEquipmentItems(character);
const starterInventory = buildCustomWorldStarterInventoryItems(character);
if (worldType === WorldType.CUSTOM && customWorldProfile) {
const starterEquipment = buildCustomWorldStarterEquipmentItems(
character,
customWorldProfile,
);
const starterInventory = buildCustomWorldStarterInventoryItems(
character,
customWorldProfile,
);
return sortInventoryItems(
mergeInventory([
...(Object.values(starterEquipment).filter(Boolean) as InventoryItem[]),
@@ -465,7 +479,7 @@ function buildCharacterNpcInventory(
);
}
const equipmentItems = getCharacterEquipment(character).map((item) =>
const equipmentItems = getCharacterEquipment(character, customWorldProfile).map((item) =>
buildInventoryItem(
`npc-${character.id}`,
item.slot,
@@ -1503,8 +1517,9 @@ export function removeInventoryItem(
export function buildInitialPlayerInventory(
character: Character,
worldType: WorldType | null,
customWorldProfile = getRuntimeCustomWorldProfile(),
) {
return buildCharacterInventory(character, worldType);
return buildCharacterInventory(character, worldType, customWorldProfile);
}
function buildMonsterPresetInventory(
@@ -1547,7 +1562,11 @@ export function buildInitialNpcState(
? (() => {
const character = getCharacterById(encounter.characterId);
return character
? buildCharacterNpcInventory(character, worldType)
? buildCharacterNpcInventory(
character,
worldType,
state?.customWorldProfile ?? getRuntimeCustomWorldProfile(),
)
: buildRoleInventory(encounter, worldType, state);
})()
: encounter.monsterPresetId