fix: Dice So Nice import v14 compat, override Foundry text colors for readability
Release Creation / build (release) Failing after 1m28s

- hooks.mjs: replace static dice-so-nice import with dynamic import
  using game.modules.get('dice-so-nice').id (path removed in v14)
- hooks.mjs: fix permission condition (|| -> &&), jQuery -> vanilla JS
- less/base.less: override --color-text-* and --button-text-color
  for both .themed.theme-dark (AppV2) and body.theme-dark (legacy apps)
- target #settings-config buttons + labels + hints for dark grays
This commit is contained in:
2026-07-12 22:05:45 +02:00
parent dcc24b47ec
commit 90de66d668
44 changed files with 516 additions and 4305 deletions
+20 -221
View File
@@ -1,5 +1,4 @@
import { VERMINE } from "./config.mjs";
import { getActorSkillScore, updateActorSkillScore } from "./functions.mjs";
/**
* Handles combat-related dice rolls for Vermine2047.
@@ -28,7 +27,8 @@ export class VermineFight {
*/
async performTest(enemyAchievement, enemyConservation, skillKey, skill, params, actor) {
// Use d10 as per Vermine2047 official rules
const dicePool = (params.spleen != undefined || params.purpose != undefined) ? '5' : '4';
const basePool = Math.max(skill, 1)
const dicePool = (params.spleen != undefined || params.purpose != undefined) ? String(basePool + 1) : String(basePool)
const difficulty = params.difficulty || 7; // Default difficulty
const r = new Roll(dicePool + `d10`);
let diceString = '';
@@ -167,218 +167,25 @@ export class VermineFight {
// data injected to char data
static previousValues = {
dicePool: 4,
skills: VERMINE.skillsList,
cskills: VERMINE.cskills,
skills: [],
cskills: [],
cephalic: false,
achievementReroll: VERMINE.achievementReroll,
conservationReroll: VERMINE.conservationReroll
achievementReroll: 0,
conservationReroll: 0
};
static rollerTemplate = 'systems/vermine2047/templates/fight.html';
static CombatResultTemplate = 'systems/vermine2047/templates/fight-result.html';
static async chatMessageHandler(message, html, data) {
// console.log("accès au fin du fin", message._id);
// sélection du dé actif
html.on("click", '.confrontation .die.d10', event => {
const diceResult = parseInt($(event.target).html(), 10);
html.find('.confrontation .die.d10').removeClass('active');
$(event.target).addClass('active');
});
// sélection des dés d'accomplissement (achievement = successes)
html.on("click", '.confrontation .add-to-achievement', event => {
const diceResult = parseInt(html.find('.confrontation .die.d10.active').html(), 10);
html.find('.confrontation .die.d10.active').removeClass('min').addClass('max');
});
// sélection des dés de conservation
html.on("click", '.confrontation .add-to-conservation', event => {
const diceResult = parseInt(html.find('.confrontation .die.d10.active').html(), 10);
html.find('.confrontation .die.d10.active').removeClass('max').addClass('min');
});
// reset de la sélection des pools
html.on("click", '.confrontation .reset', event => {
html.find('.confrontation .die.d10')
.removeClass('max')
.removeClass('min');
});
// résolution de la confrontation
// Note: With d10 system, we count successes (dice >= difficulty) instead of summing
html.on("click", '.confrontation .resolve', async event => {
let achievementDice = 0;
let conservationDice = 0;
let achievementBasis = 0;
let conservationBasis = 0;
const difficulty = 7; // Default difficulty for legacy compatibility
// Count successes (dice >= difficulty) for achievement
html.find('.confrontation .die.d10.max').each(function (index) {
const value = parseInt($(this).html(), 10);
if (value >= difficulty) {
achievementDice++;
}
});
// Count successes (dice >= difficulty) for conservation
html.find('.confrontation .die.d10.min').each(function (index) {
const value = parseInt($(this).html(), 10);
if (value >= difficulty) {
conservationDice++;
}
});
// saisie des résultats
achievementBasis = html.find('td.achievement-result').data('achievement-basis');
html.find('td.achievement-result').data('achievement-value', achievementDice);
html.find('td.achievement-result').html(achievementBasis + achievementDice);
conservationBasis = html.find('td.conservation-result').data('conservation-basis');
html.find('td.conservation-result').data('conservation-value', conservationDice);
html.find('td.conservation-result').html(conservationBasis + conservationDice);
// calcul des marges (now based on successes, not sum)
const achievementMargin = achievementBasis + achievementDice - parseInt(html.find('td.adv-achievement-result').html(), 10);
const conservationMargin = conservationBasis + conservationDice - parseInt(html.find('td.adv-conservation-result').html(), 10);
html.find('td.achievement-margin').html(achievementMargin);
html.find('td.conservation-margin').html(conservationMargin);
});
// fin de la résolution de la confrontation
}
static async chatListeners(html) {
// supprime le masquage des résultats du dé
html.off("click", ".dice-roll");
}
/**
* main class function
* @returns
*/
static async ui(externalData = {}) {
let actor = {};
// get the actor
try {
actor = game.user.character;
} catch (e) {
throw ("Aucun personnage défini !");
}
if (actor == null && externalData.speakerId != undefined && externalData.speakerId != null) {
// on récupère le speakerId, et de là l'objet actor
actor = game.actors.get(externalData.speakerId);
VermineFight.previousValues['speakerName'] = actor.name;
VermineFight.previousValues['speakerImg'] = actor.img;
} else {
VermineFight.previousValues['speakerName'] = "Anonyme";
}
// get the data
let charData = (externalData) => {
let o = Object.assign({ _template: VermineFight.rollerTemplate }, { ...VermineFight.previousValues, ...externalData });
return o;
};
let data = charData(externalData);
console.log(data);
// render template
let html = await foundry.applications.handlebars.renderTemplate(data._template, data);
let ui = new Dialog({
title: game.i18n.localize("VERMINE.FightTool"),
content: html,
buttons: {
roll: {
label: game.i18n.localize('VERMINE.Roll4Fight'),
callback: (html) => {
let form = html.find('#dice-pool-form');
if (!form[0].checkValidity()) {
throw "Invalid Data";
}
let enemyAchievement, enemyConservation, skillKey, skill = 5, enemySkill, params = {};
form.serializeArray().forEach(e => {
switch (e.name) {
case "skill":
case "cephalic":
if (e.value !== '') {
skillKey = e.value;
}
break;
case "skill-score":
skill = +e.value;
break;
case "specialization":
params.specialization = true;
break;
case "usure":
params.usure = +e.value;
break;
case "trait":
params.trait = +e.value;
break;
case "purpose":
params.purpose = true;
break;
case "spleen":
params.spleen = true;
break;
case "adv-skill":
enemySkill = +e.value;
break;
case "achievement":
enemyAchievement = +e.value;
break;
case "conservation":
enemyConservation = +e.value;
break;
}
});
// prise en compte de l'usure sur la feuille de perso
if (params.usure != undefined) {
const newSpentScore = getActorSkillScore(actor, skillKey, 'spent') + params.usure;
console.log(newSpentScore);
updateActorSkillScore(actor, skillKey, 'spent', newSpentScore);
}
return VermineFight.get().performTest(enemyAchievement + enemySkill, enemyConservation + enemySkill, skillKey, skill, params, actor);
}
},
cancel: {
label: game.i18n.localize('Close'),
callback: () => { }
}
},
render: function (h) {
h.on("change", 'select[name="skill"]', event => {
const skillLabel = $(event.target).val();
const currentSkillScore = getActorSkillScore(actor, skillLabel) - getActorSkillScore(actor, skillLabel, 'spent');
if (parseInt(currentSkillScore, 10) >= 0) {
h.find('input#skillScore').val(currentSkillScore);
}
});
}
}, { width: 601, height: 'fit-content' });
ui.render(true);
return ui;
}
}
export class VermineCombat extends Combat {
_encounterCheck() {
console.log('encounter combat object', this);
// encounter check
}
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
// roll initiative
return super.rollInitiative(ids, formula, messageOptions)
}
@@ -421,13 +228,6 @@ export class VermineCombatTracker extends foundry.applications.sidebar.tabs.Comb
return "systems/vermine2047/templates/combat-tracker.hbs";
}
/* -------------------------------------------- */
get template() {
return "systems/vermine2047/templates/combat-tracker.hbs";
}
async getData(options) {
const context = await super.getData(options);
@@ -441,7 +241,9 @@ export class VermineCombatTracker extends foundry.applications.sidebar.tabs.Comb
activateListeners(html) {
super.activateListeners(html);
html.find("[data-attitude]").click(this._setStatut.bind(this));
html.querySelectorAll("[data-attitude]").forEach(el => {
el.addEventListener("click", this._setStatut.bind(this));
});
}
/**
@@ -465,23 +267,20 @@ export class VermineCombatTracker extends foundry.applications.sidebar.tabs.Comb
}
let actor = await game.actors.get(combatant.actorId)
console.log(actor, combatant)
// combatant attitude set
}
}
export class VermineCombatant extends Combatant {
constructor(data, context) {
super(data, context);
this.setDefaultAttitude();
}
setDefaultAttitude() {
this.attitude = this.token.flags.world?.attitude || "active"
super(data, context)
if (this.token) {
this.attitude = this.token.flags.world?.attitude || "active"
} else {
this.attitude = "active"
}
}
_getInitiativeFormula() {
return String(CONFIG.Combat.initiative.formula || game.system.initiative);
return String(CONFIG.Combat.initiative.formula || game.system.initiative)
}
}