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>
<div class="details"> <div class="details">
Hello There {{this.potato}} <div class="character-name">Character to Archive: {{this.characterName}}</div>
<input class="character-handle" value="{{this.handle}}"/> <input class="player-handle" value="{{this.playerHandle}}"/>
<input class="character-alias" value="{{this.characterAlias}}"/>
</div> </div>
<div class="available-versions"> <div class="available-versions">
Avaiable Versions Go Here Avaiable Versions Go Here
<table>
<tr>
<th>Alias</th>
<th>Player</th>
<th>Table</th>
<th>Version</th>
</tr>
{{#each this.reads}} {{#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}} {{/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> </div>
<button class="archive-button">Archive</button> <button class="archive-button">Archive</button>
</div> </div>

View File

@@ -7,6 +7,8 @@ interface CharacterArchiverData {
potato: string; potato: string;
reads: Character[]; reads: Character[];
playerHandle: string; playerHandle: string;
characterName: string;
characterAlias: string;
} }
export class CharacterArchiver extends Application { export class CharacterArchiver extends Application {
@@ -24,13 +26,16 @@ export class CharacterArchiver extends Application {
data: CharacterArchiverData = { data: CharacterArchiverData = {
potato: "po tato potato", potato: "po tato potato",
reads: [], reads: [],
playerHandle: "default" playerHandle: "default",
characterName: "",
characterAlias: "",
} }
constructor(characterId: string) { constructor(characterId: string, tableName: string) {
super() super()
this.characterId = characterId; this.characterId = characterId;
this.character = (game as Game).actors!.get(characterId); this.character = (game as Game).actors!.get(characterId);
this.data.characterName = this.character!.name || "";;
} }
static override get defaultOptions() { static override get defaultOptions() {
@@ -80,9 +85,10 @@ export class CharacterArchiver extends Application {
characterData: characterMsg characterData: characterMsg
}; };
console.log("HERE: " + JSON.stringify(request)); this.client.createCharacter(request).then((response) => {
this.render(true);
this.client.createCharacter(request); return response;
});
} }
timeout: NodeJS.Timeout | undefined; timeout: NodeJS.Timeout | undefined;
@@ -90,17 +96,15 @@ export class CharacterArchiver extends Application {
private async handleChange(e: Event) { private async handleChange(e: Event) {
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = setTimeout(async () => { this.timeout = setTimeout(async () => {
console.log(e.target);
const target = e.target as HTMLTextAreaElement; const target = e.target as HTMLTextAreaElement;
this.data.playerHandle = target.value; this.data.playerHandle = target.value;
console.log(this.data.playerHandle); console.log(this.data.playerHandle);
console.log(await this.loadArchiveList());
}, 500); }, 500);
} }
private async loadArchiveList(): Promise<Character[]> { private async loadArchiveList(): Promise<Character[]> {
return this.client.listCharacters({ return this.client.listCharacters({
playerName: "iamBadgers", playerName: "",
characterName: this.character!.name || "" characterName: this.character!.name || ""
}).response }).response
.then((response) => response.characters); .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 URI_SETTING_NAME = "uri_setting";
export const API_KEY_NAME = "api_key"; export const API_KEY_NAME = "api_key";
export const TABLE_NAME = "table_name";
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;
}
}

View File

@@ -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() { export function initializeSettings() {
(game as Game).settings!.register(MODULE_ID, URI_SETTING_NAME, { if ((game as Game).settings) {
name: "Archive Server URI", (game as Game).settings.register(MODULE_ID, URI_SETTING_NAME, {
hint: "Address of the character archive server.", name: "Archive Server URI",
scope: "world", hint: "Address of the character archive server.",
config: true, scope: "world",
// restricted: true, config: true,
default: "https://chararchive.cyberpunkrush.com", // restricted: true,
type: String, default: "https://chararchive.cyberpunkrush.com",
}); 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", name: "API Key",
hint: "API key to use when communicating with the archive server.", hint: "API key to use when communicating with the archive server.",
scope: "world", scope: "world",
config: true, config: true,
// restricted: true, // restricted: true,
default: "", default: "",
type: String, 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,
});
}
} }