Skip to content

Commit

Permalink
v1.3.8 - NPCs are now included in the list of possible characters if …
Browse files Browse the repository at this point in the history
…they are within the active scene and a player has ownership.
  • Loading branch information
Garsondee committed Jun 10, 2024
1 parent 0993483 commit e80c220
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@ function buildCharacterSelection(users, preSelectedCharacterIds, characterLevels
return sceneTokens.some(token => token.actorId === character.id);
});

if (charactersInScene.length > 0) {
// Filter NPCs that have a token in the current scene and the player owns them
const npcsInScene = sceneTokens.filter(token => {
return token.actor.data.type === 'npc' && token.actor.hasPlayerOwner && token.actor.ownership[user.id] === 3;
}).map(token => token.actor);

const charactersAndNPCsInScene = charactersInScene.concat(npcsInScene);

if (charactersAndNPCsInScene.length > 0) {
characterSelection += `<div class="user-column"><strong>${user.name}</strong>`;
charactersInScene.forEach(character => {
charactersAndNPCsInScene.forEach(character => {
const tokenTexture = character.prototypeToken.texture.src || '';
characterSelection += `
<div class="character-selection">
Expand Down

0 comments on commit e80c220

Please sign in to comment.