Skip to content

Commit

Permalink
Quick fix for issue #40 - prepared for release
Browse files Browse the repository at this point in the history
  • Loading branch information
lupestro committed Feb 26, 2023
1 parent d328bb1 commit c56fe80
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Middle Kingdom - v10 -> main branch

### 2.6.0 - February 26, 2022
- [FEATURE] (amir-arad) Added support for Old School Essentials (ose) and for quantities within objects. (PR #46 Thanks!)
- [BUGFIX] (Lupestro) GM escalation is now only invoked for the named light source on the intended game system. The only implemented example of this to date is token creation/deletion for Dancing Lights on dnd5e. (Behavior when aliasing the name of one of these _in the same game system_ to be used for something else is undefined.) (Issue #40)

### 2.5.0 - February 18, 2023
- [FEATURE] (Unomagan) Added light sources for Starfinder

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ Out of the box, the following are available:
| swade | Candle, Flashlight, Lantern, Torch
| pf1 | Candle, Lamp, Lantern, Bullseye Lantern, Hooded Lantern, Miner's Lantern, Torch
| pf2e | Candle, Lantern (Hooded), Lantern (Bull's Eye), Torch
| sfrpg | "Comm Unit, Personal", "Portable Light, Beacon", "Portable Light, Flashlight", "Portable Light, Lantern", "Portable Light, Spotlight",
| earthdawn4e | Candle, Lantern (Hooded), Lantern (Bullseye), Torch
| gurps | "Candle, Tallow", "Flashlight, Heavy", "Mini Flashlight", "Micro Flashlight", "Survival Flashlight", "Lantern", "Torch", "Bull's-Eye Lantern", "Electric Lantern, Small", "Electric Lantern, Large", "Small Tactical Light", "Large Tactical Light", "Floodlight"
| dcc | "Lantern", "Torch, each"
| gurps | "Candle, Tallow", "Flashlight, Heavy", Mini Flashlight, Micro Flashlight, Survival Flashlight, Lantern, Torch, Bull's-Eye Lantern, "Electric Lantern, Small", "Electric Lantern, Large", Small Tactical Light, Large Tactical Light, Floodlight
| dcc | Lantern, "Torch, each",
| ose | Torch, Lantern

This module just sheds light from the location of a player token upon demand based upon equipment inventory. It is recommended *not* to use this module for spells or equipment that have other capabilities you intend to use, like performing damage or setting down the equipment, but to rely upon other common approaches, like active effects or item piles, for those.

Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "torch",
"title": "Torch",
"description": "Torch HUD Controls",
"version": "2.5.0",
"version": "2.6.0",
"authors": [
{
"name": "Deuce",
Expand Down
8 changes: 4 additions & 4 deletions request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
const NEEDED_PERMISSIONS = {
// Don't want to do yourself something you can't undo without a GM -
// so check for delete on create
"create:Dancing Lights": ["TOKEN_CREATE", "TOKEN_DELETE"],
"delete:Dancing Lights": ["TOKEN_DELETE"],
"create:dnd5e:Dancing Lights": ["TOKEN_CREATE", "TOKEN_DELETE"],
"delete:dnd5e:Dancing Lights": ["TOKEN_DELETE"],
};

export default class TorchRequest {
static ACTIONS = {
"create:Dancing Lights": TorchRequest.createDancingLights,
"delete:Dancing Lights": TorchRequest.removeDancingLights,
"create:dnd5e:Dancing Lights": TorchRequest.createDancingLights,
"delete:dnd5e:Dancing Lights": TorchRequest.removeDancingLights,
};
static isPermitted(user, requestType) {
if (requestType in NEEDED_PERMISSIONS) {
Expand Down
5 changes: 3 additions & 2 deletions socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default class TorchSocket {
* See if this light source supports a socket request for this action
*/
static requestSupported(action, lightSource) {
return TorchRequest.supports(`${action}:${lightSource}`);

return TorchRequest.supports(`${action}:${game.system.id}:${lightSource}`);
}

/*
Expand All @@ -31,7 +32,7 @@ export default class TorchSocket {
*/
static async sendRequest(tokenId, action, lightSource, lightSettings) {
let req = {
requestType: `${action}:${lightSource}`,
requestType: `${action}:${game.system.id}:${lightSource}`,
sceneId: canvas.scene.id,
tokenId: tokenId,
lightSettings: lightSettings
Expand Down
3 changes: 3 additions & 0 deletions topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class StandardLightTopology {
constructor(quantityField) {
this.quantityField = quantityField ?? "quantity";
}

_getQuantity(item) {
let val = item.system;
for (const segment of this.quantityField.split(".")) {
val = val[segment];
}
return val;
}

_findMatchingItem(actor, lightSourceName) {
return Array.from(actor.items).find(
(item) => item.name.toLowerCase() === lightSourceName.toLowerCase()
Expand Down Expand Up @@ -58,6 +60,7 @@ class StandardLightTopology {
return Promise.resolve();
}
}

async setInventory (actor, lightSource, count) {
if (!lightSource.consumable) return Promise.resolve();
let item = this._findMatchingItem(actor, lightSource.name);
Expand Down
Binary file modified torch.zip
Binary file not shown.

0 comments on commit c56fe80

Please sign in to comment.