fix: Dice So Nice import v14 compat, override Foundry text colors for readability
Release Creation / build (release) Failing after 1m28s
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:
+28
-30
@@ -1,47 +1,45 @@
|
||||
import { VERMINE } from './config.mjs'
|
||||
|
||||
/**
|
||||
* renvoie le score d'une compétence d'un actor existant
|
||||
* @param {VermineActor}
|
||||
* @return {number||null} Data for rendering or null
|
||||
* Returns the score of a skill for an actor.
|
||||
* Skills are stored as a flat object in actor.system.skills: { [key]: { value, spent, label, category } }
|
||||
* @param {VermineActor} actor
|
||||
* @param {string} skillLabel - The localized label of the skill to find
|
||||
* @param {"value"|"spent"} [property="value"] - Which property to return
|
||||
* @returns {number|null} The skill score or null if not found
|
||||
*/
|
||||
export function getActorSkillScore(actor, skillLabel, property = "value") {
|
||||
let returnedValue = null;
|
||||
const skills = actor.system?.skills;
|
||||
if (!skills) return null;
|
||||
|
||||
for(let i in actor.system.skills){
|
||||
for(let j in actor.system.skills[i].data){
|
||||
if (actor.system.skills[i].data[j].label == skillLabel){
|
||||
returnedValue = actor.system.skills[i].data[j][property];
|
||||
}
|
||||
for (const key of Object.keys(skills)) {
|
||||
if (skills[key].label === skillLabel) {
|
||||
return skills[key][property] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
return returnedValue;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* met à jour le score d'une compétence d'un actor existant
|
||||
* @param {VermineActor}
|
||||
* @return {boolean} bool
|
||||
* Updates the score of a skill for an actor.
|
||||
* @param {VermineActor} selectedActor
|
||||
* @param {string} skillLabel - The localized label of the skill to update
|
||||
* @param {"value"|"spent"} [property="value"] - Which property to update
|
||||
* @param {number} updatedValue - The new value
|
||||
* @returns {boolean} Whether the update was successful
|
||||
*/
|
||||
export function updateActorSkillScore(selectedActor, skillLabel, property = "value", updatedValue) {
|
||||
try {
|
||||
let updated = false;
|
||||
// on recherche le label parmi les compétences
|
||||
for (let st in selectedActor.system.skills){
|
||||
for (let s in selectedActor.system.skills[st].data){
|
||||
if (selectedActor.system.skills[st].data[s].label == skillLabel){
|
||||
selectedActor.system.skills[st].data[s][property] = updatedValue; // printing the new value
|
||||
const systemSkillKey = `system.skills.${st}.data.${s}.${property}`;
|
||||
selectedActor.update({[systemSkillKey]:updatedValue }); // updating actor's data
|
||||
updated = true;
|
||||
}
|
||||
const skills = selectedActor.system?.skills;
|
||||
if (!skills) return false;
|
||||
|
||||
for (const key of Object.keys(skills)) {
|
||||
if (skills[key].label === skillLabel) {
|
||||
skills[key][property] = updatedValue;
|
||||
selectedActor.update({ [`system.skills.${key}.${property}`]: updatedValue });
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
} catch(e){
|
||||
return false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user