Skip to content

Commit

Permalink
(amend)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Sep 23, 2023
1 parent 1a304c1 commit 424be2a
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 99 deletions.
29 changes: 6 additions & 23 deletions ts/blades-active-effect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BladesActor from "./blades-actor.js";
import U from "./core/utilities.js";
import BladesItem from "./blades-item.js";
import {Tag, BladesPhase, BladesActorType, BladesItemType, Attribute, InsightActions, ProwessActions, ResolveActions} from "./core/constants.js";
import {Tag, BladesPhase, BladesActorType} from "./core/constants.js";

const FUNCQUEUE: Record<string, {
curFunc: Promise<void>,
Expand All @@ -15,10 +15,8 @@ const CUSTOMFUNCS: Record<string, (actor: BladesActor, funcData: string, effect:
if (isReversing) {
return actor.remSubItem(funcData);
}
} else {
if (!isReversing) {
return actor.addSubItem(funcData);
}
} else if (!isReversing) {
return actor.addSubItem(funcData);
}
return undefined;
},
Expand Down Expand Up @@ -104,16 +102,6 @@ type BladesCustomFuncData = {
effect: BladesActiveEffect
}

// type BladesCustomFuncParams = Parameters<ValueOf<typeof CUSTOMFUNCS>>[1];

// type BladesCustomFunc = (actor: BladesActor, params: BladesCustomFuncParams) => Promise<void>;
// type BladesCustomResult = ReturnType<BladesCustomFunc>;

// type BladesCustomEffectData = {
// func: BladesCustomFuncName,
// params: BladesCustomFuncParams
// }

class BladesActiveEffect extends ActiveEffect {
static Initialize() {
CONFIG.ActiveEffect.documentClass = BladesActiveEffect;
Expand Down Expand Up @@ -184,14 +172,9 @@ class BladesActiveEffect extends ActiveEffect {
effect
};
BladesActiveEffect.ThrottleCustomFunc(effect.parent as BladesActor, funcData);
} else {
switch(permFuncName) {
case "Add": {
const [target, qty] = value.split(/:/);
(<BladesActor>effect.parent).update({[target]: U.pInt(getProperty(<BladesActor>effect.parent, target)) + U.pInt(qty)});
}
// no default
}
} else if (permFuncName === "Add") {
const [target, qty] = value.split(/:/);
(<BladesActor>effect.parent).update({[target]: U.pInt(getProperty(<BladesActor>effect.parent, target)) + U.pInt(qty)});
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions ts/blades-dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import G, {ApplyTooltipListeners} from "./core/gsap.js";
import {ApplyTooltipListeners} from "./core/gsap.js";
import U from "./core/utilities.js";
import BladesActor from "./blades-actor.js";
import BladesItem from "./blades-item.js";
Expand Down Expand Up @@ -52,7 +52,7 @@ class BladesSelectorDialog extends Dialog {
tabs: Record<string, BladesActor[]|BladesItem[]>,
tags?: string[]
) {
// eLog.checkLog("BladesSelectorDialog.Display()", {parent, title, tabs});

const app = new BladesSelectorDialog({
parent,
title,
Expand Down Expand Up @@ -108,13 +108,13 @@ class BladesSelectorDialog extends Dialog {

override getData() {
const data = super.getData() as BladesDialog.Data;
// eLog.checkLog4("dialog", "[BladesDialog] super.getData()", {...data});

data.title = this.title;
data.tabs = this.tabs;
data.docType = this.docType;
data.tags = this.tags;

// eLog.checkLog("dialog", "[BladesDialog] return getData()", {...data});

return data;
}

Expand Down
10 changes: 5 additions & 5 deletions ts/blades-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ class BladesItem extends Item implements BladesDocument<Item>,
if (/^s.*ame/i.test(keyString)) { key = "source_name" } else
if (/^tool|^tip/i.test(keyString)) { key = "tooltip" } else
if (/^ty/i.test(keyString)) { key = "modType" } else
if (/^c.*r?.*ty/i.test(keyString)) { key = "conditionalRollTypes" } else
if (/^a.*r?.*y/i.test(keyString)) { key = "autoRollTypes" } else
if (/^c.*r?.*tr/i.test(keyString)) { key = "conditionalRollTraits" } else
if (/^a.*r?.*tr/i.test(keyString)) { key = "autoRollTraits" } else {
if (/^c.{0,10}r?.{0,3}ty/i.test(keyString)) {key = "conditionalRollTypes"} else
if (/^a.{0,3}r?.{0,3}y/i.test(keyString)) {key = "autoRollTypes"} else
if (/^c.{0,10}r?.{0,3}tr/i.test(keyString)) {key = "conditionalRollTraits"} else
if (/^a.{0,3}r?.{0,3}tr/i.test(keyString)) {key = "autoRollTraits"} else {
throw new Error(`Bad Roll Mod Key: ${keyString}`);
}

Expand Down Expand Up @@ -345,7 +345,7 @@ class BladesItem extends Item implements BladesDocument<Item>,
system.subtitle = C.ScaleSizes[scaleIndex];
}
if (subtypes.length + elite_subtypes.length === 0) {
system.subtitle = system.subtitle.replace(/\s+of\s*/g, "");
system.subtitle = system.subtitle.replace(/\s+of\b/g, "").trim();
}
} else {
system.scale = 0;
Expand Down
2 changes: 1 addition & 1 deletion ts/blades-push-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class BladesPushController {
pushToSome(...args: [string, string, string|undefined, User[]]) {
const users = (args.pop() as User[]).map((user) => user.id!);
const pushArgs = args.slice(0, 3) as [string, string, string|undefined];
socketlib.system.executeForUsers("pushNotice", users, "", ...args);
socketlib.system.executeForUsers("pushNotice", users, "", ...pushArgs);
}

pushToGM(...args: [string, string, string|undefined]) {
Expand Down
7 changes: 1 addition & 6 deletions ts/documents/actors/blades-faction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import BladesItem from "../../blades-item.js";
import C, {SVGDATA, BladesActorType, BladesItemType, Tag, BladesPhase, RollModCategory, PrereqType, Factor, RollModStatus} from "../../core/constants.js";
import U from "../../core/utilities.js";
import {BladesActorType, Factor} from "../../core/constants.js";
import BladesActor from "../../blades-actor.js";
import BladesRollCollab from "../../blades-roll-collab.js";
import type {ItemDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData.js";
import type {ActorData, ActorDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/actorData.js";

const JSONDATA: {FACTIONS: Record<string,any>} = {
FACTIONS: {
Expand Down
6 changes: 1 addition & 5 deletions ts/documents/actors/blades-npc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import BladesItem from "../../blades-item.js";
import C, {SVGDATA, BladesActorType, BladesItemType, Tag, BladesPhase, RollModCategory, PrereqType, Factor, RollModStatus} from "../../core/constants.js";
import U from "../../core/utilities.js";
import {BladesActorType, Factor} from "../../core/constants.js";
import BladesActor from "../../blades-actor.js";
import BladesRollCollab from "../../blades-roll-collab.js";
import type {ItemDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData.js";
import type {ActorData, ActorDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/actorData.js";

class BladesNPC extends BladesActor implements BladesActorSubClass.NPC,
BladesRollCollab.OppositionDocData,
Expand Down
21 changes: 4 additions & 17 deletions ts/documents/items/blades-clock-keeper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import BladesItem from "../../blades-item.js";
import C, {SVGDATA, BladesActorType, BladesItemType, Tag, BladesPhase, RollModCategory, PrereqType, Factor, RollModStatus} from "../../core/constants.js";
import C, {SVGDATA, BladesActorType, BladesItemType} from "../../core/constants.js";
import U from "../../core/utilities.js";
import BladesActor from "../../blades-actor.js";
import BladesRollCollab from "../../blades-roll-collab.js";
import type {ItemDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData.js";

class BladesClockKeeper extends BladesItem implements BladesItemSubClass.Clock_Keeper {

Expand Down Expand Up @@ -60,19 +58,8 @@ class BladesClockKeeper extends BladesItem implements BladesItemSubClass.Clock_K
await game.eunoblades.ClockKeeper.update({
[`system.clock_keys.${keyID}.clocks.${clockNum}.value`]: `${newClockVal}`
});
// socketlib.system.executeForEveryone("renderOverlay");
});

// .on({
// mouseenter: function() {
// $(this).parent().css("z-index", 1);
// $(this).data("hoverTimeline").play();
// },
// mouseleave: function() {
// $(this).data("hoverTimeline").reverse().then(() => {
// $(this).parent().removeAttr("style");
// });
// }
$("#clocks-overlay").find(".key-label").on({
click: async (event) => {
if (!event.currentTarget) { return }
Expand All @@ -86,7 +73,7 @@ class BladesClockKeeper extends BladesItem implements BladesItemSubClass.Clock_K
update: !(game.eunoblades.ClockKeeper.system.clock_keys[keyID]?.isActive)
});
await game.eunoblades.ClockKeeper.update({[`system.clock_keys.${keyID}.isActive`]: !(game.eunoblades.ClockKeeper.system.clock_keys[keyID]?.isActive)});
// socketlib.system.executeForEveryone("renderOverlay");

},
contextmenu: () => {
if (!game.user.isGM) { return }
Expand Down Expand Up @@ -153,7 +140,7 @@ class BladesClockKeeper extends BladesItem implements BladesItemSubClass.Clock_K
}
eLog.checkLog("clock_key", "Clock Key Update Data", {clockKey, updateData});
return game.eunoblades.ClockKeeper.update(updateData);
// return socketlib.system.executeForEveryone("renderOverlay");

}
// #endregion

Expand All @@ -164,7 +151,7 @@ class BladesClockKeeper extends BladesItem implements BladesItemSubClass.Clock_K
this.system.scenes = game.scenes.map((scene) => ({id: scene.id, name: scene.name ?? ""}));
this.system.targetScene ??= game.scenes.current?.id || null;
this.system.clock_keys = Object.fromEntries(Object.entries(this.system.clock_keys ?? {})
.filter(([_, keyData]) => keyData && keyData.id)
.filter(([_, keyData]) => keyData?.id)
.map(([keyID, keyData]) => {
if (keyData === null) { return [keyID, null] }
keyData.clocks = Object.fromEntries(Object.entries(keyData.clocks ?? {})
Expand Down
5 changes: 1 addition & 4 deletions ts/documents/items/blades-gm-tracker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import BladesItem from "../../blades-item.js";
import C, {SVGDATA, BladesActorType, BladesItemType, Tag, BladesPhase, RollModCategory, PrereqType, Factor, RollModStatus} from "../../core/constants.js";
import U from "../../core/utilities.js";
import {BladesActorType, BladesItemType, BladesPhase} from "../../core/constants.js";
import BladesActor from "../../blades-actor.js";
import BladesRollCollab from "../../blades-roll-collab.js";
import type {ItemDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData.js";

class BladesGMTracker extends BladesItem implements BladesItemSubClass.Gm_Tracker {

Expand Down
3 changes: 1 addition & 2 deletions ts/documents/items/blades-location.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import BladesItem from "../../blades-item.js";
import C, {SVGDATA, BladesActorType, BladesItemType, Tag, BladesPhase, RollModCategory, PrereqType, Factor, RollModStatus} from "../../core/constants.js";
import {BladesActorType, BladesItemType, Factor} from "../../core/constants.js";
import U from "../../core/utilities.js";
import BladesActor from "../../blades-actor.js";
import BladesRollCollab from "../../blades-roll-collab.js";
import type {ItemDataConstructorData} from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/itemData.js";

class BladesLocation extends BladesItem implements BladesItemSubClass.Location,
BladesRollCollab.OppositionDocData {
Expand Down
7 changes: 0 additions & 7 deletions ts/sheets/actor/blades-crew-sheet.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import U from "../../core/utilities.js";
import BladesSheet from "./blades-sheet.js";
import BladesActor from "../../blades-actor.js";
import BladesPC from "../../documents/actors/blades-pc.js";
import {BladesCrew} from "../../documents/blades-actor-proxy.js";
import BladesNPC from "../../documents/actors/blades-npc.js";
import BladesFaction from "../../documents/actors/blades-faction.js";
// import BladesCrew from "../../documents/actors/blades-crew.js";
import BladesItem from "../../blades-item.js";
import {BladesActorType, BladesItemType} from "../../core/constants.js";

class BladesCrewSheet extends BladesSheet {
Expand Down
2 changes: 0 additions & 2 deletions ts/sheets/item/blades-clock-keeper-sheet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

import {BladesItemType} from "../../core/constants.js";
import BladesItemSheet from "./blades-item-sheet.js";
import BladesItem from "../../blades-item.js";
import BladesClockKeeper from "../../documents/items/blades-clock-keeper.js";

type BladesClockKeeperSheetData = Partial<BladesItemSheetData> & {
Expand Down
5 changes: 1 addition & 4 deletions ts/sheets/item/blades-item-sheet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import C, {BladesActorType, BladesItemType, BladesPhase, Tag, Factor} from "../../core/constants.js";
import C, {BladesItemType, BladesPhase, Factor} from "../../core/constants.js";
import U from "../../core/utilities.js";
import G, {ApplyTooltipListeners} from "../../core/gsap.js";
import BladesActor from "../../blades-actor.js";
Expand Down Expand Up @@ -129,9 +129,6 @@ class BladesItemSheet extends ItemSheet {
[...Object.values(context.system.experience_clues ?? []).filter((clue) => /[A-Za-z]/.test(clue)), " "].forEach((clue, i) => { expClueData[(i + 1).toString()] = clue });
context.system.experience_clues = expClueData as any;
}
// if (!context.isGM && context.system.experience_clues) {
// delete context.system.experience_clues[Object.keys(context.system.experience_clues).length];
// }
const sheetData: BladesItemDataOfType<BladesItemType.crew_playbook> = {
};
return {
Expand Down
20 changes: 1 addition & 19 deletions ts/sheets/item/blades-tracker-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import BladesItem from "../../blades-item.js";
import BladesGMTracker from "../../documents/items/blades-gm-tracker.js";
import BladesActor from "../../blades-actor.js";
import BladesPC from "../../documents/actors/blades-pc.js";
import BladesNPC from "../../documents/actors/blades-npc.js";
import BladesFaction from "../../documents/actors/blades-faction.js";
import BladesCrew from "../../documents/actors/blades-crew.js";


export enum BladesTipContext {
Expand Down Expand Up @@ -59,13 +56,7 @@ class BladesTipGenerator {


}
// declare interface BladesTrackerSheet {
// get type(): BladesItemType.gm_tracker,
// parent: null,
// system: BladesItem["system"] & {
// game_phase: BladesPhase;
// }
// }

class BladesTrackerSheet extends BladesItemSheet {

static Get() { return game.eunoblades.Tracker as BladesGMTracker }
Expand Down Expand Up @@ -98,15 +89,6 @@ class BladesTrackerSheet extends BladesItemSheet {
]);
}

// override getData() {
// const context: any = super.getData() as ReturnType<BladesItemSheet["getData"]> & {system: any}

// context.system.phases = Object.values(BladesPhase);

// return context;
// }


override async activateListeners(html: JQuery<HTMLElement>) {
super.activateListeners(html);

Expand Down

0 comments on commit 424be2a

Please sign in to comment.