Compare commits

...

10 Commits

7 changed files with 131 additions and 93 deletions

View File

@ -81,11 +81,7 @@
<div class="tab {{#if (eq tabGroups.primary 'tab3')}}active{{/if}}" data-group="primary" data-tab="tab3">
<span>{{localize "DSA41.bewaffnung.schild.groesse.label"}}</span>
<select name="system.schild.groesse">
<option value="klein" {{#if (eq item.system.schild.groesse "klein")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.klein"}}</option>
<option value="gross" {{#if (eq item.system.schild.groesse "gross")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.gross"}}</option>
<option value="sehr_gross" {{#if (eq item.system.schild.groesse "sehr_gross")}} selected {{/if}}>{{localize "DSA41.bewaffnung.schild.groesse.sehr_gross"}}</option>
</select>
{{DSA41_input "system.schild.groesse"}}
<span>{{localize "DSA41.bewaffnung.schild.modifikator"}}</span>
<div class="grid2">
{{>editable-input type="number" name="system.schild.modifikator_attacke" value=item.system.schild.modifikator_attacke placeholder=(localize "DSA41.bewaffnung.schild.attacke")}}

View File

@ -5,28 +5,14 @@
<div class="grid3 gap">
{{>editable-input type="text" name="name" value=item.name placeholder=(localize "DSA41.name")}}
<div>
<select name="system.steigern">
<option value="A_Star" {{#if (eq item.system.steigern "A_Star")}}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.A_Star"}}</option>
<option value="A" {{#if (eq item.system.steigern "A") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.A"}} </option>
<option value="B" {{#if (eq item.system.steigern "B") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.B"}} </option>
<option value="C" {{#if (eq item.system.steigern "C") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.C"}} </option>
<option value="D" {{#if (eq item.system.steigern "D") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.D"}} </option>
<option value="E" {{#if (eq item.system.steigern "E") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.E"}} </option>
<option value="F" {{#if (eq item.system.steigern "F") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.F"}} </option>
<option value="G" {{#if (eq item.system.steigern "G") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.G"}} </option>
<option value="H" {{#if (eq item.system.steigern "H") }}selected{{/if}}>{{localize "DSA41.kampftalent.steigern.H"}} </option>
</select>
{{DSA41_input "system.steigern"}}
<div class="placeholder">{{localize "DSA41.kampftalent.label_steigern"}}</div>
</div>
{{>editable-input type="text" name="system.behinderung" value=item.system.behinderung placeholder=(localize "DSA41.talente.label_behinderung")}}
</div>
<div class="grid gap">
<div>
<select name="system.kategorie">
<option value="waffenlos" {{#if (eq item.system.kategorie "waffenlos")}}selected{{/if}}>{{localize "DSA41.kampftalent.kategorie.waffenlos"}}</option>
<option value="nahkampf" {{#if (eq item.system.kategorie "nahkampf") }}selected{{/if}}>{{localize "DSA41.kampftalent.kategorie.nahkampf"}} </option>
<option value="fernkampf" {{#if (eq item.system.kategorie "fernkampf")}}selected{{/if}}>{{localize "DSA41.kampftalent.kategorie.fernkampf"}}</option>
</select>
{{DSA41_input "system.kategorie"}}
<div class="placeholder">{{localize "DSA41.talente.label_kategorie"}}</div>
</div>
</div>

View File

@ -5,12 +5,7 @@
<div class="grid2 gap">
{{>editable-input type="text" name="name" value=item.name placeholder=(localize "DSA41.name")}}
<div>
<select name="system.kategorie">
<option value="allgemein" {{#if (eq item.system.kategorie "allgemein")}}selected{{/if}}>{{localize "DSA41.sonderfertigkeiten.kategorie.allgemein"}}</option>
<option value="kampf" {{#if (eq item.system.kategorie "kampf") }}selected{{/if}}>{{localize "DSA41.sonderfertigkeiten.kategorie.kampf"}} </option>
<option value="magisch" {{#if (eq item.system.kategorie "magisch") }}selected{{/if}}>{{localize "DSA41.sonderfertigkeiten.kategorie.magisch"}} </option>
<option value="klerikal" {{#if (eq item.system.kategorie "klerikal") }}selected{{/if}}>{{localize "DSA41.sonderfertigkeiten.kategorie.klerikal"}} </option>
</select>
{{DSA41_input "system.kategorie"}}
<div class="placeholder">{{localize "DSA41.sonderfertigkeiten.kategorie.label"}}</div>
</div>
</div>

View File

@ -5,50 +5,15 @@
<div class="grid3 gap">
{{>editable-input type="text" name="name" value=item.name placeholder=(localize "DSA41.name")}}
<div>
<select name="system.kategorie">
<option value="koerperliche" {{#if (eq item.system.kategorie "koerperliche") }}selected{{/if}}>{{localize "DSA41.talente.koerperliche.label"}} </option>
<option value="gesellschaftliche" {{#if (eq item.system.kategorie "gesellschaftliche")}}selected{{/if}}>{{localize "DSA41.talente.gesellschaftliche.label"}}</option>
<option value="natur" {{#if (eq item.system.kategorie "natur") }}selected{{/if}}>{{localize "DSA41.talente.natur.label"}} </option>
<option value="wissens" {{#if (eq item.system.kategorie "wissens") }}selected{{/if}}>{{localize "DSA41.talente.wissens.label"}} </option>
<option value="handwerks" {{#if (eq item.system.kategorie "handwerks") }}selected{{/if}}>{{localize "DSA41.talente.handwerks.label"}} </option>
</select>
{{DSA41_input "system.kategorie"}}
<div class="placeholder">{{localize "DSA41.talente.label_kategorie"}}</div>
</div>
{{>editable-input type="text" name="system.behinderung" value=item.system.behinderung placeholder=(localize "DSA41.talente.label_behinderung")}}
</div>
<div class="grid3 gap">
<select name="system.attribute1">
<option value="courage" {{#if (eq item.system.attribute1 "courage") }}selected{{/if}}>{{localize "DSA41.attributes.long.courage"}} </option>
<option value="cleverness" {{#if (eq item.system.attribute1 "cleverness") }}selected{{/if}}>{{localize "DSA41.attributes.long.cleverness"}} </option>
<option value="intuition" {{#if (eq item.system.attribute1 "intuition") }}selected{{/if}}>{{localize "DSA41.attributes.long.intuition"}} </option>
<option value="charisma" {{#if (eq item.system.attribute1 "charisma") }}selected{{/if}}>{{localize "DSA41.attributes.long.charisma"}} </option>
<option value="dexterity" {{#if (eq item.system.attribute1 "dexterity") }}selected{{/if}}>{{localize "DSA41.attributes.long.dexterity"}} </option>
<option value="agility" {{#if (eq item.system.attribute1 "agility") }}selected{{/if}}>{{localize "DSA41.attributes.long.agility"}} </option>
<option value="constitution" {{#if (eq item.system.attribute1 "constitution")}}selected{{/if}}>{{localize "DSA41.attributes.long.constitution"}}</option>
<option value="strength" {{#if (eq item.system.attribute1 "strength") }}selected{{/if}}>{{localize "DSA41.attributes.long.strength"}} </option>
</select>
<select name="system.attribute2">
<option value="courage" {{#if (eq item.system.attribute2 "courage") }}selected{{/if}}>{{localize "DSA41.attributes.long.courage"}} </option>
<option value="cleverness" {{#if (eq item.system.attribute2 "cleverness") }}selected{{/if}}>{{localize "DSA41.attributes.long.cleverness"}} </option>
<option value="intuition" {{#if (eq item.system.attribute2 "intuition") }}selected{{/if}}>{{localize "DSA41.attributes.long.intuition"}} </option>
<option value="charisma" {{#if (eq item.system.attribute2 "charisma") }}selected{{/if}}>{{localize "DSA41.attributes.long.charisma"}} </option>
<option value="dexterity" {{#if (eq item.system.attribute2 "dexterity") }}selected{{/if}}>{{localize "DSA41.attributes.long.dexterity"}} </option>
<option value="agility" {{#if (eq item.system.attribute2 "agility") }}selected{{/if}}>{{localize "DSA41.attributes.long.agility"}} </option>
<option value="constitution" {{#if (eq item.system.attribute2 "constitution")}}selected{{/if}}>{{localize "DSA41.attributes.long.constitution"}}</option>
<option value="strength" {{#if (eq item.system.attribute2 "strength") }}selected{{/if}}>{{localize "DSA41.attributes.long.strength"}} </option>
</select>
<select name="system.attribute3">
<option value="courage" {{#if (eq item.system.attribute3 "courage") }}selected{{/if}}>{{localize "DSA41.attributes.long.courage"}} </option>
<option value="cleverness" {{#if (eq item.system.attribute3 "cleverness") }}selected{{/if}}>{{localize "DSA41.attributes.long.cleverness"}} </option>
<option value="intuition" {{#if (eq item.system.attribute3 "intuition") }}selected{{/if}}>{{localize "DSA41.attributes.long.intuition"}} </option>
<option value="charisma" {{#if (eq item.system.attribute3 "charisma") }}selected{{/if}}>{{localize "DSA41.attributes.long.charisma"}} </option>
<option value="dexterity" {{#if (eq item.system.attribute3 "dexterity") }}selected{{/if}}>{{localize "DSA41.attributes.long.dexterity"}} </option>
<option value="agility" {{#if (eq item.system.attribute3 "agility") }}selected{{/if}}>{{localize "DSA41.attributes.long.agility"}} </option>
<option value="constitution" {{#if (eq item.system.attribute3 "constitution")}}selected{{/if}}>{{localize "DSA41.attributes.long.constitution"}}</option>
<option value="strength" {{#if (eq item.system.attribute3 "strength") }}selected{{/if}}>{{localize "DSA41.attributes.long.strength"}} </option>
</select>
{{DSA41_input "system.attribute1"}}
{{DSA41_input "system.attribute2"}}
{{DSA41_input "system.attribute3"}}
</div>
</div>
</div>

View File

@ -7,10 +7,7 @@
{{>editable-input type="number" name="system.kosten" value=item.system.kosten placeholder=(localize "DSA41.vornachteil.kosten")}}
</div>
<div>
<select name="system.kategorie">
<option value="vorteil" {{#if (eq item.system.kategorie "vorteil") }}selected{{/if}}>{{localize "DSA41.vornachteil.kategorie.vorteil"}} </option>
<option value="nachteil" {{#if (eq item.system.kategorie "nachteil")}}selected{{/if}}>{{localize "DSA41.vornachteil.kategorie.nachteil"}} </option>
</select>
{{DSA41_input "system.kategorie"}}
<div class="placeholder">{{localize "DSA41.vornachteil.kategorie.label"}}</div>
</div>
</div>

View File

@ -34,6 +34,18 @@
"kreuzer": "Kreuzer"
},
"steigerungskategorie": {
"A_Star": "A*",
"A": "A",
"B": "B",
"C": "C",
"D": "D",
"E": "E",
"F": "F",
"G": "G",
"H": "H"
},
"chat": {
"result": "Ergebnis",
"success": "Geschafft",
@ -165,18 +177,6 @@
"waffenlos": "Waffenlos",
"nahkampf": "Bewaffneter Nahkampf",
"fernkampf": "Fernkampf"
},
"steigern": {
"A_Star": "A*",
"A": "A",
"B": "B",
"C": "C",
"D": "D",
"E": "E",
"F": "F",
"G": "G",
"H": "H"
}
},

View File

@ -16,7 +16,7 @@ Hooks.once("i18nInit", async function() {
const fallback = game.i18n.translations;
await game.i18n.setLanguage(lang);
game.i18n._fallback = foundry.utils.mergeObject(fallback, game.i18n.fallback);
game.i18n._fallback = foundry.utils.mergeObject(fallback, game.i18n._fallback);
});
class DSA41_Notifications extends Notifications {
@ -97,6 +97,22 @@ Hooks.once("init", async function() {
return array.toSorted((a, b) => a.sort - b.sort);
}
});
Handlebars.registerHelper({
DSA41_input: (field_name, options) => {
let fields = field_name.startsWith("system.") ? options.data.root.document.system.schema.fields : options.data.root.document.schema.fields;
let field = foundry.utils.getProperty(fields, field_name.replace(/^(system\.)/, "").replace(".", ".fields."));
if (!field) {
console.error("Non-existent data field provided to {{DSA4_input}} handlebars helper.");
return Handlebars.SafeString("");
}
const value = foundry.utils.getProperty(options.data.root.document, field_name);
const input = field.toInput({ localize: true, value: value, ...options.hash });
return new Handlebars.SafeString(input.outerHTML);
}
});
await loadTemplates({
"editable-input": "systems/dsa-4th-edition/src/EditableInput.hbs",
@ -255,6 +271,47 @@ class AttributeField extends SchemaField {
}
}
class AttributeChoiceField extends StringField {
constructor(options={}, context={}) {
return super({
required: true,
choices: {
"courage": "DSA41.attributes.long.courage",
"cleverness": "DSA41.attributes.long.cleverness",
"intuition": "DSA41.attributes.long.intuition",
"charisma": "DSA41.attributes.long.charisma",
"dexterity": "DSA41.attributes.long.dexterity",
"agility": "DSA41.attributes.long.agility",
"constitution": "DSA41.attributes.long.constitution",
"strength": "DSA41.attributes.long.strength",
},
initial: "courage",
...options,
}, context);
}
}
class SteigerungsKategorieField extends StringField {
constructor(options={}, context={}) {
return super({
required: true,
choices: {
"A_Star": "DSA41.steigerungskategorie.A_Star",
"A": "DSA41.steigerungskategorie.A",
"B": "DSA41.steigerungskategorie.B",
"C": "DSA41.steigerungskategorie.C",
"D": "DSA41.steigerungskategorie.D",
"E": "DSA41.steigerungskategorie.E",
"F": "DSA41.steigerungskategorie.F",
"G": "DSA41.steigerungskategorie.G",
"H": "DSA41.steigerungskategorie.H",
},
initial: "A_Star",
...options,
}, context);
}
}
class DSA41_CharacterDocument extends Actor {
static async create(data, operation) {
const actor = await super.create(data, operation);
@ -681,7 +738,15 @@ class DSA41_BewaffnungData extends TypeDataModel {
schild: new SchemaField({
aktiv: new BooleanField({ initial: false }),
groesse: new StringField({ initial: "klein" }),
groesse: new StringField({
required: true,
choices: {
"klein": "DSA41.bewaffnung.schild.groesse.klein",
"gross": "DSA41.bewaffnung.schild.groesse.gross",
"sehr_gross": "DSA41.bewaffnung.schild.groesse.sehr_gross",
},
initial: "klein",
}),
modifikator_attacke: new NumberField({ integer: true, initial: 0 }),
modifikator_parade: new NumberField({ integer: true, initial: 0 }),
@ -718,12 +783,22 @@ class DSA41_BewaffnungData extends TypeDataModel {
class DSA41_TalentData extends TypeDataModel {
static defineSchema() {
return {
kategorie: new StringField({ initial: "koerperliche" }),
kategorie: new StringField({
required: true,
choices: {
"koerperliche": "DSA41.talente.koerperliche.label",
"gesellschaftliche": "DSA41.talente.gesellschaftliche.label",
"natur": "DSA41.talente.natur.label",
"wissens": "DSA41.talente.wissens.label",
"handwerks": "DSA41.talente.handwerks.label",
},
initial: "koerperliche"
}),
behinderung: new StringField({ initial: "" }),
attribute1: new StringField({ initial: "courage" }),
attribute2: new StringField({ initial: "courage" }),
attribute3: new StringField({ initial: "courage" }),
attribute1: new AttributeChoiceField(),
attribute2: new AttributeChoiceField(),
attribute3: new AttributeChoiceField(),
talentwert: new NumberField({ integer: true, initial: 0 }),
};
@ -733,9 +808,17 @@ class DSA41_TalentData extends TypeDataModel {
class DSA41_KampftalentData extends TypeDataModel {
static defineSchema() {
return {
kategorie: new StringField({ initial: "waffenlos" }),
kategorie: new StringField({
required: true,
choices: {
"waffenlos": "DSA41.kampftalent.kategorie.waffenlos",
"nahkampf": "DSA41.kampftalent.kategorie.nahkampf",
"fernkampf": "DSA41.kampftalent.kategorie.fernkampf",
},
initial: "waffenlos"
}),
behinderung: new StringField({ initial: "" }),
steigern: new StringField({ initial: "A_Star"}),
steigern: new SteigerungsKategorieField(),
beschreibung: new StringField({ initial: "" }),
@ -749,7 +832,16 @@ class DSA41_KampftalentData extends TypeDataModel {
class DSA41_SonderfertigkeitData extends TypeDataModel {
static defineSchema() {
return {
kategorie: new StringField({ initial: "allgemein" }),
kategorie: new StringField({
required: true,
choices: {
"allgemein": "DSA41.sonderfertigkeiten.kategorie.allgemein",
"kampf": "DSA41.sonderfertigkeiten.kategorie.kampf",
"magisch": "DSA41.sonderfertigkeiten.kategorie.magisch",
"klerikal": "DSA41.sonderfertigkeiten.kategorie.klerikal",
},
initial: "allgemein",
}),
kosten: new NumberField({ integer: true, initial: 0 }),
verbreitung: new NumberField({ integer: true, initial: 0 }),
@ -761,8 +853,15 @@ class DSA41_SonderfertigkeitData extends TypeDataModel {
class DSA41_VorNachteilData extends TypeDataModel {
static defineSchema() {
return {
kategorie: new StringField({ initial: "vorteil" }),
kosten: new NumberField({ integer: true, initial: 0 }),
kategorie: new StringField({
required: true,
choices: {
"vorteil": "DSA41.vornachteil.kategorie.vorteil",
"nachteil": "DSA41.vornachteil.kategorie.nachteil",
},
initial: "vorteil",
}),
kosten: new NumberField({ integer: true, initial: 0 }),
beschreibung: new StringField({ initial: "" }),
};