Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foe actor drag and drop #768

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a5da9ba
add foe drag behavior
rsek May 21, 2023
b711a49
multiple types for DropTarget
rsek May 22, 2023
3f47a21
set pointers from encounter items to foe actors
rsek May 22, 2023
8f120d8
regen DB with missing icons
rsek May 22, 2023
f4bb3eb
update db metadta. rm old dbs
rsek May 22, 2023
a1f44d2
rename remaining foe packs to avoid link migration
rsek May 22, 2023
5914461
rm migration that i didn't end up adding
rsek May 22, 2023
316fc0e
adjust build script. dfid property for Foes
rsek May 22, 2023
3ecc9a9
standardize dfid on imports
rsek May 22, 2023
c68002b
clean up imports
rsek May 22, 2023
29f157b
adjust propagation/inheritance of foe description
rsek May 22, 2023
315e113
rebuild dbs without repeated descriptions
rsek May 22, 2023
0328ea6
adjust pack labels
rsek May 22, 2023
24b223a
foe index fields
rsek May 22, 2023
99e9670
make foe progress the "SSoT" for most attrs
rsek May 22, 2023
8ba8db7
DRYer encounter data builder
rsek May 22, 2023
d90e098
clean up index fields
rsek May 22, 2023
7be3733
add IS encounters to key map
rsek May 22, 2023
301805e
starforged actor pack ID
rsek May 22, 2023
2363f03
rm unused default
rsek May 22, 2023
2516891
mv description to progress tracks
rsek May 22, 2023
d34780d
group ironsworn processors together
rsek May 22, 2023
ea8774b
patch: incorrect typing for _onDrop*
rsek May 22, 2023
653e344
add Actor flag config
rsek May 22, 2023
2e539a4
clean up imports + types
rsek May 22, 2023
55c0cb1
Merge branch 'main' into foe-drag-and-drop
rsek May 29, 2023
554be4d
Merge branch 'main' into foe-drag-and-drop
rsek Jun 25, 2023
a9f2dc5
adjust import
rsek Jun 25, 2023
963927e
organize imports, update types
rsek Jun 25, 2023
e538f0f
add lib so we can use replaceAll
rsek Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
diff --git a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/apps/forms/actor.d.ts b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/apps/forms/actor.d.ts
index ab8be64..b10d652 100644
--- a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/apps/forms/actor.d.ts
+++ b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/apps/forms/actor.d.ts
@@ -87,7 +87,7 @@ declare global {
protected _onDropActiveEffect(event: DragEvent, data: ActorSheet.DropData.ActiveEffect): Promise<unknown>;

/**
- * Handle dropping of an item reference or item data onto an Actor Sheet
+ * Handle dropping of an actor reference or actor data onto an Actor Sheet
* @param event - The concluding DragEvent which contains drop data
* @param data - The data transfer extracted from the event
* @returns A data object which describes the result of the drop
diff --git a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/config.d.ts b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/config.d.ts
index da561df..3665779 100644
--- a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/config.d.ts
+++ b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/config.d.ts
@@ -128,6 +128,9 @@ declare global {

/** @defaultValue `{}` */
typeLabels: Record<string, string>;
+
+ /** @defaultValue `{}` */
+ typeIcons: Record<string, string>;
};

/**
@@ -332,6 +335,9 @@ declare global {

/** @defaultValue `{}` */
typeLabels: Record<string, string>;
+
+ /** @defaultValue `{}` */
+ typeIcons: Record<string, string>;
};

/**
@@ -1485,6 +1491,7 @@ declare global {
};
defaultType: "text";
sidebarIcon: "fas fa-book-open";
+ coreTypes: ["image", "pdf", "text", "video"]
};

/**
diff --git a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/data/documents/table.d.ts b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/client/data/documents/table.d.ts
index ca6d3f2..34792e6 100644
Expand All @@ -40,35 +53,35 @@ index ca6d3f2..34792e6 100644
*/
- roll: Roll;
+ roll?: Roll;

/**
* Allow drawing recursively from inner RollTable results
* @defaultValue `true`
*/
- recursive: boolean;
+ recursive?: boolean;

/**
* One or more table results which have been drawn
* @defaultValue `[]`
*/
- results: foundry.data.TableResultData[];
+ results?: foundry.data.TableResultData[];

/**
* Whether to automatically display the results in chat
* @defaultValue `true`
*/
- displayChat: boolean;
+ displayChat?: boolean;

/**
* The chat roll mode to use when displaying the result
*/
- rollMode: keyof CONFIG.Dice.RollModes | "roll";
+ rollMode?: keyof CONFIG.Dice.RollModes | "roll";
}

/**
diff --git a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/journalEntryPageData.d.ts b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/data/data.mjs/journalEntryPageData.d.ts
index e1da7b2..c865bb4 100644
Expand All @@ -77,27 +90,27 @@ index e1da7b2..c865bb4 100644
@@ -165,9 +165,12 @@ declare global {
*/
name: string;

+
/**
* The type of this page, in {@link BaseJournalEntryPage.TYPES}.
*/
+ type: ValueOf<typeof foundry.documents.BaseJournalEntryPage.TYPES>
+
content: ValueOf<typeof foundry.CONST.JOURNAL_ENTRY_PAGE_FORMATS>;

/**
@@ -217,6 +220,7 @@ declare global {
* @defaultValue `{}`
*/
flags: ConfiguredFlags<"JournalEntryPage">;
+
}

namespace JournalEntryPageDataProperties {
@@ -315,4 +319,10 @@ export class JournalEntryPageData extends DocumentData<
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface JournalEntryPageData extends JournalEntryPageDataProperties {}
+export interface JournalEntryPageData extends JournalEntryPageDataProperties {
Expand All @@ -118,10 +131,10 @@ index 25cb406..ce8ce9b 100644
+ isEmbedded: true
}
>;

@@ -43,4 +44,24 @@ export declare class BaseJournalEntryPage extends Document<
static get TYPES(): DocumentSubTypes<"JournalEntryPage">[];

getUserLevel(user: BaseUser): ValueOf<typeof CONST.DOCUMENT_OWNERSHIP_LEVELS> | null;
+
+ /**
Expand Down Expand Up @@ -158,7 +171,7 @@ index eb3fa4c..f45b1d5 100644
+>
+ ? InstanceType<ConfiguredDocumentClassForName<T>>["type"]
: typeof foundry.CONST.BASE_DOCUMENT_TYPE;

export type ConfiguredDocumentClassForName<Name extends DocumentType> = CONFIG[Name]["documentClass"];
diff --git a/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/types/utils.d.ts b/node_modules/@league-of-foundry-developers/foundry-vtt-types/src/types/utils.d.ts
index 8cc4b52..197c630 100644
Expand Down Expand Up @@ -188,5 +201,5 @@ index 8cc4b52..197c630 100644
+ } )
+ : T[P];
};

/**
9 changes: 7 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ import {
registerOracleTree
} from './module/features/customoracles'
import { OracleTable } from './module/roll-table/oracle-table'
import type { ConfiguredData } from '@league-of-foundry-developers/foundry-vtt-types/src/types/helperTypes'

export type SystemSubtype = ConfiguredData<
'Actor' | 'Item' | 'JournalEntryPage'
>['type']

export interface EmitterEvents extends Record<EventType, unknown> {
highlightMove: string // Foundry UUID
highlightOracle: string // DF ID
globalConditionChanged: { name: string; enabled: boolean } // info about condition that changed
dragStart: string // type of item
dragEnd: string // type of item
dragStart: SystemSubtype // type of item
dragEnd: SystemSubtype // type of item
}
export type IronswornEmitter = Emitter<EmitterEvents>

Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Hooks.once('init', async () => {
CONFIG.RollTable.resultIcon = 'icons/dice/d10black.svg'
CONFIG.TableResult.documentClass = OracleTableResult

// configure index fields
CONFIG.Actor.compendiumIndexFields.push('system.dfid')

// CONFIG.RollTable.resultTemplate =
// 'systems/foundry-ironsworn/templates/rolls/oracle-roll-message.hbs'

Expand Down
18 changes: 13 additions & 5 deletions src/module/actor/sheets/sitesheet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { VueActorSheet } from '../../vue/vueactorsheet'
import siteSheetVue from '../../vue/site-sheet.vue'

export class IronswornSiteSheet extends VueActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
Expand All @@ -10,6 +9,15 @@ export class IronswornSiteSheet extends VueActorSheet {
}) as any
}

async _onDropActor(event: DragEvent, data: ActorSheet.DropData.Actor) {
// Fetch the actor. We only want to override denizens (foe-type actors)
const droppedActor = await Actor.fromDropData(data as any)
if (droppedActor == null) return false
if (droppedActor.type !== 'foe') {
return await super._onDropActor(event, data)
}
}

async _onDropItem(event: DragEvent, data: ActorSheet.DropData.Item) {
if (!this.actor.assert('site'))
throw new Error(
Expand All @@ -27,13 +35,13 @@ export class IronswornSiteSheet extends VueActorSheet {
'.ironsworn__denizen__drop'
)[0]
if (dropTarget == null) return false
const idx = parseInt(dropTarget.dataset.idx || '')
const { denizens } = this.actor.system
const idx = parseInt(dropTarget?.dataset.idx || '')
const { denizens } = this.actor.system as SiteDataSourceData
if (!denizens[idx]) return false

// Set the denizen description
denizens[idx].text = item.link
void this.actor.update({ system: { denizens } }, { render: true })
denizens[idx].text = droppedActor.link
this.actor.update({ system: { denizens } }, { render: true })
return true
}
}
Loading