mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-04-29 18:21:40 -04:00
Add customizable initiative.
This commit is contained in:
parent
c2d939aa1c
commit
ba02ddee4f
6 changed files with 122 additions and 11 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,7 @@
|
|||
# IDE
|
||||
.idea/
|
||||
.vs/
|
||||
|
||||
# Node Modules
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
|
32
gulpfile.js
Normal file
32
gulpfile.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
const gulp = require('gulp');
|
||||
const less = require('gulp-less');
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Compile LESS
|
||||
/* ----------------------------------------- */
|
||||
|
||||
const SIMPLE_LESS = ["styles/*.less"];
|
||||
function compileLESS() {
|
||||
return gulp.src("styles/simple.less")
|
||||
.pipe(less())
|
||||
.pipe(gulp.dest("./styles/"))
|
||||
}
|
||||
const css = gulp.series(compileLESS);
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Watch Updates
|
||||
/* ----------------------------------------- */
|
||||
|
||||
function watchUpdates() {
|
||||
gulp.watch(SIMPLE_LESS, css);
|
||||
}
|
||||
|
||||
/* ----------------------------------------- */
|
||||
/* Export Tasks
|
||||
/* ----------------------------------------- */
|
||||
|
||||
exports.default = gulp.series(
|
||||
gulp.parallel(css),
|
||||
watchUpdates
|
||||
);
|
||||
exports.css = css;
|
9
lang/en.json
Normal file
9
lang/en.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"SETTINGS.SimpleMacroShorthandN": "Shortened Macro Syntax",
|
||||
"SETTINGS.SimpleMacroShorthandL": "Enable a shortened macro syntax which allows referencing attributes directly, for example @str instead of @attributes.str.value. Disable this setting if you need the ability to reference the full attribute model, for example @attributes.str.label.",
|
||||
"SETTINGS.SimpleInitFormulaN": "Initiative Formula",
|
||||
"SETTINGS.SimpleInitFormulaL": "Enter an initiative formula, such as d20+@dex",
|
||||
|
||||
"SIMPLE.NotifyInitFormulaUpdated": "Initiative formula was updated to:",
|
||||
"SIMPLE.NotifyInitFormulaInvalid": "Initiative formula was invalid:"
|
||||
}
|
|
@ -17,7 +17,7 @@ Hooks.once("init", async function() {
|
|||
console.log(`Initializing Simple Worldbuilding System`);
|
||||
|
||||
/**
|
||||
* Set an initiative formula for the system
|
||||
* Set an initiative formula for the system. This will be updated later.
|
||||
* @type {String}
|
||||
*/
|
||||
CONFIG.Combat.initiative = {
|
||||
|
@ -36,11 +36,50 @@ Hooks.once("init", async function() {
|
|||
|
||||
// Register system settings
|
||||
game.settings.register("worldbuilding", "macroShorthand", {
|
||||
name: "Shortened Macro Syntax",
|
||||
hint: "Enable a shortened macro syntax which allows referencing attributes directly, for example @str instead of @attributes.str.value. Disable this setting if you need the ability to reference the full attribute model, for example @attributes.str.label.",
|
||||
name: "SETTINGS.SimpleMacroShorthandN",
|
||||
hint: "SETTINGS.SimpleMacroShorthandL",
|
||||
scope: "world",
|
||||
type: Boolean,
|
||||
default: true,
|
||||
config: true
|
||||
});
|
||||
|
||||
// Register initiative setting.
|
||||
game.settings.register("worldbuilding", "initFormula", {
|
||||
name: "SETTINGS.SimpleInitFormulaN",
|
||||
hint: "SETTINGS.SimpleInitFormulaL",
|
||||
scope: "world",
|
||||
type: String,
|
||||
default: "1d20",
|
||||
config: true,
|
||||
onChange: formula => _simpleUpdateInit(formula, true)
|
||||
});
|
||||
|
||||
// Retrieve and assign the initiative formula setting.
|
||||
const initFormula = game.settings.get("worldbuilding", "initFormula");
|
||||
_simpleUpdateInit(initFormula);
|
||||
|
||||
/**
|
||||
* Update the initiative formula.
|
||||
* @param {string} formula - Dice formula to evaluate.
|
||||
* @param {boolean} notify - Whether or not to post nofications.
|
||||
*/
|
||||
function _simpleUpdateInit(formula, notify = false) {
|
||||
// If the formula is valid, use it.
|
||||
try {
|
||||
new Roll(formula).roll();
|
||||
CONFIG.Combat.initiative.formula = formula;
|
||||
if (notify) {
|
||||
ui.notifications.notify(game.i18n.localize("SIMPLE.NotifyInitFormulaUpdated") + ` ${formula}`);
|
||||
}
|
||||
}
|
||||
// Otherwise, fall back to a d20.
|
||||
catch (error) {
|
||||
CONFIG.Combat.initiative.formula = "1d20";
|
||||
if (notify) {
|
||||
ui.notifications.error(game.i18n.localize("SIMPLE.NotifyInitFormulaInvalid") + ` ${formula}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
21
package.json
Normal file
21
package.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "worldbuilding",
|
||||
"version": "1.0.0",
|
||||
"description": "CSS compiler for the Worldbuilding system",
|
||||
"scripts": {
|
||||
"css": "gulp css",
|
||||
"watch": "gulp",
|
||||
"gulp": "gulp"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 3 versions"
|
||||
],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-less": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
|
@ -10,7 +10,13 @@
|
|||
"esmodules": ["module/simple.js"],
|
||||
"styles": ["styles/simple.css"],
|
||||
"packs": [],
|
||||
"languages": [],
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
"name": "English",
|
||||
"path": "lang/en.json"
|
||||
}
|
||||
],
|
||||
"gridDistance": 5,
|
||||
"gridUnits": "ft",
|
||||
"primaryTokenAttribute": "health",
|
||||
|
|
Loading…
Add table
Reference in a new issue