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