add AttributeChoiceField and use it for Talent

This commit is contained in:
Sven Balzer 2025-05-04 11:04:01 +02:00
parent bc8c7f6a2b
commit a6dc61a924
2 changed files with 25 additions and 35 deletions

View File

@ -17,38 +17,9 @@
{{>editable-input type="text" name="system.behinderung" value=item.system.behinderung placeholder=(localize "DSA41.talente.label_behinderung")}} {{>editable-input type="text" name="system.behinderung" value=item.system.behinderung placeholder=(localize "DSA41.talente.label_behinderung")}}
</div> </div>
<div class="grid3 gap"> <div class="grid3 gap">
<select name="system.attribute1"> {{DSA41_input "system.attribute1"}}
<option value="courage" {{#if (eq item.system.attribute1 "courage") }}selected{{/if}}>{{localize "DSA41.attributes.long.courage"}} </option> {{DSA41_input "system.attribute2"}}
<option value="cleverness" {{#if (eq item.system.attribute1 "cleverness") }}selected{{/if}}>{{localize "DSA41.attributes.long.cleverness"}} </option> {{DSA41_input "system.attribute3"}}
<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>
</div> </div>
</div> </div>
</div> </div>

View File

@ -271,6 +271,25 @@ class AttributeField extends SchemaField {
} }
} }
class AttributeChoiceField extends StringField {
constructor() {
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",
});
}
}
class DSA41_CharacterDocument extends Actor { class DSA41_CharacterDocument extends Actor {
static async create(data, operation) { static async create(data, operation) {
const actor = await super.create(data, operation); const actor = await super.create(data, operation);
@ -737,9 +756,9 @@ class DSA41_TalentData extends TypeDataModel {
kategorie: new StringField({ initial: "koerperliche" }), kategorie: new StringField({ initial: "koerperliche" }),
behinderung: new StringField({ initial: "" }), behinderung: new StringField({ initial: "" }),
attribute1: new StringField({ initial: "courage" }), attribute1: new AttributeChoiceField(),
attribute2: new StringField({ initial: "courage" }), attribute2: new AttributeChoiceField(),
attribute3: new StringField({ initial: "courage" }), attribute3: new AttributeChoiceField(),
talentwert: new NumberField({ integer: true, initial: 0 }), talentwert: new NumberField({ integer: true, initial: 0 }),
}; };