1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user