Skip to content

Commit

Permalink
God sometimes I hate TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunomiac committed Jan 27, 2024
1 parent 24a99c8 commit 31268ac
Show file tree
Hide file tree
Showing 24 changed files with 734 additions and 658 deletions.
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action-acquireasset.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-result-{{rollResult}} roll-downtime-action-{{case "lower" rollDowntimeAction}}"
data-chat-id="{{chatMsgID}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{flagData.rollUserID}}"
data-primary-id="{{flagData.rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{flagData.rollPrimaryData.rollPrimaryType}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action-clock-recover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-position-{{finalPosition}} roll-effect-{{finalEffect}} roll-result-{{rollResult}}"
data-chat-id="{{chatMsgID}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{flagData.rollUserID}}"
data-primary-id="{{flagData.rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{flagData.rollPrimaryData.rollPrimaryType}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action-clock.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-position-{{finalPosition}} roll-effect-{{finalEffect}} roll-result-{{rollResult}}"
data-chat-id="{{chatMsgID}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{flagData.rollUserID}}"
data-primary-id="{{flagData.rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{flagData.rollPrimaryData.rollPrimaryType}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action-gatherinfo.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-position-{{finalPosition}} roll-effect-{{finalEffect}} roll-result-{{rollResult}}"
data-chat-id="{{chatMsgID}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{flagData.rollUserID}}"
data-primary-id="{{flagData.rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{flagData.rollPrimaryData.rollPrimaryType}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action-reduceheat.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-position-{{finalPosition}} roll-effect-{{finalEffect}} roll-result-{{rollResult}}"
data-chat-id="{{chatMsgID}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{flagData.rollUserID}}"
data-primary-id="{{flagData.rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{flagData.rollPrimaryData.rollPrimaryType}}"
Expand Down
2 changes: 1 addition & 1 deletion templates/chat/roll-result/action.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{eLog "CHAT ACTION ROLL RESULT CONTEXT" this}}

<div class="blades-roll roll-type-{{case "lower" rollType}} roll-position-{{finalPosition}} roll-effect-{{finalEffect}} roll-result-{{rollResult}}"
data-roll-id="{{rollID}}"
data-roll-id="{{id}}"
data-user-id="{{rollUserID}}"
data-primary-id="{{rollPrimaryData.rollPrimaryID}}"
data-primary-type="{{rollPrimaryData.rollPrimaryType}}"
Expand Down
4 changes: 2 additions & 2 deletions templates/roll/partials/roll-collab-action.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{rollID}}">
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{id}}">
<div class="roll-type-header">{{rollType}} Roll</div>
</section>

Expand Down Expand Up @@ -327,7 +327,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
4 changes: 2 additions & 2 deletions templates/roll/partials/roll-collab-fortune-gm.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{rollID}}">
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{id}}">
<div class="roll-type-header">{{rollType}} Roll</div>
</section>

Expand Down Expand Up @@ -190,7 +190,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
4 changes: 2 additions & 2 deletions templates/roll/partials/roll-collab-fortune.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{rollID}}">
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{id}}">
<div class="roll-type-header">{{rollType}} Roll</div>
</section>

Expand Down Expand Up @@ -323,7 +323,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
4 changes: 2 additions & 2 deletions templates/roll/partials/roll-collab-indulgevice-gm.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{rollID}}">
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{id}}">
<div class="roll-type-header">{{rollType}} Roll</div>
</section>

Expand Down Expand Up @@ -190,7 +190,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
4 changes: 2 additions & 2 deletions templates/roll/partials/roll-collab-indulgevice.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{rollID}}">
<section class="sheet-topper roll-type roll-type-{{case "lower" rollType}}" data-roll-id="{{id}}">
<div class="roll-type-header">{{rollType}} Roll</div>
</section>

Expand Down Expand Up @@ -323,7 +323,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
2 changes: 1 addition & 1 deletion templates/roll/partials/roll-collab-resistance.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<div class="roll-odds-label-text">Waiting For GM ...</div>
</div>
{{else if (test rollPhase "==" "AwaitingRoll")}}
<button class="roll-button" data-action="roll" data-roll-id="{{rollID}}">ROLL</button>
<button class="roll-button" data-action="roll" data-roll-id="{{id}}">ROLL</button>
{{/if}}
</div>
{{#if costData}}
Expand Down
10 changes: 8 additions & 2 deletions ts/@types/blades-general-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {AttributeTrait, ActionTrait, District} from "../core/constants";
import BladesItem from "../BladesItem";
import BladesActor from "../BladesActor";
import BladesChat from "../classes/BladesChat";
import BladesClockKey, {BladesClock} from "../classes/BladesClocks";
import BladesConsequence from "../classes/BladesConsequence";
import BladesRoll, {BladesRollMod} from "../classes/BladesRoll";
import {gsap} from "gsap/all";


Expand Down Expand Up @@ -132,10 +135,13 @@ declare global {
type gsapAnim = gsap.core.Tween | gsap.core.Timeline;

// Represents a generic Blades document
type BladesDoc = BladesActor | BladesItem | BladesChat;
type BladesDoc = BladesActor | BladesItem;

// Represents any Blades document sheet
type BladesSheet = BladesActorSheet | BladesItemSheet | BladesRoll;
type BladesSheet = BladesActorSheet | BladesItemSheet;

// Represents any document that can be the target of a BladesTargetLink subclass.
type BladesLinkDoc = BladesDoc | BladesChat | User;

// Represents a reference to a Blades document
type DocRef = string | BladesDoc;
Expand Down
22 changes: 13 additions & 9 deletions ts/@types/blades-roll.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ declare global {

namespace BladesRollMod {

// export type Value = string|number|string[];

export type Schema = {
key: string,
name: string,
Expand Down Expand Up @@ -43,22 +45,22 @@ declare global {

namespace BladesRoll {

export interface Config extends BladesTargetLink.Config {
rollType: RollType,
export interface Config extends Partial<BladesTargetLink.Config> {
rollType?: RollType,
rollSubType?: RollSubType,
rollUserID: IDString,
rollUserID?: IDString,
rollTrait?: RollTrait,
rollDowntimeAction?: DowntimeAction,
rollClockKey?: IDString|BladesClockKey,
rollClockKeyID?: IDString,

rollPrimaryData: PrimaryDocData;
rollPrimaryData?: PrimaryDocData;
rollOppData?: OppositionDocData;
rollParticipantData?: RollParticipantData,
rollParticipantData?: RollParticipantDataSet,

participantRollTo?: string,
resistanceRollTo?: {
rollID: string,
id: string,
userID: string,
consequenceID: string
},
Expand All @@ -74,7 +76,9 @@ declare global {
>>,
resistanceData?: {
consequence: BladesConsequence.Data
}
},

userPermissions?: Record<IDString, RollPermissions>
}

export interface Schema extends Omit<Config, "rollClockKey"|"rollPrimaryData"|"rollOppData"|"rollParticipantData"> {
Expand All @@ -99,7 +103,7 @@ declare global {
Partial<Record<Factor, FactorFlagData>>
>,

userPermissions: Record<string, RollPermissions>,
userPermissions: Record<IDString, RollPermissions>,

template?: string,
finalPosition?: Position,
Expand Down Expand Up @@ -319,7 +323,7 @@ declare global {
export type ParticipantConstructorData = ParticipantSectionData & Partial<ParticipantDocData>;


export interface RollParticipantData {
export interface RollParticipantDataSet {
[RollModSection.roll]?: {
Assist?: ParticipantDocData & ParticipantSectionData,
Group_1?: ParticipantDocData & ParticipantSectionData,
Expand Down
11 changes: 5 additions & 6 deletions ts/@types/blades-target-link.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import BladesNPC from "../documents/actors/BladesNPC";
import BladesFaction from "../documents/actors/BladesFaction";
import BladesCrew from "../documents/actors/BladesCrew";
import BladesTargetLink from "../classes/BladesTargetLink";
import BladesChat from "../classes/BladesChat";


declare global {
Expand All @@ -13,13 +14,11 @@ declare global {

namespace BladesTargetLink {

export type UnknownSchema = Record<any, any>;

export type StaticThisContext<Schema extends UnknownSchema> = typeof BladesTargetLink
export type StaticThisContext<Schema> = typeof BladesTargetLink
& (new (data: Data & Schema) => BladesTargetLink & Subclass<Schema>);

export type Config = {
target?: IDString|UUIDString|BladesDoc,
target?: IDString|UUIDString|BladesDoc|BladesChat|User,
targetID?: IDString|UUIDString,
targetKey?: TargetKey,
targetFlagKey?: TargetFlagKey
Expand All @@ -33,10 +32,10 @@ declare global {
}

export type Instance = Data & {
target: BladesDoc
target: BladesDoc|BladesChat|User
}

export interface Subclass<Schema extends UnknownSchema> extends Instance {
export interface Subclass<Schema> extends Instance {

data: Data & Schema,

Expand Down
9 changes: 1 addition & 8 deletions ts/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ declare global {
ClockKeeper: BladesClockKeeper,
Director: BladesDirector,
Tracker: BladesGMTracker,
Rolls: Collection<BladesRoll>,
ClockKeys: Collection<BladesClockKey>,
Consequences: Collection<BladesConsequence>,
Tooltips: WeakMap<HTMLElement, gsap.core.Timeline>
Expand Down Expand Up @@ -97,14 +98,6 @@ declare global {
}
interface LenientGlobalVariableTypes { game: never }

interface FlagConfig {
User: {
[C.SYSTEM_ID]?: {
rollCollab?: BladesRoll.FlagData
}
};
}

// GreenSock Accessor Object
declare const gsap: gsap;
type BladesTweenTarget = JQuery<HTMLElement> | gsap.TweenTarget;
Expand Down
1 change: 1 addition & 0 deletions ts/blades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ class GlobalGetter {
Hooks.once("init", async () => {
// Initialize Game object
game.eunoblades = {
Rolls: new Collection<BladesRoll>(),
ClockKeys: new Collection<BladesClockKey>(),
Consequences: new Collection<BladesConsequence>(),
Director: BladesDirector.getInstance(),
Expand Down
Loading

0 comments on commit 31268ac

Please sign in to comment.