fixe hexa radios

This commit is contained in:
rwanoux
2024-05-15 10:36:45 +02:00
parent a970e9335c
commit 5c3301b88e
3 changed files with 37 additions and 15 deletions
+26 -9
View File
@@ -40,6 +40,8 @@ export class VermineActorSheet extends ActorSheet {
// Add the actor's data to context.data for easier access, as well as flags. // Add the actor's data to context.data for easier access, as well as flags.
context.system = actorData.system; context.system = actorData.system;
context.flags = actorData.flags; context.flags = actorData.flags;
//add system config for convenience use
context.config = CONFIG.VERMINE; context.config = CONFIG.VERMINE;
// Add roll data for TinyMCE editors. // Add roll data for TinyMCE editors.
@@ -48,6 +50,7 @@ export class VermineActorSheet extends ActorSheet {
// Prepare active effects // Prepare active effects
context.effects = prepareActiveEffectCategories(this.actor.effects); context.effects = prepareActiveEffectCategories(this.actor.effects);
return context; return context;
} }
@@ -92,22 +95,33 @@ export class VermineActorSheet extends ActorSheet {
} }
//click on wound radio //click on wound radio
html.find('.hexa [type="radio"]').change(ev => { html.find('.hexa [type="radio"]').click(ev => {
ev.preventDefault() ev.preventDefault();
console.log(ev.target.checked, "CHECK______________________") ev.stopPropagation();
return this._onClickRadioHexa(ev) return this._onClickRadioHexa(ev)
}) })
} }
_onClickRadioHexa(ev) { _onClickRadioHexa(ev) {
console.log("________________iiiiiii") let input = ev.currentTarget;
if (!ev.currentTarget.checked) { return false }; console.log(input.value, input.name);
ev.preventDefault();
let prop = ev.currentTarget.name;
let update = {}; let update = {};
update[prop] = ev.currentTarget.value - 1 update[input.name] = 0
let propTree = input.name.split('.')
let current = this.actor;
for (let prop of propTree) {
current = current[prop]
}
if (current != input.value) {
update[input.name] = parseInt(input.value)
} else {
update[input.name] = parseInt(input.value) - 1;
}
this.actor.update(update)
return this.actor.update(update)
} }
async _onMinMaxEdit(event) { async _onMinMaxEdit(event) {
@@ -162,4 +176,7 @@ export class VermineActorSheet extends ActorSheet {
// Finally, create the item! // Finally, create the item!
return await Item.create(itemData, { parent: this.actor }); return await Item.create(itemData, { parent: this.actor });
} }
async getGroup() {
return await game.actors.find(group => { group == group - 1 })
}
} }
+5
View File
@@ -56,6 +56,11 @@ export class VermineCharacterSheet extends VermineActorSheet {
// Add roll data for TinyMCE editors. // Add roll data for TinyMCE editors.
context.rollData = context.actor.getRollData(); context.rollData = context.actor.getRollData();
//get the group actor
context.group = this.getGroup()
// Prepare active effects // Prepare active effects
context.effects = prepareActiveEffectCategories(this.actor.effects); context.effects = prepareActiveEffectCategories(this.actor.effects);
@@ -103,9 +103,9 @@
checked checked
{{/iflteq}} {{/iflteq}}
" "
{{#iflteq @minorwoundmax @root.system.minorWound.value }} {{#ife @minorwoundmax @root.system.minorWound.value }}
checked="true" checked="true"
{{/iflteq}} /> {{/ife}} />
</div> </div>
{{/repeat}} {{/repeat}}
</div> </div>
@@ -127,9 +127,9 @@
{{/iflteq}} {{/iflteq}}
" "
{{#iflteq @minorwoundmax @root.system.majorWound.value }} {{#ife @majourwoundmax @root.system.majorWound.value }}
checked="true" checked="true"
{{/iflteq}} /> {{/ife}} />
</div> </div>
{{/repeat}} {{/repeat}}
@@ -153,9 +153,9 @@
{{/iflteq}} {{/iflteq}}
" "
{{#iflteq @minorwoundmax @root.system.deadlyWound.value }} {{#ife @deadlywoundmax @root.system.deadlyWound.value }}
checked="true" checked="true"
{{/iflteq}} /> {{/ife}} />
</div> </div>
{{/repeat}} {{/repeat}}