90de66d668
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
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
/**
|
|
* 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") {
|
|
const skills = actor.system?.skills;
|
|
if (!skills) return null;
|
|
|
|
for (const key of Object.keys(skills)) {
|
|
if (skills[key].label === skillLabel) {
|
|
return skills[key][property] ?? null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 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 {
|
|
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 false;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|