Skip to content

Commit

Permalink
custom status effects
Browse files Browse the repository at this point in the history
  • Loading branch information
DrOgres committed Aug 7, 2021
1 parent 40eee50 commit 38423d9
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 24 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It provides support for **character sheets only**, game content should be drawn
* clean-up layout
* Add relationship Item Type

* Vaesen, NPC and HQ sheets
* Vaesen and NPC sheets
* UX improvements

* Dialogs and Chat
Expand All @@ -36,6 +36,8 @@ It provides support for **character sheets only**, game content should be drawn

* Localize Dialog and tooltip texts

* Link conditions on sheet and status icons on the character sheet (adding a status from the token toggels it on the sheet and visa versa)


## Related Website
- https://foundryvtt.com/
Expand All @@ -45,6 +47,13 @@ It provides support for **character sheets only**, game content should be drawn
[GNU General Public License v3.0](https://choosealicense.com/licenses/gpl-3.0/)

## Release Notes
v2.1.4
- Added roll dialog to the Recovery Rolls to allow for bonus dice from headquarters etc.
- Removed Damage from results in chat on things which have no damage.
- Added custom condition icons in foundry status icon menu (https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/blob/master/asset/status_icons.png?raw=true)
- Tightned styled and clarified the roll dialog (https://github.com/fvtt-fria-ligan/vaesen-foundry-vtt/blob/master/asset/roll_dialog.png?raw=true)


v2.1.3
- (bugfix) Agility modifier for Armor was not calculating in the roll dialog. Now highest negative modifier for armor will apply to agility tests.
- (Change) Updated look and feel of Headquarters sheet. Now all upgrades are on first page and "history" is relegated to a tab.
Expand Down
Binary file added asset/roll_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/arm-sling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/broken-bone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/despair.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/oppression.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/pummeled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/revolt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/shattered-heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions asset/status/terror.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added asset/status_icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions script/actor/vaesen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,77 @@ export class VaesenActor extends Actor {

}

/* -------------------------------------------- */
findStatusEffectById(id) {
return Array.from(this.effects?.values())
.find(it => it.data.flags.core?.statusId === id);
}

/* -------------------------------------------- */
async deleteStatusEffectById(id, options = {renderSheet: true}) {
console.log("delete by id: " + id);
const effects = Array.from(this.effects?.values())
.filter(it => it.data.flags.core?.statusId === id);
await this._deleteStatusEffects(effects, options);
}

/* -------------------------------------------- */
async _deleteStatusEffects(effects, options) {
console.log(effects);
console.log(effects.map(it => it.id));
console.log(options);
const ids = Array.from(effects.map(it => it.id));
await this.deleteEmbeddedDocuments('ActiveEffect', ids, options);
//await this._deleteStatusEffectsByIds(effects.map(it => it.id), options);

}

/* -------------------------------------------- */
async _deleteStatusEffectsByIds(effectIds, options) {
await this.deleteEmbeddedDocuments('ActiveEffect', effectIds, options);
}

/* -------------------------------------------- */
async addStatusEffectById(id, options = {renderSheet: false, unique: true}) {
if (this.hasStatusEffectById(id) && options.unique === true) {
return;
}
const statusEffect = CONFIG.statusEffects.find(it => it.id === id);
await this.addStatusEffect(statusEffect, options);
}

/* -------------------------------------------- */
async addStatusEffect(statusEffect, options = {renderSheet: false, overlay: false}) {
//await this.deleteStatusEffectById(statusEffect.id, options);
const effect = duplicate(statusEffect);
console.log(effect.label);
console.log(effect.id);
await this.createEmbeddedDocuments("ActiveEffect", [{
"flags.core.statusId": effect.id,
"flags.core.overlay": options.overlay,
label: effect.label,
icon: effect.icon,
origin: this.uuid,
}], options);
}

/* -------------------------------------------- */
hasStatusEffectById(id) {
const effects = this.findStatusEffectById(id);
return (effects !== undefined);
}

async toggleStatusEffectById(id, options = {renderSheet: true}) {
console.log("over to the character for toggeling");

const effect = this.findStatusEffectById(id);

if (effect) {
await this.deleteStatusEffectById(id);
} else {
await this.addStatusEffectById(id, options)
}
}

static async create(data, options={}) {
data.token = data.token || {};
Expand Down
3 changes: 3 additions & 0 deletions script/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const tftloop = {};

export const vaesen = {};
22 changes: 22 additions & 0 deletions script/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ import { AttackCharacterSheet } from "./sheet/attack.js";
import { UpgradeCharacterSheet } from "./sheet/upgrade.js";
import { prepareRollDialog, push } from "./util/roll.js";
import { registerSystemSettings } from "./util/settings.js";
import {vaesen} from "./config.js"
import {conditions} from "./util/conditions.js";

Hooks.once("ready", function(){
conditions.onReady();
});


Hooks.once("init", () => {
CONFIG.vaesen = vaesen;
CONFIG.Combat.initiative = { formula: "1d10", decimals: 0 };
CONFIG.Actor.documentClass = VaesenActor;
CONFIG.anonymousSheet = {};
Expand All @@ -39,6 +47,18 @@ Hooks.once("init", () => {
preloadHandlebarsTemplates();
// Register System Settings
registerSystemSettings();
Token.prototype._drawEffect = async function(src, i, bg, w, tint) {
const multiplier = 3;
const divisor = 3 * this.data.height;
w = (w / 2) * multiplier;
let tex = await loadTexture(src);
let icon = this.effects.addChild(new PIXI.Sprite(tex));
icon.width = icon.height = w;
icon.y = Math.floor(i / divisor) * w;
icon.x = (i % divisor) * w;
if ( tint ) icon.tint = tint;
this.effects.addChild(icon);
};
});

Hooks.once('diceSoNiceReady', (dice3d) => {
Expand Down Expand Up @@ -114,3 +134,5 @@ function preloadHandlebarsTemplates() {
];
return loadTemplates(templatePaths);
}


Loading

0 comments on commit 38423d9

Please sign in to comment.