Skip to content

Commit 6341872

Browse files
committed
initial commit of alpha 1
0 parents  commit 6341872

File tree

9 files changed

+304
-0
lines changed

9 files changed

+304
-0
lines changed

.github/FUNDING.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
patreon: ElfFriend_DnD
4+
ko_fi: elffriend

.github/workflows/main.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release Creation
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
# get part of the tag after the `v`
14+
- name: Extract tag version number
15+
id: get_version
16+
uses: battila7/get-version-action@v2
17+
18+
# Substitute the Manifest and Download URLs in the module.json
19+
- name: Substitute Manifest and Download Links For Versioned Ones
20+
id: sub_manifest_link_version
21+
uses: microsoft/variable-substitution@v1
22+
with:
23+
files: 'module.json'
24+
env:
25+
version: ${{steps.get_version.outputs.version-without-v}}
26+
url: https://github.com/${{github.repository}}
27+
manifest: https://github.com/${{github.repository}}/releases/latest/download/module.json
28+
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip
29+
30+
# Create a zip file with all files required by the module to add to the release
31+
- run: zip -r ./module.zip module.json LICENSE scripts/ lang/ styles/ templates/
32+
33+
# Create a release for this specific version
34+
- name: Update Release with Files
35+
id: create_version_release
36+
uses: ncipollo/release-action@v1
37+
with:
38+
allowUpdates: true # Set this to false if you want to prevent updating existing releases
39+
name: ${{ github.event.release.name }}
40+
draft: ${{ github.event.release.unpublished }}
41+
prerelease: ${{ github.event.release.prerelease }}
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
artifacts: './module.json, ./module.zip'
44+
tag: ${{ github.event.release.tag_name }}
45+
body: ${{ github.event.release.body }}
46+
47+
# Publish this new version to the Foundry VTT Module Listing
48+
# - name: FoundryVTT AutoPublish
49+
# uses: Varriount/fvtt-autopublish@v1.0.2a
50+
# with:
51+
# username: ${{ secrets.FOUNDRY_ADMIN_USER }}
52+
# password: ${{ secrets.FOUNDRY_ADMIN_PW }}
53+
# module-id: 1633
54+
# manifest-url: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.json
55+
# manifest-file: module.json

.gitignore

Whitespace-only changes.

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "pwa-chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:30000",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Elf Friend D&D
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Item Effects to Chat D&D5e
2+
3+
![Foundry Core Compatible Version](https://img.shields.io/badge/dynamic/json.svg?url=https%3A%2F%2Fraw.githubusercontent.com%2FElfFriend-DnD%2Ffoundryvtt-drop-effects-on-items%2Fmain%2Fmodule.json&label=Foundry%20Version&query=$.compatibleCoreVersion&colorB=orange)
4+
![Latest Release Download Count](https://img.shields.io/badge/dynamic/json?label=Downloads@latest&query=assets%5B1%5D.download_count&url=https%3A%2F%2Fapi.github.com%2Frepos%2FElfFriend-DnD%2Ffoundryvtt-drop-effects-on-items%2Freleases%2Flatest)
5+
![Forge Installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Fdrop-effects-on-items&colorB=4aa94a)
6+
[![Foundry Hub Endorsements](https://img.shields.io/endpoint?logoColor=white&url=https%3A%2F%2Fwww.foundryvtt-hub.com%2Fwp-json%2Fhubapi%2Fv1%2Fpackage%2Fdrop-effects-on-items%2Fshield%2Fendorsements)](https://www.foundryvtt-hub.com/package/drop-effects-on-items/)
7+
[![Foundry Hub Comments](https://img.shields.io/endpoint?logoColor=white&url=https%3A%2F%2Fwww.foundryvtt-hub.com%2Fwp-json%2Fhubapi%2Fv1%2Fpackage%2Fdrop-effects-on-items%2Fshield%2Fcomments)](https://www.foundryvtt-hub.com/package/drop-effects-on-items/)
8+
9+
[![ko-fi](https://img.shields.io/badge/-buy%20me%20a%20coke-%23FF5E5B)](https://ko-fi.com/elffriend)
10+
[![patreon](https://img.shields.io/badge/-patreon-%23FF424D)](https://www.patreon.com/ElfFriend_DnD)
11+
12+
This module prints all Temporary Effects on an Item to Chat when that item is rolled. It also allows the GM to drag those effects onto tokens, or apply them to targeted tokens directly from the chat message.
13+
14+
This module does not affect the Active Effect data structure or behavior in any way.
15+
16+
![image](https://user-images.githubusercontent.com/7644614/147707503-713858cc-fd30-4d31-b320-3123ee612429.png)
17+
18+
19+
https://user-images.githubusercontent.com/7644614/147708014-12cd6997-0a59-47be-85cf-29d56eeb85d5.mp4
20+
21+
22+
## Compatibility
23+
24+
Requires More Hooks 5e
25+
26+
Super Charged by:
27+
- [Attack Roll Check D&D5e](https://github.com/ElfFriend-DnD/foundryvtt-attack-roll-check-5e)
28+
- [Auto Roll NPC Save D&D5e](https://github.com/ElfFriend-DnD/foundryvtt-auto-roll-npc-save-5e)
29+
30+
Compatible with:
31+
- Core dnd5e roller
32+
- Minimal Rolling Enhancements
33+
34+
Mostly Compatible with:
35+
- Better Rolls 5e
36+
- Midi QOL
37+
38+
39+
I'm not actively supporting these two so if something breaks, I'm open to a PR but not invested.
40+
41+
If you're using Midi, automatic application of effects is already possible without this module.
42+

jsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "es2020"
5+
},
6+
}

module.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "drop-effects-on-items",
3+
"title": "Drop Effects on Items",
4+
"description": "A module which allows effects to be dragged and dropped to and from Item Sheets.",
5+
"version": "0.0.1",
6+
"author": "Andrew Krigline",
7+
"authors": [
8+
{
9+
"name": "Andrew Krigline",
10+
"discord": "Calego#0914",
11+
"url": "https://github.com/ElfFriend-DnD",
12+
"ko-fi": "elffriend",
13+
"patreon": "ElfFriend_DnD"
14+
}
15+
],
16+
"scripts": [
17+
"./scripts/drop-effects-on-items.js"
18+
],
19+
"minimumCoreVersion": "0.8.9",
20+
"compatibleCoreVersion": "9",
21+
"url": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items",
22+
"bugs": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/issues",
23+
"changelog": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/releases",
24+
"manifest": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/releases/latest/download/module.json",
25+
"download": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/releases/latest/download/module.zip",
26+
"license": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/raw/main/LICENSE",
27+
"readme": "https://github.com/ElfFriend-DnD/foundryvtt-drop-effects-on-items/raw/main/README.md",
28+
"flags": {
29+
"allowBugReporter": true
30+
}
31+
}

scripts/drop-effects-on-items.js

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
export class DropEffectsOnItems {
2+
static MODULE_NAME = "drop-effects-on-items";
3+
static MODULE_TITLE = "Drop Effects on Items";
4+
5+
static log(...args) {
6+
if (game.modules.get('_dev-mode')?.api?.getPackageDebugValue(this.MODULE_NAME)) {
7+
console.log(this.MODULE_TITLE, '|', ...args);
8+
}
9+
}
10+
11+
static init = async () => {
12+
console.log(`${DropEffectsOnItems.MODULE_NAME} | Initializing ${DropEffectsOnItems.MODULE_TITLE}`);
13+
14+
Hooks.on('renderItemSheet', this.handleItemSheetRender);
15+
}
16+
17+
static handleItemSheetRender = (app, html) => {
18+
const effectsList = html.find('.effects-list');
19+
20+
if (app.item.isOwned || !effectsList || !app.isEditable) {
21+
return;
22+
}
23+
24+
this.log('binding dragdrop');
25+
26+
const dragDrop = new DragDrop({
27+
dragSelector: '[data-effect-id]',
28+
dropSelector: '.effects-list',
29+
permissions: { drag: () => app.isEditable, drop: () => app.isEditable },
30+
callbacks: { dragstart: this._onDragStart(app.object), drop: this._onDrop(app.object) }
31+
});
32+
33+
dragDrop.bind(html[0]);
34+
}
35+
36+
37+
/**
38+
* The Drag Start event which populates data to create an effect on drop
39+
* @param {*} event
40+
*/
41+
static _onDragStart = (effectParent) => (event) => {
42+
if (!effectParent) {
43+
this.log('DragDrop _onDragStart no parent', {
44+
effectParent
45+
});
46+
47+
return;
48+
}
49+
50+
const li = event.currentTarget;
51+
const effectId = li.dataset?.effectId;
52+
53+
if (!effectId) {
54+
return;
55+
}
56+
57+
const effect = effectParent.effects.get(effectId);
58+
59+
if (!effect) {
60+
return;
61+
}
62+
63+
// Create drag data
64+
const dragData = {
65+
type: 'ActiveEffect',
66+
data: effect.data,
67+
};
68+
69+
this.log('DragDrop dragStart:', {
70+
effect,
71+
dragData,
72+
});
73+
74+
// Set data transfer
75+
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
76+
};
77+
78+
/**
79+
* When an effect is dropped on the sheet, create a copy of that effect
80+
*/
81+
static _onDrop = (effectParent) => async (event) => {
82+
if (!effectParent) {
83+
return;
84+
}
85+
86+
// Try to extract the data
87+
let dropData;
88+
try {
89+
dropData = JSON.parse(event.dataTransfer.getData('text/plain'));
90+
91+
this.log('DragDrop drop', {
92+
event,
93+
dropData,
94+
});
95+
} catch (err) {
96+
this.log('DragDrop drop', {
97+
err,
98+
});
99+
100+
return false;
101+
}
102+
103+
104+
if (dropData.type !== 'ActiveEffect') return false;
105+
106+
107+
if (!!effectParent.effects.get(dropData.data._id)) {
108+
return;
109+
}
110+
111+
this.log('DragDrop drop starting:', {
112+
effectParent,
113+
dropData,
114+
});
115+
116+
return ActiveEffect.create(
117+
{
118+
...dropData.data,
119+
origin: effectParent.uuid,
120+
_id: null,
121+
}, {parent: effectParent}
122+
);
123+
}
124+
}
125+
126+
Hooks.on("ready", DropEffectsOnItems.init);
127+
128+
Hooks.once('devModeReady', ({ registerPackageDebugFlag }) => {
129+
registerPackageDebugFlag(DropEffectsOnItems.MODULE_NAME);
130+
});

0 commit comments

Comments
 (0)