RC-43 | Weapons | Populate Table Content
This commit is contained in:
parent
5773c2e920
commit
ff43ef2eb9
3 changed files with 39 additions and 5 deletions
|
|
@ -45,14 +45,34 @@
|
|||
<tbody>
|
||||
{{#each weapons as | slot |}}
|
||||
{{#if slot.empty}}
|
||||
<tr data-row="{{slot.index}}" class="{{slot.class}}">
|
||||
<td>---</td>
|
||||
<tr
|
||||
data-row="{{slot.index}}"
|
||||
class="{{slot.class}}"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<td>{{ rc-i18n "RipCrypt.common.empty" }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr data-row="index"></tr>
|
||||
<tr data-row="{{slot.index}}" class="{{slot.class}}">
|
||||
<td>{{ slot.data.name }}</td>
|
||||
<td>
|
||||
{{#if slot.data.system.traitString}}
|
||||
<span class="traits">{{ slot.data.system.traitString }}</span>
|
||||
{{/if}}
|
||||
{{#if slot.data.system.rangeString}}
|
||||
<span class="range">{{ slot.data.system.rangeString }}</span>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{ slot.data.system.wear.value }} / {{ slot.data.system.wear.max }}
|
||||
</td>
|
||||
<td>
|
||||
{{ slot.data.system.damage }}
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -102,11 +102,12 @@ export class HeroSummaryCardV1 extends GenericSheetMixin(HandlebarsApplicationMi
|
|||
|
||||
static async prepareWeapons(ctx) {
|
||||
const limit = ctx.actor.system.limit.weapons;
|
||||
const embedded = ctx.actor.itemTypes.weapon;
|
||||
ctx.weapons = [];
|
||||
for (let i = 0; i < limit; i++) {
|
||||
ctx.weapons.push({
|
||||
data: null,
|
||||
empty: true,
|
||||
data: embedded[i],
|
||||
empty: embedded.at(i) === undefined,
|
||||
index: i + 1,
|
||||
class: i % 2 === 1 ? `row-alt` : ``,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,4 +42,17 @@ export class WeaponData extends foundry.abstract.TypeDataModel {
|
|||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
};
|
||||
|
||||
// #region Getters
|
||||
get traitString() {
|
||||
return [...this.traits].join(`, `);
|
||||
}
|
||||
|
||||
get rangeString() {
|
||||
if (this.range.short && this.range.long) {
|
||||
return `${this.range.short} / ${this.range.long}`;
|
||||
};
|
||||
return String(this.range.short ?? this.range.long ?? ``);
|
||||
}
|
||||
// #endregion
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue