Skip to content

Commit

Permalink
Starting to figure out socket animations and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Dec 22, 2023
1 parent eb81aa9 commit 1b7490a
Show file tree
Hide file tree
Showing 45 changed files with 984 additions and 632 deletions.
Binary file added assets/backgrounds/ink-streak-1.png
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 assets/backgrounds/ink-streak-2.png
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 assets/backgrounds/ink-streak-3.png
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 assets/backgrounds/ink-swipe-1.png
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 assets/backgrounds/ink-swipe-2.png
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 assets/backgrounds/ink-swipe-3.png
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 assets/backgrounds/ink-swipe-diagonal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions css/style.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -6436,6 +6436,8 @@ template {
width: 100%;
pointer-events: none;
z-index: 50;
perspective: 500px;
transform-style: preserve-3d;
}
:root body.vtt.game.system-eunos-blades #blades-overlay #testSquare, :root body.vtt.game.system-eunos-blades #blades-overlay .overlay-section #testSquare {
position: absolute;
Expand All @@ -6445,6 +6447,9 @@ template {
height: 200px;
width: 200px;
}
:root body.vtt.game.system-eunos-blades #blades-overlay .clock-key-container, :root body.vtt.game.system-eunos-blades #blades-overlay .overlay-section .clock-key-container {
visibility: hidden;
}
:root body.vtt.game.system-eunos-blades #clocks-overlay {
margin-top: 0.25rem;
}
Expand Down Expand Up @@ -9084,7 +9089,7 @@ template {
/* CONTROLS */
}
:root body.vtt.game.system-eunos-blades #clocks-overlay .clock-key-container {
position: relative;
position: absolute;
perspective: 500px;
transform-style: preserve-3d;
}
Expand Down Expand Up @@ -22875,7 +22880,7 @@ template {
/* CONTROLS */
}
:root body.vtt.game.system-eunos-blades .app.window-app .clock-key-container {
position: relative;
position: absolute;
perspective: 500px;
transform-style: preserve-3d;
}
Expand Down Expand Up @@ -24824,7 +24829,7 @@ template {
/* CONTROLS */
}
:root body.vtt.game.system-eunos-blades .app.window-app.sheet .window-content .clock-key-container .clock-key-container {
position: relative;
position: absolute;
perspective: 500px;
transform-style: preserve-3d;
}
Expand Down
48 changes: 38 additions & 10 deletions module/BladesActor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// #region Imports ~
import U from "./core/utilities.js";
import C, { BladesActorType, Tag, Playbook, BladesItemType, ActionTrait, PrereqType, AdvancementPoint, Randomizers, Factor } from "./core/constants.js";
import { BladesPC, BladesNPC } from "./documents/BladesActorProxy.js";
import { BladesPC, BladesCrew, BladesNPC } from "./documents/BladesActorProxy.js";
import { BladesItem } from "./documents/BladesItemProxy.js";
import { BladesRollMod } from "./classes/BladesRoll.js";
import BladesPushAlert from "./classes/BladesPushAlert.js";
import BladesDirector from "./classes/BladesDirector.js";
import { SelectionCategory } from "./classes/BladesDialog.js";
// #endregion
// Blades Theme Song: "Bangkok" from The Gray Man soundtrack: https://www.youtube.com/watch?v=cjjImvMqYlo&list=OLAK5uy_k9cZDd1Fbpd25jfDtte5A6HyauD2-cwgk&index=2
Expand Down Expand Up @@ -676,25 +676,53 @@ class BladesActor extends Actor {
return;
}
await this.update({ "system.experience.playbook.value": 0 });
if (BladesActor.IsType(this, BladesActorType.pc)) {
BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their Playbook!`, `${this.name}, select a new Ability on your Character Sheet.`, "advancement-alert");
if (this instanceof BladesPC) {
BladesDirector.getInstance().push("ALL", {
title: `${this.name} Advances their Playbook!`,
message: `${this.name}, select a new Ability on your Character Sheet.`,
type: "push",
classNames: "advancement-alert"
});
this.grantAdvancementPoints(AdvancementPoint.Ability);
return;
}
if (BladesActor.IsType(this, BladesActorType.crew)) {
BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their Playbook!`, "Select new Upgrades and/or Abilities on your Crew Sheet.", "advancement-alert");
if (this instanceof BladesCrew) {
BladesDirector.getInstance().push("ALL", {
title: "You Advance your Crew Playbook!",
message: "Select new Upgrades and/or Abilities on your Crew Sheet.",
type: "push",
classNames: "advancement-alert crew-advancement-alert"
});
const coinGained = this.system.tier.value + 2;
this.members.forEach((member) => {
const coinGained = this.system.tier.value + 2;
BladesPushAlert.Get().pushToAll("GM", `${member.name} Gains ${coinGained} Stash (Crew Advancement)`, null, "stash-gain-alert");
member.addStash(coinGained);
if (member.primaryUser?.id) {
BladesDirector.getInstance().push(member.primaryUser?.id, {
title: "Your Stash Increases! <em>(Crew Advancement)</em>",
message: `You gain ${coinGained} Stash from Crew Advancement.`,
type: "push",
classNames: "stash-alert"
});
member.addStash(coinGained);
}
});
this.grantAdvancementPoints(AdvancementPoint.UpgradeOrAbility, 2);
}
}
async advanceAttribute(attribute) {
if (!(this instanceof BladesPC)) {
return;
}
if (!this.primaryUser?.id) {
return;
}
await this.update({ [`system.experience.${attribute}.value`]: 0 });
const actions = C.Action[attribute].map((action) => `<strong>${U.tCase(action)}</strong>`);
BladesPushAlert.Get().pushToAll("GM", `${this.name} Advances their ${U.uCase(attribute)}!`, `${this.name}, add a dot to one of ${U.oxfordize(actions, true, "or")}.`, "advancement-alert");
BladesDirector.getInstance().push(this.primaryUser.id, {
title: `${this.name} Advances their ${U.uCase(attribute)}!`,
message: `${this.name}, add a dot to one of ${U.oxfordize(actions, true, "or")}.`,
type: "push",
classNames: "advancement-alert"
});
}
get isAtWar() {
if (BladesNPC.IsType(this)) {
Expand Down
9 changes: 7 additions & 2 deletions module/BladesItem.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import C, { BladesItemType, Tag, Factor } from "./core/constants.js";
import U from "./core/utilities.js";
import { BladesCrew, BladesPC } from "./documents/BladesActorProxy.js";
import BladesDirector from "./classes/BladesDirector.js";
import { BladesRollMod } from "./classes/BladesRoll.js";
import BladesPushAlert from "./classes/BladesPushAlert.js";
class BladesItem extends Item {
// #region Static Overrides: Create ~
static async create(data, options = {}) {
Expand Down Expand Up @@ -204,8 +204,13 @@ class BladesItem extends Item {
"They cannot do anything until they recover.",
"You may replace them during Downtime."
];
BladesDirector.getInstance().push("ALL", {
title: `${this.name} ${harmVerb[newHarm - 1]}`,
message: harmEffect[newHarm - 1],
type: "push",
cssClasses: "harm-alert"
});
await this.update({ "system.harm": amount });
BladesPushAlert.Get().pushToAll("GM", `${this.name} ${harmVerb[newHarm - 1]}`, harmEffect[newHarm - 1], "harm-alert");
}
}
async applyWorsePosition() {
Expand Down
60 changes: 21 additions & 39 deletions module/blades.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import C, { ActionTrait, ClockColor, AttributeTrait, RollType, ConsequenceType } from "./core/constants.js";
import registerSettings, { initTinyMCEStyles, initCanvasStyles, initDOMStyles } from "./core/settings.js";
import { registerHandlebarHelpers, preloadHandlebarsTemplates } from "./core/helpers.js";
import BladesPushAlert from "./classes/BladesPushAlert.js";
import BladesChat from "./classes/BladesChat.js";
import U from "./core/utilities.js";
import logger from "./core/logger.js";
Expand Down Expand Up @@ -542,7 +541,6 @@ class GlobalGetter {
BladesClockKey,
BladesNPCSheet,
BladesActiveEffect,
BladesPushAlert,
BladesRoll,
BladesRollMod,
BladesRollPrimary,
Expand Down Expand Up @@ -571,7 +569,8 @@ Hooks.once("init", async () => {
game.eunoblades = {
Clocks: new Collection(),
ClockKeys: new Collection(),
Consequences: new Collection()
Consequences: new Collection(),
Director: BladesDirector.getInstance()
};
// Register System Settings
registerSettings();
Expand All @@ -588,61 +587,44 @@ Hooks.once("init", async () => {
Actors.registerSheet("blades", BladesNPCSheet, { types: ["npc"], makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("blades", BladesItemSheet, { types: C.ItemTypes, makeDefault: true });
// Initialize subclasses
registerHandlebarHelpers();
preloadHandlebarsTemplates();
// Initialize preliminary classes with templates to load
await Promise.all([
BladesDirector.Initialize(),
BladesPCSheet.Initialize(),
BladesActiveEffect.Initialize(),
BladesGMTrackerSheet.Initialize(),
BladesClockKeeperSheet.Initialize(),
BladesScore.Initialize(),
BladesDialog.Initialize(),
BladesClockKeeperSheet.Initialize(),
BladesPushAlert.Initialize(),
BladesRoll.Initialize(),
BladesProject.Initialize(),
BladesChat.Initialize(),
preloadHandlebarsTemplates()
BladesChat.Initialize()
]);
registerHandlebarHelpers();
});
Hooks.once("ready", () => {
Hooks.once("ready", async () => {
// Initialize overlays
await Promise.all([
BladesDirector.Initialize(),
BladesGMTracker.Initialize(),
BladesClockKeeper.Initialize()
]);
// Initialize Clocks, ClockKeys & Consequences
BladesClockKey.Initialize();
await BladesConsequence.Initialize();
initDOMStyles();
initCanvasStyles();
initTinyMCEStyles();
// Initialize Clocks, ClockKeys & Consequences
BladesClockKey.Initialize();
BladesConsequence.Initialize();
BladesDirector.getInstance().renderOverlay();
await BladesDirector.getInstance().renderOverlay();
BladesDirector.InitSockets();
BladesRoll.InitSockets();
BladesClockKeeper.InitSockets();
});
// #endregion ▄▄▄▄▄ SYSTEM INITIALIZATION ▄▄▄▄▄
// #region ░░░░░░░[SocketLib]░░░░ SocketLib Initialization ░░░░░░░ ~
Hooks.once("socketlib.ready", () => {
socket = socketlib.registerSystem("eunos-blades");
/* DEVCODE*/ Object.assign(globalThis, { socket, socketlib }); /* !DEVCODE*/
BladesDirector.InitSockets();
BladesRoll.InitSockets();
let clockOverlayUp;
let pushControllerUp;
/**
* Initializes the overlay sockets for the BladesClockKeeperSheet and BladesPushAlert.
* It checks every 2 seconds if the overlays are up and running.
* If both overlays are up, it stops checking.
*
* @function
* @name InitOverlaySockets
* @returns {void}
*/
function InitOverlaySockets() {
setTimeout(() => {
clockOverlayUp = clockOverlayUp || BladesClockKeeperSheet.InitSockets();
pushControllerUp = pushControllerUp || BladesPushAlert.InitSockets();
if (clockOverlayUp && pushControllerUp) {
return;
}
InitOverlaySockets();
}, 2000);
}
InitOverlaySockets();
});
Hooks.once("diceSoNiceReady", (dice3d) => {
dice3d.addSystem({ id: "eunos-blades", name: "Euno's Blades" }, "preferred");
Expand Down
88 changes: 1 addition & 87 deletions module/classes/BladesClock.js
Original file line number Diff line number Diff line change
@@ -1,94 +1,8 @@
import C, { BladesActorType, BladesItemType, ClockColor, ClockKeyDisplayMode, Factor } from "../core/constants.js";
import BladesTargetLink from "./BladesTargetLink.js";
import U from "../core/utilities.js";
import { BladesActor } from "../documents/BladesActorProxy.js";
import { BladesItem } from "../documents/BladesItemProxy.js";
class BladesTargetLink {
static validateConfig(ref) {
// Check if 'ref' is a simple object literal
if (!U.isSimpleObj(ref)) {
return false;
}
// Confirm a target key or flag key has been provided.
if (!ref.targetKey && !ref.targetFlagKey) {
return false;
}
// Confirm a target has been provided, and that it can be resolved to a Document entity.
if (!ref.target) {
return false;
}
if (U.isDocID(ref.target)) {
// Convert string id of target to target Document
ref.target = game.actors.get(ref.target) ?? game.items.get(ref.target);
}
if (!(ref.target instanceof Actor || ref.target instanceof Item)) {
return false;
}
// Create a random ID if one not provided.
if (!ref.id) {
ref.id = randomID();
}
return true;
}
_id;
_targetID;
get targetID() { return this._targetID; }
_target;
get target() { return this._target; }
_targetKey = "system";
get targetKey() { return this._targetKey; }
_targetFlagKey;
get targetFlagKey() { return this._targetFlagKey; }
constructor(config) {
if (!BladesTargetLink.validateConfig(config)) {
eLog.error("[new BladesTargetLink] Bad Config File.", config);
throw new Error("See log.");
}
const { id, target, targetKey, targetFlagKey } = config;
this._id = id;
this._target = target;
this._targetID = this.target.id;
this._targetKey = targetKey ?? "system";
this._targetFlagKey = targetFlagKey;
}
getSystemData() {
if (this.targetFlagKey) {
return this.target.getFlag("eunos-blades", `${this.targetFlagKey}.${this._id}`);
}
return getProperty(this.target, `${this.targetKey}.${this._id}`) ?? {};
}
get id() { return this._id; }
get name() { return this.getSystemData().name; }
getTargetProp(prop) {
return this.getSystemData()[prop];
}
async updateTarget(prop, val) {
if (this.targetFlagKey) {
this.target.setFlag("eunos-blades", `${this.targetFlagKey}.${this._id}.${prop}`, val);
}
else {
this.target.update({ [`${this.targetKey}.${this._id}.${prop}`]: val });
}
}
async updateTargetData(val) {
if (this.targetFlagKey) {
if (val === null) {
return this.target.unsetFlag("eunos-blades", `${this.targetFlagKey}.${this._id}`);
}
else {
return this.target.setFlag("eunos-blades", `${this.targetFlagKey}.${this._id}`, val);
}
}
else if (val === null) {
return this.target.update({ [`${this.targetKey}.-=${this._id}`]: null });
}
else {
return this.target.update({ [`${this.targetKey}.${this._id}`]: val });
}
}
async delete() {
return this.updateTargetData(null);
}
}
class BladesClockKey extends BladesTargetLink {
// #region STATIC METHODS ~
static Initialize() {
Expand Down
Loading

0 comments on commit 1b7490a

Please sign in to comment.