first commit after clone

This commit is contained in:
rwanoux
2024-04-17 11:51:59 +02:00
parent f483a219c1
commit 0fe0d530b1
3 changed files with 173 additions and 161 deletions
+26 -25
View File
@@ -1,4 +1,4 @@
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs"; import { onManageActiveEffect, prepareActiveEffectCategories } from "../system/effects.mjs";
import { VermineActorSheet } from "./actor-sheet.mjs"; import { VermineActorSheet } from "./actor-sheet.mjs";
import { getRollBox } from "../system/dialogs.mjs"; import { getRollBox } from "../system/dialogs.mjs";
import { TotemPicker } from "../system/applications.mjs"; import { TotemPicker } from "../system/applications.mjs";
@@ -42,7 +42,7 @@ export class VermineCharacterSheet extends VermineActorSheet {
context.system = actorData.system; context.system = actorData.system;
context.flags = actorData.flags; context.flags = actorData.flags;
context.config = CONFIG.VERMINE; context.config = CONFIG.VERMINE;
// Prepare character data and items. // Prepare character data and items.
if (actorData.type == 'character') { if (actorData.type == 'character') {
this._prepareItems(context); this._prepareItems(context);
@@ -102,8 +102,9 @@ export class VermineCharacterSheet extends VermineActorSheet {
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
// Choose Totem // Choose Totem
html.find('.chooseTotem').click(this._onTotemButton.bind(this)); html.find('.chooseTotem').click(this._onTotemButton.bind(this));
html.find('.ability .rollable').click(this._onRoll.bind(this));
} }
@@ -130,27 +131,27 @@ export class VermineCharacterSheet extends VermineActorSheet {
// Handle rolls that supply the formula directly. // Handle rolls that supply the formula directly.
if (dataset.label) { if (dataset.label) {
dataset.rollType = dataset.type; dataset.rollType = dataset.type;
/*const label = game.i18n.localize(dataset.label) ? `[ability] ${game.i18n.localize(dataset.label)}` : ''; /*const label = game.i18n.localize(dataset.label) ? `[ability] ${game.i18n.localize(dataset.label)}` : '';
console.log($(element).attr('for')); console.log($(element).attr('for'));
const NoD = this.actor.system.skills[$(element).attr('for').split('.')[2]]?.value || 0 const NoD = this.actor.system.skills[$(element).attr('for').split('.')[2]]?.value || 0
return game.vermine2047.VermineRoll.roll(this.actor.id, label, NoD, 0, {});*/ return game.vermine2047.VermineRoll.roll(this.actor.id, label, NoD, 0, {});*/
let data = { let data = {
actorId: this.actor.id, actorId: this.actor.id,
abilities: this.actor.system.abilities, abilities: this.actor.system.abilities,
skills: this.actor.system.skills, skills: this.actor.system.skills,
rollType: dataset.rollType, rollType: dataset.rollType,
labelKey: dataset.label, labelKey: dataset.label,
abilityScore: 0, abilityScore: 0,
skillScore: 0, skillScore: 0,
label: game.i18n.localize(dataset.label) label: game.i18n.localize(dataset.label)
}; };
if (dataset.type == 'ability'){ if (dataset.type == 'ability') {
data.abilityScore = this.actor.system.abilities[dataset.label].value; data.abilityScore = this.actor.system.abilities[dataset.label].value;
} else if (dataset.type == 'skill'){ } else if (dataset.type == 'skill') {
data.skillScore = this.actor.system.skills[dataset.label].value; data.skillScore = this.actor.system.skills[dataset.label].value;
} }
getRollBox(data); getRollBox(data);
return true; return true;
} }
} }
@@ -163,7 +164,7 @@ export class VermineCharacterSheet extends VermineActorSheet {
event.preventDefault(); event.preventDefault();
const el = event.currentTarget; const el = event.currentTarget;
// const dataset = el.dataset; // const dataset = el.dataset;
const totemPicker = new TotemPicker(el, this.actor); const totemPicker = new TotemPicker(el, this.actor);
totemPicker.render(true); totemPicker.render(true);
} }
+121 -121
View File
@@ -1,129 +1,129 @@
export class CombatResultDialog extends Dialog { export class CombatResultDialog extends Dialog {
constructor(dialogData, options) { constructor(dialogData, options) {
/*let options = { classes: ["combat", "result"], ...options }; /*let options = { classes: ["combat", "result"], ...options };
let conf = { let conf = {
title: "Résultat de la confrontation", title: "Résultat de la confrontation",
content: dialogData.content content: dialogData.content
}; };
super(conf, options); super(conf, options);
this.dialogData = dialogData;*/ this.dialogData = dialogData;*/
}
/* -------------------------------------------- */
activateListeners(html) {
/*super.activateListeners(html);
this.html = html;
this.setEphemere(this.dialogData.signe.system.ephemere);
html.find(".signe-aleatoire").click(event => this.setSigneAleatoire());
html.find("[name='signe.system.ephemere']").change((event) => this.setEphemere(event.currentTarget.checked));
html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event));
html.find("input.select-actor").change((event) => this.onSelectActor(event));
html.find("input.select-tmr").change((event) => this.onSelectTmr(event));*/
}
async onSelectActor(event) {
/*const actorId = this.html.find(event.currentTarget)?.data("actor-id");
const actor = this.dialogData.actors.find(it => it.id == actorId);
if (actor) {
actor.selected = event.currentTarget.checked;
}*/
}
} }
export const getRollBox = async function(data) { /* -------------------------------------------- */
let html = await renderTemplate('systems/vermine2047/templates/roll.hbs', data); activateListeners(html) {
let ui = new Dialog({ /*super.activateListeners(html);
title: game.i18n.localize("ROLLS.tool"), this.html = html;
content: html, this.setEphemere(this.dialogData.signe.system.ephemere);
buttons: { html.find(".signe-aleatoire").click(event => this.setSigneAleatoire());
roll: { html.find("[name='signe.system.ephemere']").change((event) => this.setEphemere(event.currentTarget.checked));
label: game.i18n.localize('ROLLS.roll_dice'), html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event));
callback: (html) => { html.find("input.select-actor").change((event) => this.onSelectActor(event));
let form = html.find('#dice-pool-form'); html.find("input.select-tmr").change((event) => this.onSelectTmr(event));*/
if (!form[0].checkValidity()) { }
throw "Invalid Data";
}
let formData = {};
form.serializeArray().map(item => {
formData[item.name] = item.value;
});
// console.log("roll form data", formData);
let NoD = parseInt(formData.abilityScore,10);
let Reroll = 0;
// difficulty
data.difficulty = (formData.difficulty != undefined) ? formData.difficulty : 7;
// maîtrise bonus
if (formData.rollType == 'skill'){
NoD += CONFIG.VERMINE.SkillLevels[formData.skillScore].dicePool || 0;
Reroll += CONFIG.VERMINE.SkillLevels[formData.skillScore].reroll || 0;
}
console.log('reroll', Reroll);
// réserves
if (formData.self_control > 0){ async onSelectActor(event) {
NoD += parseInt(formData.self_control,10); /*const actorId = this.html.find(event.currentTarget)?.data("actor-id");
} const actor = this.dialogData.actors.find(it => it.id == actorId);
if (formData.group > 0){ if (actor) {
NoD += parseInt(formData.group,10); actor.selected = event.currentTarget.checked;
} }*/
// checks }
if (formData.usingSpecialization !== undefined && formData.usingSpecialization == 1){
NoD += 1;
} }
if (formData.usingTools !== undefined && formData.usingTools == 1){
NoD += 1; export const getRollBox = async function (data) {
} let html = await renderTemplate('systems/vermine2047/templates/roll.hbs', data);
if (formData.helped !== undefined && formData.helped == 1){ let dial = new Dialog({
NoD += 1; title: game.i18n.localize("ROLLS.tool"),
} content: html,
if (formData.abilityScore == 0){ buttons: {
ui.notifications.notify(`veuillez saisir une caractéristique`); roll: {
} else return game.vermine2047.VermineRoll.roll(data.actorId, data.label, NoD, Reroll, data); label: game.i18n.localize('ROLLS.roll_dice'),
callback: (html) => {
let form = html.find('#dice-pool-form');
if (!form[0].checkValidity()) {
throw "Invalid Data";
} }
}, let formData = {};
close: { form.serializeArray().map(item => {
label: game.i18n.localize('Close'), formData[item.name] = item.value;
callback: () => { } });
// console.log("roll form data", formData);
let NoD = parseInt(formData.abilityScore, 10);
let Reroll = 0;
// difficulty
data.difficulty = (formData.difficulty != undefined) ? formData.difficulty : 7;
// maîtrise bonus
if (formData.rollType == 'skill') {
NoD += CONFIG.VERMINE.SkillLevels[formData.skillScore].dicePool || 0;
Reroll += CONFIG.VERMINE.SkillLevels[formData.skillScore].reroll || 0;
}
console.log('reroll', Reroll);
// réserves
if (formData.self_control > 0) {
NoD += parseInt(formData.self_control, 10);
}
if (formData.group > 0) {
NoD += parseInt(formData.group, 10);
}
// checks
if (formData.usingSpecialization !== undefined && formData.usingSpecialization == 1) {
NoD += 1;
}
if (formData.usingTools !== undefined && formData.usingTools == 1) {
NoD += 1;
}
if (formData.helped !== undefined && formData.helped == 1) {
NoD += 1;
}
if (formData.abilityScore == 0 || !formData.abilityScore) {
ui.notifications.notify(`veuillez saisir une caractéristique`);
} else return game.vermine2047.VermineRoll.roll(data.actorId, data.label, NoD, Reroll, data);
} }
}, },
render: function (h) { close: {
if( h.find('input[name="abilityScore"]').val()== 0 && data.rollType == 'ability'){ label: game.i18n.localize('Close'),
h.find('input[name="abilityScore"]').val(data.abilities[data.label].value); callback: () => { }
}
h.find('select[name="ability"]').change((event) => {
if (event.target.value != undefined){
const abilityScore = data.abilities[event.target.value].value;
console.log('ability', abilityScore);
// on enregistre la valeur de la caractéristique
h.find('input[name="abilityScore"]').val(abilityScore);
}
});
h.find('select[name="skill"]').change((event) => {
if (data.rollType == 'skill' && event.target.value != undefined){
const skillScore = data.skills[event.target.value].value;
// on enregistre la valeur de la compétence
h.find('input[name="skillScore"]').val(skillScore);
// on met à jour les infos de niveaux de compétence
const skillLevel = CONFIG.VERMINE.SkillLevels[skillScore];
if (skillLevel != undefined){
h.find('#skillLevel').text(game.i18n.localize(skillLevel.label));
h.find('#skillDicePool').text(skillLevel.dicePool);
h.find('#skillReroll').text(skillLevel.reroll);
} else {
h.find('#skillLevel').text('Inconnu');
h.find('#skillDicePool').text(0);
h.find('#skillReroll').text(0);
}
}
});
} }
}); },
ui.render(true); render: function (h) {
} if (h.find('input[name="abilityScore"]').val() == 0 && data.rollType == 'ability') {
h.find('input[name="abilityScore"]').val(data.abilities[data.label].value);
}
h.find('select[name="ability"]').change((event) => {
if (event.target.value != undefined) {
const abilityScore = data.abilities[event.target.value].value;
console.log('ability', abilityScore);
// on enregistre la valeur de la caractéristique
h.find('input[name="abilityScore"]').val(abilityScore);
}
});
h.find('select[name="skill"]').change((event) => {
if (data.rollType == 'skill' && event.target.value != undefined) {
const skillScore = data.skills[event.target.value].value;
// on enregistre la valeur de la compétence
h.find('input[name="skillScore"]').val(skillScore);
// on met à jour les infos de niveaux de compétence
const skillLevel = CONFIG.VERMINE.SkillLevels[skillScore];
if (skillLevel != undefined) {
h.find('#skillLevel').text(game.i18n.localize(skillLevel.label));
h.find('#skillDicePool').text(skillLevel.dicePool);
h.find('#skillReroll').text(skillLevel.reroll);
} else {
h.find('#skillLevel').text('Inconnu');
h.find('#skillDicePool').text(0);
h.find('#skillReroll').text(0);
}
}
});
}
});
dial.render(true);
}
+26 -15
View File
@@ -1,21 +1,32 @@
<div class="totem choose grid grid-2col" style="padding:5px;"> <div class="totem choose grid grid-2col" style="padding:5px;">
{{#each config.totems as | totem tk|}} {{#each config.totems as | totem tk|}}
{{#if (ne tk "human")}} {{#if (ne tk "human")}}
{{#if (ne tk "adapted")}} {{#if (ne tk "adapted")}}
<div class="flexrow row mdb flex-group-center">
<h4 style="flex:33%;"> <div class="flexrow row mdb flex-group-center">
<a class="totem" data-totem="{{ tk }}" title="{{ smarttlk "TOTEMS" tk "description"}}"> <h4 style="flex:33%;">
<img src="/systems/vermine2047/assets/images/ui/totems/{{ tk }}.webp" alt="{{ localize totem }}" width="80" height="80" /> <a class="totem" data-totem="{{ tk }}"
</a> title="{{ smarttlk "TOTEMS"
</h4> tk "description"}}">
<p style="flex:66%;text-align:left;"> <img
<strong>Instincts</strong> : {{ smarttlk "TOTEMS" tk "instincts"}}<br> src="/systems/vermine2047/assets/images/ui/totems/{{ tk }}.webp"
<strong>Interdits</strong> : {{ smarttlk "TOTEMS" tk "bans"}}<br> alt="{{ localize totem }}" width="80" height="80" />
<strong>Comportements</strong> : {{ smarttlk "TOTEMS" tk "behaviour"}}<br> <h2>{{ smarttlk "TOTEMS"
<strong>Totem opposé</strong> : {{ smartcfg "totem_opposites" tk }}<br> tk "name"}}</h2>
</p> </a>
</div> </h4>
{{/if}} <p style="flex:66%;text-align:left;">
<strong>Instincts</strong> : {{ smarttlk "TOTEMS" tk
"instincts"}}<br>
<strong>Interdits</strong> : {{ smarttlk "TOTEMS" tk
"bans"}}<br>
<strong>Comportements</strong> : {{ smarttlk "TOTEMS" tk
"behaviour"}}<br>
<strong>Totem opposé</strong> : {{ smartcfg "totem_opposites" tk
}}<br>
</p>
</div>
{{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
</div> </div>