tableized group sheet
parent
c474d63156
commit
099d1c5d16
|
|
@ -28,13 +28,18 @@ export class GroupSheet extends ActorSheet {
|
|||
|
||||
|
||||
// update group
|
||||
const settings = {...group.system.settings}
|
||||
let settings = {...group.system.settings}
|
||||
character.items.filter((i) => i.type === "Advantage").forEach((advantage) => {
|
||||
settings[this.#stringToKeyFieldName(advantage.name)] = false
|
||||
if (!settings[sheet.#stringToKeyFieldName(advantage.name)]) {
|
||||
settings[sheet.#stringToKeyFieldName(advantage.name)] = false
|
||||
}
|
||||
})
|
||||
character.items.filter((i) => i.type === "Skill").forEach((skill) => {
|
||||
settings[this.#stringToKeyFieldName(skill.name)] = false
|
||||
}),
|
||||
if (!settings[sheet.#stringToKeyFieldName(skill.name)]) {
|
||||
settings[sheet.#stringToKeyFieldName(skill.name)] = false
|
||||
}
|
||||
})
|
||||
|
||||
await group.update({
|
||||
system: {
|
||||
characters: [
|
||||
|
|
@ -55,7 +60,7 @@ export class GroupSheet extends ActorSheet {
|
|||
}
|
||||
|
||||
#stringToKeyFieldName(s) {
|
||||
return s.replace(/[ \[\]:]/g, "_").toLowerCase()
|
||||
return s
|
||||
}
|
||||
|
||||
/** @override */
|
||||
|
|
@ -74,14 +79,46 @@ export class GroupSheet extends ActorSheet {
|
|||
context.system = groupData.system;
|
||||
context.flags = groupData.flags;
|
||||
context.characters = []
|
||||
context.isGM = game.user.isGM;
|
||||
|
||||
context.fields = [];
|
||||
|
||||
const hiddenFields = Object.entries(groupData.system.settings).filter(([key, value]) => value === true).map(([key, value]) => key)
|
||||
|
||||
context.fields = {}
|
||||
context.fields["head"] = {}
|
||||
for (const field of hiddenFields) {
|
||||
|
||||
context.fields[field] = {}
|
||||
|
||||
for (const characterId of groupData.system.characters) {
|
||||
const character = await game.actors.get(characterId)
|
||||
context.fields[field][character.name] = "-"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (const characterId of groupData.system.characters) {
|
||||
const character = await game.actors.get(characterId)
|
||||
context.characters.push(
|
||||
|
||||
character.items.filter((i) => i.type === "Advantage").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((advantage) => {
|
||||
const n = this.#stringToKeyFieldName(advantage.name)
|
||||
if (!context.fields[n]) {
|
||||
context.fields[n] = {}
|
||||
}
|
||||
context.fields[n][character.name] = advantage.system.value ?? "Ja" // TODO: Allow GM roll
|
||||
})
|
||||
|
||||
character.items.filter((i) => i.type === "Skill").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((skill) => {
|
||||
const n = this.#stringToKeyFieldName(skill.name)
|
||||
if (!context.fields[n]) {
|
||||
context.fields[n] = {}
|
||||
}
|
||||
context.fields[n][character.name] = skill.system.taw ?? 0 // TODO: Allow GM roll
|
||||
})
|
||||
|
||||
context.fields.head[character.name] =
|
||||
{
|
||||
img: character.img,
|
||||
name: character.name,
|
||||
|
|
@ -96,25 +133,10 @@ export class GroupSheet extends ActorSheet {
|
|||
{name: "KO", value: character.system.attribute.ko.aktuell},
|
||||
{name: "KK", value: character.system.attribute.kk.aktuell},
|
||||
],
|
||||
advantages: character.items.filter((i) => i.type === "Advantage").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((advantage) => {
|
||||
return {
|
||||
name: advantage.name,
|
||||
id: advantage._id,
|
||||
value: advantage.system.value,
|
||||
}
|
||||
}),
|
||||
skills: character.items.filter((i) => i.type === "Skill").filter((i) => hiddenFields.includes(this.#stringToKeyFieldName(i.name))).map((skill) => {
|
||||
return {
|
||||
name: skill.name,
|
||||
taw: skill.system.taw,
|
||||
id: skill._id
|
||||
}
|
||||
}),
|
||||
isLimited: character.isOwner || !character.limited,
|
||||
isVisible: character.isOwner || character.visible,
|
||||
isOwner: character.isOwner
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
context.equipments = [];
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
<div class="tab characters" data-group="primary" data-tab="characters">
|
||||
{{#if actor.limited}}
|
||||
{{#unless isGM}}
|
||||
<div class="characters-overview minimal">
|
||||
{{#each characters}}
|
||||
{{#if this.isVisible}}
|
||||
|
|
@ -33,14 +33,19 @@
|
|||
</div>
|
||||
{{else}}
|
||||
<div class="characters-overview">
|
||||
{{#each characters}}
|
||||
{{#if this.isVisible}}
|
||||
<div class="character">
|
||||
<div class="header clickable" data-id="{{this.id}}" data-operation="openActorSheet">
|
||||
<img class="profile-img" src="{{this.img}}" style="object-fit: cover;"
|
||||
title="{{this.name}}" alt="{{this.name}}"/>
|
||||
<span class="name">{{this.name}}</span>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Charakter</th>
|
||||
{{#each this.fields.head}}
|
||||
<th>
|
||||
<div class="character">
|
||||
<div class="header clickable" data-id="{{this.id}}"
|
||||
data-operation="openActorSheet">
|
||||
<img class="profile-img" src="{{this.img}}" style="object-fit: cover;"
|
||||
title="{{this.name}}" alt="{{this.name}}"/>
|
||||
<span class="name">{{this.name}}</span>
|
||||
</div>
|
||||
{{#if this.isLimited}}
|
||||
<div class="mini-attributes">
|
||||
{{#each this.attributes}}
|
||||
|
|
@ -51,32 +56,37 @@
|
|||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="fixedElements">
|
||||
<ul class="inline-list">
|
||||
{{#each skills}}
|
||||
<li class="mini-skill clickable" data-actor-id="{{this.id}}"
|
||||
data-id="{{this.id}}">{{this.name}}: {{this.taw}}</li>{{/each}}
|
||||
</ul>
|
||||
<ul class="inline-list">
|
||||
{{#each advantages}}
|
||||
<li class="mini-advantage clickable" data-actor-id="{{this.id}}"
|
||||
data-id="{{this.id}}">{{this.name}} {{#if this.value}}
|
||||
[{{this.value}}]{{/if}}</li>{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if this.isOwner}}
|
||||
<div class="owneroptions">
|
||||
<button class="owneroption clickable" data-operation="removeFromParty"
|
||||
data-id="{{this.id}}">Leave Group
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each this.fields}}
|
||||
{{#unless (eq @key "head")}}
|
||||
<tr>
|
||||
<th>
|
||||
{{ @key}}
|
||||
</th>
|
||||
|
||||
{{#each this}}
|
||||
<td>
|
||||
{{#if (eq this "-")}}
|
||||
|
||||
{{else}}
|
||||
{{this}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/each}}
|
||||
|
||||
</tr>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
<div class="tab inventory" data-group="primary" data-tab="inventory">
|
||||
{{> 'systems/DSA_4-1/templates/ui/partial-equipment-group-button.hbs' equipments}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue