Not even sure at this point

This commit is contained in:
iamBadgers
2025-08-19 20:43:12 -07:00
parent 7b3e206240
commit 96046dfd2a
4 changed files with 67 additions and 43 deletions

View File

@@ -1,13 +1,34 @@
<div>
<div class="details">
Hello There {{this.potato}}
<input class="character-handle" value="{{this.handle}}"/>
<div class="character-name">Character to Archive: {{this.characterName}}</div>
<input class="player-handle" value="{{this.playerHandle}}"/>
<input class="character-alias" value="{{this.characterAlias}}"/>
</div>
<div class="available-versions">
Avaiable Versions Go Here
<table>
<tr>
<th>Alias</th>
<th>Player</th>
<th>Table</th>
<th>Version</th>
</tr>
{{#each this.reads}}
<div>{{this.characterName}} {{this.playerName}} {{this.sourceTable}} {{this.version}}</div>
<tr>
<td>{{this.characterName}}</td>
<td>{{this.playerName}}</td>
<td>{{this.sourceTable}}</td>
<td>{{this.version}}</td>
</tr>
{{/each}}
<tr>
<td><input class="character-alias" value="{{this.characterAlias}}"/></td>
<td><input class="player-handle" value="{{this.playerHandle}}"/>
</td>
<td></td>
<td></td>
</tr>
</table>
</div>
<button class="archive-button">Archive</button>
</div>

View File

@@ -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<Character[]> {
return this.client.listCharacters({
playerName: "iamBadgers",
playerName: "",
characterName: this.character!.name || ""
}).response
.then((response) => response.characters);

View File

@@ -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<P extends any[]>(
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";

View File

@@ -1,7 +1,8 @@
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, {
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",
@@ -11,7 +12,7 @@ export function initializeSettings() {
type: String,
});
(game as Game).settings!.register(MODULE_ID, API_KEY_NAME, {
(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",
@@ -20,4 +21,14 @@ export function initializeSettings() {
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,
});
}
}