Skip to content

Commit

Permalink
Initial Push
Browse files Browse the repository at this point in the history
  • Loading branch information
ChasarooniZ committed Jun 26, 2024
1 parent 057cc47 commit e156007
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
scripts/ \
styles/ \
packs/ \
language/ \
languages/ \
lang/
# Don't forget to add a backslash at the end of the line for any
# additional files or directories!
Expand Down
File renamed without changes.
71 changes: 7 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,14 @@
![](https://img.shields.io/badge/Foundry-v10-informational)
<!--- Downloads @ Latest Badge -->
<!--- replace <user>/<repo> with your username/repository -->
<!--- ![Latest Release Download Count](https://img.shields.io/github/downloads/<user>/<repo>/latest/module.zip) -->
![](https://img.shields.io/badge/Foundry-v12-informational)

<!--- Forge Bazaar Install % Badge -->
<!--- replace <your-module-name> with the `name` in your manifest -->
<!--- ![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%2F<your-module-name>&colorB=4aa94a) -->


# How to use this Template to create a versioned Release
# PF2e Reactive Token Ring
Adds some reaction for the pf2e system for dynamic token rings

1. Open your repository's releases page.

![Where to click to open repository releases.](https://user-images.githubusercontent.com/7644614/93409301-9fd25080-f864-11ea-9e0c-bdd09e4418e4.png)

2. Click "Draft a new release"

![Draft a new release button.](https://user-images.githubusercontent.com/7644614/93409364-c1333c80-f864-11ea-89f1-abfcb18a8d9f.png)

3. Fill out the release version as the tag name.

If you want to add details at this stage you can, or you can always come back later and edit them.

![Release Creation Form](https://user-images.githubusercontent.com/7644614/93409543-225b1000-f865-11ea-9a19-f1906a724421.png)

4. Hit submit.

5. Wait a few minutes.

A Github Action will run to populate the `module.json` and `module.zip` with the correct urls that you can then use to distribute this release. You can check on its status in the "Actions" tab.

![Actions Tab](https://user-images.githubusercontent.com/7644614/93409820-c1800780-f865-11ea-8c6b-c3792e35e0c8.png)

6. Grab the module.json url from the release's details page.

![image](https://user-images.githubusercontent.com/7644614/93409960-10c63800-f866-11ea-83f6-270cc5d10b71.png)

This `module.json` will only ever point at this release's `module.zip`, making it useful for sharing a specific version for compatibility purposes.

7. You can use the url `https://github.com/<user>/<repo>/releases/latest/download/module.json` to refer to the manifest.

This is the url you want to use to install the module typically, as it will get updated automatically.

# How to List Your Releases on Package Admin

To request a package listing for your first release, go to the [Package Submission Form](https://foundryvtt.com/packages/submit) (accessible via a link at the bottom of the "[Systems and Modules](https://foundryvtt.com/packages/)" page on the Foundry website).

Fill in the form. "Package Name" must match the name in the module manifest. Package Title will be the display name for the package. Package URL should be your repo URL.
![image](https://user-images.githubusercontent.com/36359784/120664263-b49e5500-c482-11eb-9126-af7006389903.png)


One of the Foundry staff will typically get back to you with an approval or any further questions within a few days, and give you access to the package admin pages.

Once you have access to the [module admin page](https://foundryvtt.com/admin/packages/package/), you can release a new version by going into the page for your module, scrolling to the bottom, and filling in a new Package Version.

When listing a new version, Version should be the version number you set above, and the Manifest URL should be the manifest __for that specific version__ (do not use /latest/ here).
![image](https://user-images.githubusercontent.com/36359784/120664346-c4b63480-c482-11eb-9d8b-731b50d70939.png)

> ### :warning: Important :warning:
>
> It is very important that you use the specific release manifest url, and not the `/latest` url here. For more details about why this is important and how Foundry Installs/Updates packages, read [this wiki article](https://foundryvtt.wiki/en/development/guides/releases-and-history).
Clicking "Save" in the bottom right will save the new version, which means that anyone installing your module from within Foundry will get that version, and a post will be generated in the #release-announcements channel on the official Foundry VTT Discord.


# FoundryVTT Module

Does something, probably

## Changelog
## Features
- Flashes red on damage taken
- Flashes green on heal
- Flashes white when targetted
36 changes: 17 additions & 19 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
{
"id": "module",
"title": "New Module",
"description": "",
"id": "pf2e-reactive-token-ring",
"title": "PF2e Reactive Token Ring",
"description": "Adds some reaction for the pf2e system for dynamic token rings",
"version": "#{VERSION}#",
"library": "false",
"manifestPlusVersion": "1.2.0",
"compatibility": {
"minimum": 10,
"verified": 10,
"maximum": 11
"minimum": 12,
"verified": 12
},
"authors": [
{
"name": "The League of Extraordinary FVTT Developers",
"url": "https://github.com/League-of-Foundry-Developers",
"discord": "discordID#0001"
"name": "chasarooniZ"
}
],
"relationships": {
"systems": [],
"systems": [
{
"id": "pf2e",
"type": "system",
"compatibility": {
"minimum": "5.2.1",
"verified": "5.3.0"
}
}
],
"requires": []
},
"esmodules": [
"scripts/module.js"
],
"scripts": [
"scripts/lib/lib.js"
],
"styles": [
"styles/module.css"
],
"esmodules": ["scripts/module.js"],
"languages": [
{
"lang": "en",
Expand Down
84 changes: 82 additions & 2 deletions scripts/module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,87 @@
Hooks.once('init', async function() {
Hooks.once("init", async function () {});

const COLORS = {
GREEN: "#ADFF2F",
RED: "#ff0000",
WHITE: "#FFFFFF",
};
Hooks.once("ready", async function () {
Hooks.on("updateActor", async (actor, update, status, userID) => {
if (userID == game.user.id) {
if (status.diff) {
const hpChanged = update.system.attributes.hp.value;
const dmgTaken = status.damageTaken;
const tok = canvas.tokens.placeables.find(
(token) => token.actor.id === actor.id
);
if (hpChanged) {
if (dmgTaken) {
//Dealt Damage
flashColor(tok, COLORS.RED);
} else {
//Heal
flashColor(tok, COLORS.GREEN);
}
}
}
}
});
Hooks.on("targetToken", async (user, token) => {
if (user.id === game.user.id) {
flashColor(token, COLORS.WHITE);
}
});
});

Hooks.once('ready', async function() {
const defaultAnimationOptions = {
duration: 500,
easing: CONFIG.Token.ringClass.easeTwoPeaks,
};

/**
* flash color of token
* @param {Token} token Token to flash
* @param {string} color Color as hex aka '#0000FF'
* @param {AnimationOptions} animationOverride Override to animation options
*/
async function flashColor(token, color, animationOverride = {}) {
//if ring enabled flash it
if (token?.document?.ring?.enabled) {
const options = foundry.utils.mergeObject(
defaultAnimationOptions,
animationOverride
);
const colorNum = Color.fromString(color);
return token.ring.flashColor(colorNum, options);
}
//return Promise.resolve();
}

// Code Borrowed from DND 5e system implementation of color flash

/**
* Easing function that produces two peaks before returning to the original value. Ideal duration is around 500ms.
* @param {number} pt The proportional animation timing on [0,1].
* @returns {number} The eased animation progress on [0,1].
*/
function easeTwoPeaks(pt) {
return (Math.sin(4 * Math.PI * pt - Math.PI / 2) + 1) / 2;
}

/* -------------------------------------------- */
/* Rings System */
/* -------------------------------------------- */

/**
* The effects which could be applied to a token ring (using bitwise operations.)
* @enum {number}
* @readonly
*/
const effects = Object.freeze({
DISABLED: 0x00,
ENABLED: 0x01,
RING_PULSE: 0x02,
RING_GRADIENT: 0x04,
BKG_WAVE: 0x08,
INVISIBILITY: 0x10,
});
10 changes: 10 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function registerSettings() {
game.settings.register("pf2e-reactive-token-ring", "enabled", {
name: game.i18n.localize("pf2e-reactive-token-ring.module-settings.enabled.name"),
hint: game.i18n.localize("pf2e-reactive-token-ring.module-settings.enabled.hint"),
scope: "world",
config: true,
default: true,
type: Boolean,
});
}

0 comments on commit e156007

Please sign in to comment.