Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
Grandsome authored Aug 25, 2024
1 parent 17b3e7f commit 81da61b
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
41 changes: 41 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "gnd-elevation-ruler-wod20-compatibility",
"title": "Elevation Ruler World of Darkness 20th Anniversary Compatibility",
"version": "1.0.0",
"compatibility": {
"minimum": "12",
"verified": "12"
},
"relationships": {
"requires": [
{
"id": "elevationruler",
"type": "module",
"compatibility": {}
}
]
},
"esmodules": [
"scripts/speed_provider.js"
],
"description": "Adds Basic Elevation Ruler Compatibility for World of Darkness 20th Anniversary.\nBased on Rapunzel77 TDE 5 Drag Ruler Integration (Das Schwarze Auge) module.",
"authors": [
{
"name": "grandsome",
"discord": "grandsome",
"flags": {}
},
{
"name": "caewok",
"url": "https://github.com/caewok",
"discord": "caewok#9192",
"flags": {}
},
{
"name": "Rapunzel7",
"url": "https://github.com/Rapunzel77/dsa5-drag-ruler",
"discord": "Rapunzel_77#7051",
"flags": {}
}
]
}
87 changes: 87 additions & 0 deletions scripts/speed_provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
Hooks.once("init", () => {
game.settings.register("wod20-elevation-ruler-integration", "walk", {
name: "walk",
scope: "client",
config: true,
type: new foundry.data.fields.ColorField(),
default: "#00FF00",
onChange: (value) => { refreshSpeedCategories(); }
});

game.settings.register("wod20-elevation-ruler-integration", "jog", {
name: "jog",
scope: "client",
config: true,
type: new foundry.data.fields.ColorField(),
default: "#0xFFFF00",
onChange: (value) => { refreshSpeedCategories(); }
});

game.settings.register("wod20-elevation-ruler-integration", "run", {
name: "run",
scope: "client",
config: true,
type: new foundry.data.fields.ColorField(),
default: "0xFF8000",
onChange: (value) => { refreshSpeedCategories(); }
});

game.settings.register("wod20-elevation-ruler-integration", "unreachable", {
name: "unreachable",
scope: "client",
config: true,
type: new foundry.data.fields.ColorField(),
default: "#FF0000",
onChange: (value) => { refreshSpeedCategories(); }
});

});

Hooks.once("ready", () => {
refreshSpeedCategories();

CONFIG.elevationruler.SPEED.tokenSpeed = function (token) {
const baseSpeed = token.actor.system.movement.jog;
if (baseSpeed === null) return null;
return Number(baseSpeed);
};

CONFIG.elevationruler.SPEED.maximumCategoryDistance = function (token, speedCategory, tokenSpeed) {
switch (speedCategory.name) {
case "walk":
return speedCategory.multiplier * tokenSpeed;
case "jog":
return speedCategory.multiplier * tokenSpeed;
case "run":
return speedCategory.multiplier * tokenSpeed;
}
return Number.POSITIVE_INFINITY;
};
});

function refreshSpeedCategories() {
let walkAction = {
name: "walk",
color: Color.from(game.settings.get("wod20-elevation-ruler-integration", "walk")),
multiplier: 0.5
}

let jogAction = {
name: "jog",
color: Color.from(game.settings.get("wod20-elevation-ruler-integration", "jog")),
multiplier: 1
}
let runAction = {
name: "run",
color: Color.from(game.settings.get("wod20-elevation-ruler-integration", "run")),
multiplier: 2
}

let Unreachable = {
name: "Unreachable",
color: Color.from(game.settings.get("wod20-elevation-ruler-integration", "unreachable")),
multiplier: Number.POSITIVE_INFINITY
}

CONFIG.elevationruler.SPEED.CATEGORIES = [walkAction, jogAction, runAction, Unreachable];
}

0 comments on commit 81da61b

Please sign in to comment.