add Inventar and combat system base values

This commit is contained in:
Sven Balzer 2024-10-12 16:58:13 +02:00
parent 948dba6032
commit e2ffb67d35
6 changed files with 309 additions and 102 deletions

View File

@ -15,14 +15,31 @@
</div>
{{/inline}}
{{#*inline "editable-checkbox"}}
<div class="editable-input editable-checkbox">
{{#if @root.editable}}
<input type="checkbox" name="{{name}}" {{checked value}}>
{{else}}
<div>
{{value}}
{{#unless value}}{{placeholder}}{{/unless}}
</div>
{{/if}}
{{#if placeholder}}
<div class="placeholder">{{placeholder}}</div>
{{/if}}
</div>
{{/inline}}
{{#*inline "die-type"}}
<div class="center die die-{{type}}">{{localize (concat "DSA41.attributes.short." type)}}</div>
{{/inline}}
{{#*inline "die-value"}}
<div class="col">
<div class="col noflex">
<div class="center">{{localize (concat "DSA41.attributes.short." type)}}</div>
<div class="die die-{{type}}">{{lookup @root.actor.system.computed type}}</div>
<div class="die die-{{type}}">{{lookup @root.actor.system.computed.attributes.with_modifiers type}}</div>
</div>
{{/inline}}
@ -41,6 +58,20 @@
{{/each}}
</div>
<nav class="tabs" data-group="primary">
<div class="row noflex">
<a data-tab="tab1">{{localize "DSA41.character.eigenschaften"}}</a>
</div>
<div class="row noflex">
<a data-tab="tab2">{{localize "DSA41.character.talente"}}</a>
</div>
<div class="row noflex">
<a data-tab="tab3">{{localize "DSA41.character.inventar"}}</a>
</div>
</nav>
<section class="content">
<div class="tab" data-group="primary" data-tab="tab1">
<div class="row">
<fieldset>
<legend>{{localize "DSA41.attributes.label"}}</legend>
@ -72,7 +103,35 @@
</table>
</fieldset>
</div>
<table>
<tr>
<td>Lebenspunkte</td>
<td>{{actor.system.computed.max_lebenspunkte}}</td>
<td>Ausdauer</td>
<td>{{actor.system.computed.max_ausdauer}}</td>
</tr>
<tr>
<td>Astralenergie</td>
<td>{{actor.system.computed.max_atralenergie}}</td>
<td>Magieresistenz</td>
<td>{{actor.system.computed.magieresistenz}}</td>
</tr>
<tr>
<td>INI-Basiswert</td>
<td>{{actor.system.computed.ini_basiswert}}</td>
<td>AT-Basiswert</td>
<td>{{actor.system.computed.at_basiswert}}</td>
</tr>
<tr>
<td>PA-Basiswert</td>
<td>{{actor.system.computed.pa_basiswert}}</td>
<td>FK-Basiswert</td>
<td>{{actor.system.computed.fk_basiswert}}</td>
</tr>
</table>
</div>
<div class="tab" data-group="primary" data-tab="tab2">
<div class="row">
<fieldset>
<legend>{{localize "DSA41.talente.kampf_talente.label"}}</legend>
@ -120,4 +179,69 @@
</fieldset>
</div>
{{/each}}
</div>
<div class="tab" data-group="primary" data-tab="tab3">
<div class="col inventar">
<div class="col list">
<div class="row list-header">
<div class="row">{{localize "DSA41.inventar.bewaffnung"}}</div>
<div>{{localize "DSA41.weight"}}</div>
</div>
{{#each actor.itemTypes.Bewaffnung}}
<div class="row list-item" data-item-id="{{this._id}}">
<div class="row item-name">
<img class="item-image" src="{{this.img}}" title="{{this.name}}">
<div class="col">
<span>{{this.name}}</span>
<span class="item-sub">
{{#if this.system.nahkampfwaffe.aktiv}} Nahkampfwaffe {{/if}}
{{#if this.system.parierwaffe.aktiv}} Parierwaffe {{/if}}
{{#if this.system.schild.aktiv}} Schild {{/if}}
{{#if this.system.fernkampfwaffe.aktiv}} Fernkampfwaffe {{/if}}
</span>
</div>
</div>
<div class="center">{{this.system.gewicht}}</div>
<div class="center">{{>editable-checkbox value=this.system.angelegt}}</div>
</div>
{{/each}}
</div>
<div class="col list">
<div class="row list-header">
<div class="row">{{localize "DSA41.inventar.ruestungen"}}</div>
<div>{{localize "DSA41.weight"}}</div>
</div>
{{#each actor.itemTypes.Ruestung}}
<div class="row list-item" data-item-id="{{this._id}}">
<div class="row item-name">
<img class="item-image" src="{{this.img}}" title="{{this.name}}">
<span class="center">{{this.name}}</span>
</div>
<div class="center">{{this.system.gewicht}}</div>
<div class="center">{{>editable-checkbox value=this.system.angelegt}}</div>
</div>
{{/each}}
</div>
<div class="col list">
<div class="row list-header">
<div class="row">{{localize "DSA41.inventar.gegenstaende"}}</div>
<div>{{localize "DSA41.weight"}}</div>
</div>
{{#each actor.itemTypes.Gegenstand}}
<div class="row list-item" data-item-id="{{this._id}}">
<div class="row item-name">
<img class="item-image" src="{{this.img}}" title="{{this.name}}">
<span class="center">{{this.name}}</span>
</div>
<div class="center">{{this.system.gewicht}}</div>
<div class="center">{{>editable-checkbox value=this.system.angelegt}}</div>
</div>
{{/each}}
</div>
</div>
</div>
</section>
</form>

View File

@ -85,7 +85,7 @@
<tr>
<td>{{localize "DSA41.bewaffnung.nahkampfwaffe.initiative"}}</td>
<td>{{>editable-input type="number" name="system.nahkampfwaffe.initiative" value=item.system.nahkampfwaffe.initiative}}</td>
<td>{{localize "DSA41.bewaffnung.nahkampfwaffe.bruchfaktor"}}</td>
<td>{{localize "DSA41.bewaffnung.bruchfaktor"}}</td>
<td>{{>editable-input type="number" name="system.nahkampfwaffe.bruchfaktor" value=item.system.nahkampfwaffe.bruchfaktor}}</td>
</tr>
<tr>
@ -127,7 +127,7 @@
</td>
</tr>
<tr>
<td>{{localize "DSA41.bewaffnung.parierwaffe.bruchfaktor"}}</td>
<td>{{localize "DSA41.bewaffnung.bruchfaktor"}}</td>
<td>{{>editable-input type="number" name="system.parierwaffe.bruchfaktor" value=item.system.parierwaffe.bruchfaktor}}</td>
</tr>
</table>
@ -155,7 +155,7 @@
<tr>
<td>{{localize "DSA41.bewaffnung.schild.initiative"}}</td>
<td>{{>editable-input type="number" name="system.schild.initiative" value=item.system.schild.initiative}}</td>
<td>{{localize "DSA41.bewaffnung.schild.bruchfaktor"}}</td>
<td>{{localize "DSA41.bewaffnung.bruchfaktor"}}</td>
<td>{{>editable-input type="number" name="system.schild.bruchfaktor" value=item.system.schild.bruchfaktor}}</td>
</tr>
</table>

View File

@ -15,6 +15,12 @@
"weight": "Gewicht",
"price": "Preis",
"character": {
"eigenschaften": "Eigenschaften",
"talente": "Talente",
"inventar": "Inventar"
},
"attributes": {
"label": "Eigenschaften",
"initial": "Startwert",
@ -162,6 +168,8 @@
},
"bewaffnung": {
"bruchfaktor": "Bruchfaktor",
"nahkampfwaffe": {
"label": "Nahkampfwaffe",
@ -174,7 +182,6 @@
"modifikator": "Modifikator",
"attacke": "Attacke",
"parade": "Parade",
"bruchfaktor": "Bruchfaktor",
"distanzklasse": "Distanzklasse",
"zweihaendig": "Zweihändig",
"werfbar": "Werfbar",
@ -189,8 +196,7 @@
"modifikator": "Modifikator",
"attacke": "Attacke",
"parade": "Parade",
"initiative": "Initiative",
"bruchfaktor": "Bruchfaktor"
"initiative": "Initiative"
},
"schild": {
@ -207,8 +213,7 @@
"modifikator": "Modifikator",
"attacke": "Attacke",
"parade": "Parade",
"initiative": "Initiative",
"bruchfaktor": "Bruchfaktor"
"initiative": "Initiative"
},
"fernkampfwaffe": {
@ -222,6 +227,12 @@
"munitionskosten": "Munitionskosten",
"munitionsgewicht": "Munitionsgewicht"
}
},
"inventar": {
"bewaffnung": "Bewaffnung",
"ruestungen": "Rüstungen",
"gegenstaende": "Gegenstände"
}
}
}

View File

@ -162,6 +162,8 @@
},
"bewaffnung": {
"bruchfaktor": "!!TODO!!",
"nahkampfwaffe": {
"label": "!!TODO!!",
@ -174,7 +176,6 @@
"modifikator": "!!TODO!!",
"attacke": "!!TODO!!",
"parade": "!!TODO!!",
"bruchfaktor": "!!TODO!!",
"distanzklasse": "!!TODO!!",
"zweihaendig": "!!TODO!!",
"werfbar": "!!TODO!!",
@ -189,8 +190,7 @@
"modifikator": "!!TODO!!",
"attacke": "!!TODO!!",
"parade": "!!TODO!!",
"initiative": "!!TODO!!",
"bruchfaktor": "!!TODO!!"
"initiative": "!!TODO!!"
},
"schild": {
@ -207,8 +207,7 @@
"modifikator": "!!TODO!!",
"attacke": "!!TODO!!",
"parade": "!!TODO!!",
"initiative": "!!TODO!!",
"bruchfaktor": "!!TODO!!"
"initiative": "!!TODO!!"
},
"fernkampfwaffe": {

View File

@ -20,6 +20,8 @@
.center {
text-align: center;
justify-content: center;
align-content: center;
}
@ -80,6 +82,35 @@
height: 80px;
}
.list-header {
padding: 0.5rem;
}
.list {
box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
}
.list-item {
padding: 0.25rem;
border-bottom: 1px dotted;
}
.list-item:last-child {
border: none;
}
.item-name {
gap: 0.5rem;
}
.item-sub {
font-size: 0.625rem;
}
.inventar {
gap: 16px;
}
.actor-sheet fieldset {
width: 100%;
@ -91,6 +122,12 @@
table-layout: fixed;
}
.actor-sheet .item-image {
width: 32px;
height: 32px;
}
.actor-sheet .tabs,
.item-sheet .tabs {
padding: 6px;
margin-top: 6px;
@ -98,10 +135,12 @@
border-bottom: 1px solid;
}
.actor-sheet .tabs a,
.item-sheet .tabs a {
line-height: 18px;
}
.actor-sheet .tabs a.active,
.item-sheet .tabs a.active {
text-decoration: underline;
}

View File

@ -1,7 +1,11 @@
Hooks.once("init", function() {
console.log("INIT");
CONFIG.Combat.initiative.formula = "1d6 + @computed.ini_basiswert[INI-Basiswert]";
CONFIG.Actor.dataModels.Player = DSA41_CharacterData;
CONFIG.Actor.documentClass = DSA41_CharacterDocument;
CONFIG.Item. dataModels.Gegenstand = DSA41_GegenstandData;
CONFIG.Item. dataModels.Ruestung = DSA41_RuestungData;
CONFIG.Item. dataModels.Bewaffnung = DSA41_BewaffnungData;
@ -30,9 +34,9 @@ const { SchemaField, NumberField, StringField, BooleanField } = foundry.data.fie
class AttributeField extends foundry.data.fields.SchemaField {
constructor() {
return super({
initial: new NumberField({ integer: true, initial: 8, min: 8, max: 14, }),
advancement: new NumberField({ integer: true, initial: 0, min: 0, max: 4, }),
modifier: new NumberField({ integer: true, initial: 0, min: 0, }),
initial: new NumberField({ integer: true, initial: 8, min: 0 }),
advancement: new NumberField({ integer: true, initial: 0, min: 0 }),
modifier: new NumberField({ integer: true, initial: 0 }),
});
}
}
@ -47,6 +51,10 @@ class CombatTalentField extends foundry.data.fields.SchemaField {
}
}
class DSA41_CharacterDocument extends Actor {
}
class DSA41_CharacterData extends foundry.abstract.TypeDataModel {
static defineSchema() {
return {
@ -227,11 +235,29 @@ class DSA41_CharacterData extends foundry.abstract.TypeDataModel {
prepareDerivedData() {
super.prepareDerivedData();
this.computed = {};
this.computed = {
attributes: {
without_modifiers: {},
with_modifiers: {},
},
};
for (const [attribute, values] of Object.entries(this.attributes)) {
this.computed[attribute] = Object.values(values).reduce((a, b) => a + b, 0);
this.computed.attributes.without_modifiers[attribute] = values.initial + values.advancement;
this.computed.attributes.with_modifiers [attribute] = values.initial + values.advancement + values.modifier;
}
this.computed.max_lebenspunkte = Math.round((this.computed.attributes.without_modifiers.constitution + this.computed.attributes.without_modifiers.constitution + this.computed.attributes.without_modifiers.strength) / 2);
this.computed.max_ausdauer = Math.round((this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.constitution + this.computed.attributes.without_modifiers.agility) / 2);
this.computed.max_atralenergie = Math.round((this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.charisma) / 2);
this.computed.magieresistenz = Math.round((this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.cleverness + this.computed.attributes.without_modifiers.constitution) / 5);
this.computed.ini_basiswert = Math.round((this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.agility) / 5);
this.computed.at_basiswert = Math.round((this.computed.attributes.without_modifiers.courage + this.computed.attributes.without_modifiers.agility + this.computed.attributes.without_modifiers.strength) / 5);;
this.computed.pa_basiswert = Math.round((this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.agility + this.computed.attributes.without_modifiers.strength) / 5);;
this.computed.fk_basiswert = Math.round((this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.dexterity + this.computed.attributes.without_modifiers.strength) / 5);;
}
}
@ -271,6 +297,8 @@ class DSA41_BewaffnungData extends foundry.abstract.TypeDataModel {
gewicht: new NumberField({ integer: false, initial: 0, min: 0 }),
preis: new NumberField({ integer: true, initial: 0, min: 0 }),
angelegt: new BooleanField(),
nahkampfwaffe: new SchemaField({
aktiv: new BooleanField(),
@ -343,6 +371,12 @@ class DSA41_BewaffnungData extends foundry.abstract.TypeDataModel {
}
class DSA41_ActorSheet extends ActorSheet {
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
tabs: [{ navSelector: ".tabs", contentSelector: ".content", initial: "tab1" }],
});
}
get template() {
return "systems/dsa-4th-edition/src/ActorSheet.html";
}