NPC: General section feature parity

pull/12/head
Matheus Clemente 2024-03-30 20:58:27 -03:00
parent 4589b701a2
commit 6416a4462b
1 changed files with 58 additions and 2 deletions

View File

@ -4,8 +4,7 @@
<div class="filtercontainer"> <div class="filtercontainer">
<!-- Name filter. --> <!-- Name filter. -->
<div class="filter"> <div class="filter">
<label class="unit-title" for="compendiumBrowser.name">{{ game.i18n.localize('Name') }}</label> <input type="text" name="compendiumBrowser.name" v-model="name" :placeholder="game.i18n.localize('Name')" />
<input type="text" name="compendiumBrowser.name" v-model="name" placeholder="Hydra"/>
</div> </div>
<!-- Sort --> <!-- Sort -->
@ -45,6 +44,34 @@
:options="getOptions(CONFIG.DND5E.actorSizes)" :options="getOptions(CONFIG.DND5E.actorSizes)"
/> />
</div> </div>
<div class="filter">
<label class="unit-title" for="compendiumBrowser.legact">{{ game.i18n.localize('Legendary Actions') }}</label>
<Multiselect
v-model="legact"
:searchable="false"
:create-option="false"
:options="getOptions(yesNo)"
/>
</div>
<div class="filter">
<label class="unit-title" for="compendiumBrowser.legres">{{ game.i18n.localize('Legendary Resistances') }}</label>
<Multiselect
v-model="legres"
:searchable="false"
:create-option="false"
:options="getOptions(yesNo)"
/>
</div>
<div class="filter">
<label class="unit-title" for="compendiumBrowser.creatureType">{{ game.i18n.localize('Creature Type') }}</label>
<Multiselect
v-model="creatureType"
mode="tags"
:searchable="false"
:create-option="false"
:options="getOptions(CONFIG.DND5E.creatureTypes)"
/>
</div>
</div> </div>
</section> </section>
@ -139,7 +166,10 @@ export default {
// Mixed decimals and ints aren't supported by the slider, so // Mixed decimals and ints aren't supported by the slider, so
// just use 0 for all CRs below 1. // just use 0 for all CRs below 1.
crRange: [0, 30], crRange: [0, 30],
legact: '',
legres: '',
size: [], size: [],
creatureType: [],
} }
}, },
methods: { methods: {
@ -173,7 +203,10 @@ export default {
this.sortBy = 'name'; this.sortBy = 'name';
this.name = ''; this.name = '';
this.crRange = [0, 30]; this.crRange = [0, 30];
this.legact = '';
this.legres = '';
this.size = []; this.size = [];
this.creatureType = [];
}, },
/** /**
* Get multiselect options. * Get multiselect options.
@ -209,10 +242,25 @@ export default {
); );
} }
if (this.legact === "yes") {
result = result.filter((entry) => entry.system.resources.legact.max);
} else if (this.legact === "no") {
result = result.filter((entry) => !entry.system.resources.legact.max);
}
if (this.legres === "yes") {
result = result.filter((entry) => entry.system.resources.legres.max);
} else if (this.legres === "no") {
result = result.filter((entry) => !entry.system.resources.legres.max);
}
// Handle multiselect filters, which use arrays as their values. // Handle multiselect filters, which use arrays as their values.
if (Array.isArray(this.size) && this.size.length > 0) { if (Array.isArray(this.size) && this.size.length > 0) {
result = result.filter(entry => this.size.includes(entry.system.traits.size)); result = result.filter(entry => this.size.includes(entry.system.traits.size));
} }
if (Array.isArray(this.creatureType) && this.creatureType.length > 0) {
result = result.filter(entry => this.creatureType.includes(entry.system.details.type.value));
}
// Reflow pager. // Reflow pager.
if (result.length > this.pager.perPage) { if (result.length > this.pager.perPage) {
@ -243,6 +291,9 @@ export default {
? result.slice(this.pager.firstIndex, this.pager.lastIndex) ? result.slice(this.pager.firstIndex, this.pager.lastIndex)
: result; : result;
}, },
yesNo() {
return { "yes": { label: "Yes" }, "no": { label: "No" }};
}
}, },
watch: {}, watch: {},
// Handle created hook. // Handle created hook.
@ -254,8 +305,13 @@ export default {
'dnd5e.monsters', 'dnd5e.monsters',
// insert additional packs as needed. // insert additional packs as needed.
], [ ], [
'system.attributes.ac',
'system.attributes.hp',
'system.abilities',
'system.details.cr', 'system.details.cr',
'system.details.type', 'system.details.type',
'system.resources.legact',
'system.resources.legres',
'system.traits.size' 'system.traits.size'
// insert additional properties as needed. // insert additional properties as needed.
]).then(packIndex => { ]).then(packIndex => {