From 96046dfd2a48e4352b3e26ba1613fb80bcc3a5eb Mon Sep 17 00:00:00 2001 From: iamBadgers Date: Tue, 19 Aug 2025 20:43:12 -0700 Subject: [PATCH] Not even sure at this point --- src/templates/CharacterArchiver.hbs | 27 ++++++++++++++-- src/ts/apps/CharacterArchiver.ts | 20 +++++++----- src/ts/common.ts | 14 +-------- src/ts/settings.ts | 49 ++++++++++++++++++----------- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/src/templates/CharacterArchiver.hbs b/src/templates/CharacterArchiver.hbs index 603033d..bd26ac4 100644 --- a/src/templates/CharacterArchiver.hbs +++ b/src/templates/CharacterArchiver.hbs @@ -1,13 +1,34 @@
- Hello There {{this.potato}} - +
Character to Archive: {{this.characterName}}
+ +
Avaiable Versions Go Here + + + + + + + {{#each this.reads}} -
{{this.characterName}} {{this.playerName}} {{this.sourceTable}} {{this.version}}
+ + + + + + {{/each}} + + + + + + +
AliasPlayerTableVersion
{{this.characterName}}{{this.playerName}}{{this.sourceTable}}{{this.version}}
+
diff --git a/src/ts/apps/CharacterArchiver.ts b/src/ts/apps/CharacterArchiver.ts index 44d11af..0094bb7 100644 --- a/src/ts/apps/CharacterArchiver.ts +++ b/src/ts/apps/CharacterArchiver.ts @@ -7,6 +7,8 @@ interface CharacterArchiverData { potato: string; reads: Character[]; playerHandle: string; + characterName: string; + characterAlias: string; } export class CharacterArchiver extends Application { @@ -24,13 +26,16 @@ export class CharacterArchiver extends Application { data: CharacterArchiverData = { potato: "po tato potato", reads: [], - playerHandle: "default" + playerHandle: "default", + characterName: "", + characterAlias: "", } - constructor(characterId: string) { + constructor(characterId: string, tableName: string) { super() this.characterId = characterId; this.character = (game as Game).actors!.get(characterId); + this.data.characterName = this.character!.name || "";; } static override get defaultOptions() { @@ -80,9 +85,10 @@ export class CharacterArchiver extends Application { characterData: characterMsg }; - console.log("HERE: " + JSON.stringify(request)); - - this.client.createCharacter(request); + this.client.createCharacter(request).then((response) => { + this.render(true); + return response; + }); } timeout: NodeJS.Timeout | undefined; @@ -90,17 +96,15 @@ export class CharacterArchiver extends Application { private async handleChange(e: Event) { clearTimeout(this.timeout); this.timeout = setTimeout(async () => { - console.log(e.target); const target = e.target as HTMLTextAreaElement; this.data.playerHandle = target.value; console.log(this.data.playerHandle); - console.log(await this.loadArchiveList()); }, 500); } private async loadArchiveList(): Promise { return this.client.listCharacters({ - playerName: "iamBadgers", + playerName: "", characterName: this.character!.name || "" }).response .then((response) => response.characters); diff --git a/src/ts/common.ts b/src/ts/common.ts index 8b48a98..2daa378 100644 --- a/src/ts/common.ts +++ b/src/ts/common.ts @@ -3,16 +3,4 @@ export const MODULE_ID = "rush-character-archive-foundry-module"; export const URI_SETTING_NAME = "uri_setting"; export const API_KEY_NAME = "api_key"; - -export function debounce

( - callback: (...args: P) => any, - time: number -): (...args: P) => void { - let timer: NodeJS.Timeout | undefined; - return function (this: any, ...args: P) { - clearTimeout(timer); - timer = setTimeout(() => callback.apply(this, args), time); - return timer; - } - -} +export const TABLE_NAME = "table_name"; diff --git a/src/ts/settings.ts b/src/ts/settings.ts index b1a4876..2aaa79d 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -1,23 +1,34 @@ -import {MODULE_ID, URI_SETTING_NAME, API_KEY_NAME} from "./common.js" +import {MODULE_ID, URI_SETTING_NAME, API_KEY_NAME, TABLE_NAME} from "./common" export function initializeSettings() { - (game as Game).settings!.register(MODULE_ID, URI_SETTING_NAME, { - name: "Archive Server URI", - hint: "Address of the character archive server.", - scope: "world", - config: true, - // restricted: true, - default: "https://chararchive.cyberpunkrush.com", - type: String, - }); + if ((game as Game).settings) { + (game as Game).settings.register(MODULE_ID, URI_SETTING_NAME, { + name: "Archive Server URI", + hint: "Address of the character archive server.", + scope: "world", + config: true, + // restricted: true, + default: "https://chararchive.cyberpunkrush.com", + type: String, + }); - (game as Game).settings!.register(MODULE_ID, API_KEY_NAME, { - name: "API Key", - hint: "API key to use when communicating with the archive server.", - scope: "world", - config: true, - // restricted: true, - default: "", - type: String, - }); + (game as Game).settings.register(MODULE_ID, API_KEY_NAME, { + name: "API Key", + hint: "API key to use when communicating with the archive server.", + scope: "world", + config: true, + // restricted: true, + default: "", + type: String, + }); + + (game as Game).settings.register(MODULE_ID, TABLE_NAME, { + name: "Table Name", + hint: "Table name to attatch to archived characters.", + scope: "world", + config: true, + default: "My Table", + type: String, + }); + } }