Skip to content

Commit

Permalink
Got moving on Consequences, transformations sorta done
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Feb 23, 2024
1 parent 0d0388c commit 98b636c
Show file tree
Hide file tree
Showing 13 changed files with 1,275 additions and 1,310 deletions.
8 changes: 3 additions & 5 deletions module/classes/BladesChat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// #region IMPORTS ~
import { ApplyTooltipAnimations, ApplyConsequenceAnimations } from "../core/gsap.js";
import { ApplyTooltipAnimations } from "../core/gsap.js";
import C, { RollType, Position, RollResult } from "../core/constants.js";
import U from "../core/utilities.js";
import BladesRoll from "./BladesRoll.js";
Expand All @@ -11,8 +11,7 @@ class BladesChat extends ChatMessage {
ApplyTooltipAnimations(html);
const { rollData } = msg.flagData;
if (rollData) {
ApplyConsequenceAnimations(html);
BladesConsequence.ApplyChatListeners(html);
BladesConsequence.ApplyChatListeners(msg);
}
html.addClass("display-ok");
});
Expand Down Expand Up @@ -157,8 +156,7 @@ class BladesChat extends ChatMessage {
return;
}
ApplyTooltipAnimations(this.elem$);
ApplyConsequenceAnimations(this.elem$);
BladesConsequence.ApplyChatListeners(this.elem$);
BladesConsequence.ApplyChatListeners(this);
if (this.parentRoll) {
this.elem$.addClass(`${this.parentRoll.rollType.toLowerCase()}-roll`);
if (this.parentRoll.rollType === RollType.Action && this.rollConsequences.some((csq) => !csq.isAccepted)) {
Expand Down
669 changes: 436 additions & 233 deletions module/classes/BladesConsequence.js

Large diffs are not rendered by default.

150 changes: 76 additions & 74 deletions module/classes/BladesDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import U from "../core/utilities.js";
import { BladesActor } from "../documents/BladesActorProxy.js";
import BladesItem from "../BladesItem.js";
import BladesRoll from "./BladesRoll.js";
import C, { RollResult, Position } from "../core/constants.js";
export var SelectionCategory;
(function (SelectionCategory) {
SelectionCategory["Heritage"] = "Heritage";
Expand Down Expand Up @@ -66,7 +65,7 @@ class BladesDialog extends Dialog {
icon: '<i class="fa-solid fa-arrow-down-to-arc"></i>',
label: "Apply",
callback: (html) => app
.writeToRollInstance(html)
// .writeToRollInstance(html as JQuery<HTMLElement>)
},
cancel: {
icon: '<i class="fas fa-times"></i>',
Expand Down Expand Up @@ -103,32 +102,32 @@ class BladesDialog extends Dialog {
});
return app.hasItems ? app.render(true, { width: app.width }) : undefined;
}
static async DisplayRollConsequenceDialog(rollInst) {
const app = new BladesDialog({
parent: rollInst,
title: "Consequences",
dialogType: BladesDialogType.Consequence,
content: "",
buttons: {
apply: {
icon: '<i class="fa-solid fa-arrow-down-to-arc"></i>',
label: "Apply",
callback: (html) => app
.writeToRollInstance(html)
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: game.i18n.localize("Cancel"),
callback: (html) => {
eLog.checkLog3("dialog", "Callback Scope", { this: app, html });
return false;
}
}
},
default: "apply"
}, { classes: ["eunos-blades", "sheet", "dialog", "consequence-dialog"] });
return app._render(true, { width: app.width }).then(() => eLog.checkLog3("dialog", "Dialog Instance", { this: app }));
}
// static async DisplayRollConsequenceDialog(rollInst: BladesRoll) {
// const app: BladesDialog = new BladesDialog({
// parent: rollInst,
// title: "Consequences",
// dialogType: BladesDialogType.Consequence,
// content: "",
// buttons: {
// apply: {
// icon: '<i class="fa-solid fa-arrow-down-to-arc"></i>',
// label: "Apply",
// callback: (html: HTMLElement|JQuery<HTMLElement>) => (app as BladesDialog)
// .writeToRollInstance(html as JQuery<HTMLElement>)
// },
// cancel: {
// icon: '<i class="fas fa-times"></i>',
// label: game.i18n.localize("Cancel"),
// callback: (html: JQuery|HTMLElement) => {
// eLog.checkLog3("dialog", "Callback Scope", {this: app, html});
// return false;
// }
// }
// },
// default: "apply"
// }, {classes: ["eunos-blades", "sheet", "dialog", "consequence-dialog"]});
// return app._render(true, {width: app.width}).then(() => eLog.checkLog3("dialog", "Dialog Instance", {this: app}));
// }
get template() { return `systems/eunos-blades/templates/dialog-${U.lCase(this.dialogType)}.hbs`; }
get hasItems() {
return Object.values(this.tabs ?? []).some((tabItems) => tabItems.length > 0);
Expand Down Expand Up @@ -257,21 +256,39 @@ class BladesDialog extends Dialog {
// eLog.checkLog3("dialog", "prepareConsequenceData", {outgoing: {...data}});
// return data;
// }
get consequenceTypeOptions() {
if (this.parent instanceof BladesRoll) {
const returnData = {};
[Position.controlled, Position.risky, Position.desperate].forEach((pos) => {
returnData[pos] = {
[RollResult.partial]: C.Consequences[pos][RollResult.partial]
.map((cType) => ({ value: cType, display: cType })),
[RollResult.fail]: C.Consequences[pos][RollResult.fail]
.map((cType) => ({ value: cType, display: cType }))
};
});
return returnData;
}
return {};
}
// get consequenceTypeOptions(): Record<
// Position,
// Record<
// RollResult.partial|RollResult.fail,
// Array<BladesSelectOption<string, ConsequenceType>>
// >
// > {
// if (this.parent instanceof BladesRoll) {
// const returnData: Partial<Record<
// Position,
// Record<
// RollResult.partial|RollResult.fail,
// Array<BladesSelectOption<string, ConsequenceType>>
// >
// >> = {};
// [Position.controlled, Position.risky, Position.desperate].forEach((pos) => {
// returnData[pos] = {
// [RollResult.partial]: C.Consequences[pos][RollResult.partial]
// .map((cType) => ({value: cType, display: cType})),
// [RollResult.fail]: C.Consequences[pos][RollResult.fail]
// .map((cType) => ({value: cType, display: cType}))
// };
// });
// return returnData as Record<
// Position,
// Record<
// RollResult.partial|RollResult.fail,
// Array<BladesSelectOption<string, ConsequenceType>>
// >
// >;
// }
// return {} as never;
// }
updateInputText(inputElem$) {
const value = inputElem$.val();
if (this.parent instanceof BladesRoll) {
Expand Down Expand Up @@ -444,12 +461,12 @@ class BladesDialog extends Dialog {
// this.render();
// }
// }
async writeToRollInstance(html) {
if (this.parent instanceof BladesRoll) {
// this.updateConsequenceDialog(html, false);
// await this.parent.updateTarget("consequenceData", this.csqData);
}
}
// async writeToRollInstance(html: JQuery<HTMLElement>) {
// if (this.parent instanceof BladesRoll) {
// this.updateConsequenceDialog(html, false);
// await this.parent.updateTarget("consequenceData", this.csqData);
// }
// }
// _consequenceAI?: BladesAI;
// getCsqDataFromElem(elem: HTMLElement, paramCount = 3): string[] {
// const dataAction = elem.dataset.action;
Expand Down Expand Up @@ -490,11 +507,11 @@ class BladesDialog extends Dialog {
// };
// this.render();
// }
async setFlagVal(target, value) {
if (this.parent instanceof BladesRoll) {
await this.parent.updateTarget(target, value);
}
}
// async setFlagVal(target: string, value: unknown) {
// if (this.parent instanceof BladesRoll) {
// await this.parent.updateTarget(target, value);
// }
// }
// async refreshResistanceOptions(rollPosition: Position, rollResult: RollResult, cID: string, rOptions: string[]) {
// if (!this.csqData) { return; }
// const cData = this.csqData[rollPosition][rollResult as RollResult.partial|RollResult.fail][cID];
Expand Down Expand Up @@ -583,11 +600,11 @@ class BladesDialog extends Dialog {
case BladesDialogType.Selection:
this.activateSelectionListeners(html);
break;
case BladesDialogType.Consequence: {
this.activateConsequenceListeners(html);
// Select --> updateConsequenceDialog -> updateConsequenceData(each csq)
break;
}
// case BladesDialogType.Consequence: {
// this.activateConsequenceListeners(html);
// Select --> updateConsequenceDialog -> updateConsequenceData(each csq)
// break;
// }
}
}
activateInputListeners(html) {
Expand Down Expand Up @@ -626,20 +643,5 @@ class BladesDialog extends Dialog {
$("#eunos-blades-tooltips > *").remove();
super.close();
}
activateConsequenceListeners(html) {
// html.find("input").on({change: () => this.updateConsequenceDialog(html)});
// html.find("select").on({change: () => this.updateConsequenceDialog(html)});
// html.find('[data-action^="ai-query"]').on({
// click: (event) => this.queryAI(event),
// contextmenu: (event) => this.clearResistOptions(event)
// });
// html.find('[data-action^="blank-option"]').on({
// click: (event) => this.spawnBlankResistOption(event),
// contextmenu: (event) => this.clearResistOptions(event)
// });
// html.find('[data-action^="gm-select-toggle"]').on({click: (event) => this.selectResistOption(event) });
// html.find('[data-action^="toggle-armor"]').on({click: (event) => this.toggleArmor(event) });
// html.find('[data-action^="toggle-special"]').on({click: (event) => this.toggleSpecialArmor(event) });
}
}
export default BladesDialog;
Loading

0 comments on commit 98b636c

Please sign in to comment.