Skip to content

Commit

Permalink
Successful Compile before refactoring blades-item.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Feb 20, 2024
1 parent bd045b2 commit a556594
Show file tree
Hide file tree
Showing 35 changed files with 4,163 additions and 4,763 deletions.
12 changes: 0 additions & 12 deletions css/style.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -27808,18 +27808,6 @@ template {
:root body.vtt.game.system-eunos-blades .app.window-app.sheet.active-effect-sheet .window-content form section.tab.active[data-tab=effects] ol.changes-list li.effect-change.flexrow .value {
flex-grow: 3;
}
:root body.vtt.game.system-eunos-blades .app.window-app.sheet.roll-collab .clock-key {
background: rgba(0, 255, 255, 0.25);
outline: 2px dotted rgb(0, 255, 255);
}
:root body.vtt.game.system-eunos-blades .app.window-app.sheet.roll-collab .key-image-container {
background: rgba(255, 255, 0, 0.25);
outline: 2px dotted rgb(255, 255, 0);
}
:root body.vtt.game.system-eunos-blades .app.window-app.sheet.roll-collab .clock-key-container {
background: rgba(255, 0, 255, 0.25);
outline: 2px dotted rgb(255, 0, 255);
}
:root body.vtt.game.system-eunos-blades .app.window-app.sheet.roll-collab {
--roll-spacing: 5px;
height: auto !important;
Expand Down
2 changes: 1 addition & 1 deletion module/blades.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import BladesChat from "./classes/BladesChat.js";
import U from "./core/utilities.js";
import logger from "./core/logger.js";
import G, { Initialize as GsapInitialize } from "./core/gsap.js";
import BladesClockKey from "./classes/BladesClocks.js";
import BladesClockKey from "./classes/BladesClockKey.js";
import BladesDirector from "./classes/BladesDirector.js";
import BladesConsequence from "./classes/BladesConsequence.js";
import BladesScene from "./classes/BladesScene.js";
Expand Down
1,534 changes: 1,534 additions & 0 deletions module/classes/BladesClockKey.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion module/classes/BladesDirector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import U from "../core/utilities.js";
import { ClockKey_SVGDATA, BladesPhase, ClockKeyDisplayMode } from "../core/constants.js";
import BladesClockKey, { BladesClock } from "./BladesClocks.js";
import BladesClockKey, { BladesClock } from "./BladesClockKey.js";
class BladesDirector {
// #region INITIALIZATION ~
// #region >> Single-Instance Factory Construction ~
Expand Down
90 changes: 80 additions & 10 deletions module/classes/BladesRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import U from "../core/utilities.js";
import C, { BladesActorType, BladesItemType, RollPermissions, RollType, RollSubType, RollModType, RollModStatus, RollModSection, ActionTrait, DowntimeAction, AttributeTrait, Position, Effect, Factor, RollResult, RollPhase, ConsequenceType, Tag } from "../core/constants.js";
import { BladesActor, BladesPC, BladesCrew } from "../documents/BladesActorProxy.js";
import { BladesItem, BladesGMTracker } from "../documents/BladesItemProxy.js";
import { ApplyTooltipAnimations, ApplyConsequenceAnimations } from "../core/gsap.js";
import { ApplyTooltipAnimations, ApplyConsequenceAnimations, Dragger } from "../core/gsap.js";
import BladesConsequence from "./BladesConsequence.js";
import BladesDialog from "./BladesDialog.js";
import BladesChat from "./BladesChat.js";
Expand Down Expand Up @@ -545,7 +545,11 @@ class BladesRollMod extends BladesTargetLink {
}
if (!val || val === this.baseStatus) {
this.updateTarget("user_status", null)
.then(this.rollInstance.renderRollCollab_SocketCall.bind(this.rollInstance));
.then(() => {
if (this.rollInstance.isRendered) {
this.rollInstance.renderRollCollab_SocketCall();
}
});
}
else {
if (!game.user.isGM
Expand All @@ -554,7 +558,11 @@ class BladesRollMod extends BladesTargetLink {
return;
}
this.updateTarget("user_status", val)
.then(this.rollInstance.renderRollCollab_SocketCall.bind(this.rollInstance));
.then(() => {
if (this.rollInstance.isRendered) {
this.rollInstance.renderRollCollab_SocketCall();
}
});
}
}
get baseStatus() { return this.data.base_status; }
Expand All @@ -565,11 +573,19 @@ class BladesRollMod extends BladesTargetLink {
}
if (!val) {
this.updateTarget("held_status", null)
.then(this.rollInstance.renderRollCollab_SocketCall.bind(this.rollInstance));
.then(() => {
if (this.rollInstance.isRendered) {
this.rollInstance.renderRollCollab_SocketCall();
}
});
}
else {
this.updateTarget("held_status", val)
.then(this.rollInstance.renderRollCollab_SocketCall.bind(this.rollInstance));
.then(() => {
if (this.rollInstance.isRendered) {
this.rollInstance.renderRollCollab_SocketCall();
}
});
}
}
get value() { return this.data.value; }
Expand Down Expand Up @@ -664,7 +680,7 @@ class BladesRollPrimary {
if ("target" in config && BladesRollPrimary.IsDoc(config.target)) {
rollPrimary = config.target;
}
else if (BladesRollPrimary.IsDoc(rollUser?.character)) {
else if (rollUser && BladesRollPrimary.IsDoc(rollUser.character)) {
rollPrimary = rollUser.character;
}
else {
Expand Down Expand Up @@ -888,6 +904,16 @@ class BladesRollOpposition {
static IsDoc(doc) {
return BladesActor.IsType(doc, BladesActorType.npc, BladesActorType.faction) || BladesItem.IsType(doc, BladesItemType.cohort_expert, BladesItemType.cohort_gang);
}
static GetDataFromDoc(doc) {
return {
rollOppID: doc.id,
rollOppName: doc.name,
rollOppType: doc.type,
rollOppImg: doc.img,
rollOppModsSchemaSet: doc.rollOppModsSchemaSet,
rollFactors: doc.rollFactors
};
}
// #endregion
rollInstance;
rollOppID;
Expand Down Expand Up @@ -956,7 +982,9 @@ class BladesRollOpposition {
return;
}
await this.rollInstance.updateTarget("rollOppData", this.data);
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.rollInstance.id);
if (this.rollInstance.isRendered) {
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.rollInstance.id);
}
}
refresh() {
if (!this.rollInstance) {
Expand Down Expand Up @@ -1066,7 +1094,9 @@ class BladesRollParticipant {
}
async updateRollFlags() {
await this.rollInstance.updateTarget(`rollParticipantData.${this.rollParticipantSection}.${this.rollParticipantSubSection}`, this.data);
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.rollInstance.id);
if (this.rollInstance.isRendered) {
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.rollInstance.id);
}
}
refresh() {
const rollParticipantFlagData = this.rollInstance.data.rollParticipantData?.[this.rollParticipantSection];
Expand Down Expand Up @@ -1604,11 +1634,46 @@ class BladesRoll extends BladesTargetLink {
this.renderRollCollab_SocketResponse(rollInst.id);
}
_elem$;
_overlayPosition = { x: 200, y: 200 };
get overlayPosition() { return this._overlayPosition; }
set overlayPosition(val) { this._overlayPosition = val; }
_positionDragger;
get positionDragger() {
if (this._positionDragger) {
return this._positionDragger;
}
return this.spawnPositionDragger();
}
spawnPositionDragger() {
const self = this;
if (!this._elem$) {
throw new Error(`[BladesRoll.spawnPositionDragger] No elem$ found for roll ${this.id}.`);
}
return (this._positionDragger = new Dragger(this._elem$, {
type: "top,left",
trigger: ".window-header.draggable",
onDragStart() {
U.gsap.to(this.target, { opacity: 0.25, duration: 0.25, ease: "power2" });
},
onDragEnd() {
U.gsap.to(this.target, { opacity: 1, duration: 0.25, ease: "power2" });
self.overlayPosition = { x: this.endX, y: this.endY };
}
}));
}
get elem$() {
if (this._elem$) {
return this._elem$;
}
this._elem$ = $(`#${this.id}`) ?? $(`<div id="${this.id}" class="blades-roll-collab window-content"></div>`).appendTo("body");
this._positionDragger = undefined;
const elem$ = $(`#${this.id}`);
if (elem$.length) {
this._elem$ = elem$;
}
else {
this._elem$ = $(`<div id="${this.id}" class="app window-app ${C.SYSTEM_ID} sheet roll-collab${game.user.isGM ? " gm-roll-collab" : ""}"></div>`).appendTo("body");
}
this.spawnPositionDragger();
return this._elem$;
}
async renderRollCollab() {
Expand Down Expand Up @@ -1692,7 +1757,9 @@ class BladesRoll extends BladesTargetLink {
}
const rollParticipant = new BladesRollParticipant(this, rollSection, rollSubSection, participantData);
await rollParticipant.updateRollFlags();
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.id);
if (this.isRendered) {
socketlib.system.executeForEveryone("renderRollCollab_SocketCall", this.id);
}
}
async removeRollParticipant(rollSection, rollSubSection) {
await this.updateTarget(`rollParticipantData.${rollSection}.${rollSubSection}`, null);
Expand Down Expand Up @@ -2858,6 +2925,9 @@ class BladesRoll extends BladesTargetLink {
}
// #endregion
// #region *** ROLL COLLAB HTML ELEMENT ***
get isRendered() {
return Boolean(this._elem$?.length);
}
get collabTemplate() {
/* Subclass overrides determine template against which data is parsed */
throw new Error("[BladesRoll.collabTemplate] Unimplemented by Subclass.");
Expand Down
20 changes: 12 additions & 8 deletions module/core/debug.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// #region ▮▮▮▮▮▮▮ IMPORTS ▮▮▮▮▮▮▮ ~
import { RollPermissions, ActionTrait, RollPhase, Effect, RollType, Position } from "../core/constants.js";
import { BladesPC, BladesNPC } from "../documents/BladesActorProxy.js";
import { BladesRollPrimary } from "../classes/BladesRoll.js";
// #endregion ▮▮▮▮[IMPORTS]▮▮▮▮
import { BladesPC, BladesNPC, BladesFaction } from "../documents/BladesActorProxy.js";
import { BladesRollPrimary, BladesRollOpposition } from "../classes/BladesRoll.js";
class BladesDebug {
static async GetSampleSchemas() {
static async GetSampleSchemas(docNames = {}) {
// Documents
const SAMPLE_USER_NAME = "Alistair";
const SAMPLE_PC_NAME = "Alistair";
const SAMPLE_NPC_NAME = "Setarra";
const SAMPLE_USER_NAME = docNames.user || "Alistair";
const SAMPLE_PC_NAME = docNames.pc || "Alistair";
const SAMPLE_NPC_NAME = docNames.npc || "Setarra";
const SAMPLE_FACTION_NAME = docNames.faction || "the Bluecoats";
const sampleUser = game.users.getName(SAMPLE_USER_NAME);
if (!sampleUser) {
throw new Error(`Sample user with name "${SAMPLE_USER_NAME}" not found.`);
Expand All @@ -22,6 +22,10 @@ class BladesDebug {
if (!BladesNPC.IsType(sampleNPC)) {
throw new Error(`Sample BladesNPC with name "${SAMPLE_NPC_NAME}" not found or is not a valid BladesNPC.`);
}
const sampleFaction = game.actors.getName(SAMPLE_FACTION_NAME);
if (!BladesFaction.IsType(sampleFaction)) {
throw new Error(`Sample BladesFaction with name "${SAMPLE_FACTION_NAME}" not found or is not a valid BladesFaction.`);
}
// BladesActionRoll
const BladesActionRoll_Schema = {
rollType: RollType.Action,
Expand All @@ -32,7 +36,7 @@ class BladesDebug {
// rollDowntimeAction: DowntimeAction.AcquireAsset,
// rollClockKey: U.getLast(game.eunoblades.ClockKeys.contents)?.id,
rollPrimaryData: BladesRollPrimary.GetDataFromDoc(samplePC),
// rollOppData: sampleNPC,
rollOppData: BladesRollOpposition.GetDataFromDoc(sampleFaction),
// rollParticipantData: {},
// consequenceData: {},
// resistanceData: {
Expand Down
2 changes: 1 addition & 1 deletion module/documents/actors/BladesFaction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BladesActorType } from "../../core/constants.js";
import { BladesActor } from "../BladesActorProxy.js";
import BladesFactionSheet from "../../sheets/actor/BladesFactionSheet.js";
import BladesClockKey from "../../classes/BladesClocks.js";
import BladesClockKey from "../../classes/BladesClockKey.js";
class BladesFaction extends BladesActor {
// #region INITIALIZATION ~
static async Initialize() {
Expand Down
2 changes: 1 addition & 1 deletion module/documents/actors/BladesPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import U from "../../core/utilities.js";
import { BladesActor } from "../BladesActorProxy.js";
import BladesPCSheet from "../../sheets/actor/BladesPCSheet.js";
import { BladesItem } from "../BladesItemProxy.js";
import BladesClockKey from "../../classes/BladesClocks.js";
import BladesClockKey from "../../classes/BladesClockKey.js";
import BladesDirector from "../../classes/BladesDirector.js";
import { SelectionCategory } from "../../classes/BladesDialog.js";
class BladesPC extends BladesActor {
Expand Down
2 changes: 1 addition & 1 deletion module/documents/items/BladesClockKeeper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BladesItem } from "../BladesItemProxy.js";
import BladesClockKey from "../../classes/BladesClocks.js";
import BladesClockKey from "../../classes/BladesClockKey.js";
class BladesClockKeeper extends BladesItem {
static async Initialize() {
const clockKeeper = game.items.find((item) => item.type === "clock_keeper");
Expand Down
2 changes: 1 addition & 1 deletion module/documents/items/BladesProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BladesItemType, Factor, ClockColor, ClockKeyDisplayMode } from "../../c
import U from "../../core/utilities.js";
import { BladesItem } from "../BladesItemProxy.js";
import BladesProjectSheet from "../../sheets/item/BladesProjectSheet.js";
import BladesClockKey from "../../classes/BladesClocks.js";
import BladesClockKey from "../../classes/BladesClockKey.js";
class BladesProject extends BladesItem {
// #region INITIALIZATION ~
static async Initialize() {
Expand Down
Loading

0 comments on commit a556594

Please sign in to comment.