Initial rework

This commit is contained in:
2024-12-10 17:22:28 +01:00
parent 9b25cc053a
commit 2b9361d3bd
16 changed files with 299 additions and 232 deletions

View File

@ -2,7 +2,7 @@
* Extend the base Actor document by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
export class KidsOnBroomsActor extends Actor {
export class NeverStopBlowingUpActor extends Actor {
/**
* Override getRollData() that's supplied to rolls.

View File

@ -1,7 +1,7 @@
export const KIDSONBROOMS = {};
export const NEVERSTOPBLOWINGUP = {};
// Define constants here, such as:
KIDSONBROOMS.foobar = {
'bas': 'KIDSONBROOMS.bas',
'bar': 'KIDSONBROOMS.bar'
NEVERSTOPBLOWINGUP.foobar = {
'bas': 'NEVERSTOPBLOWINGUP.bas',
'bar': 'NEVERSTOPBLOWINGUP.bar'
};

View File

@ -7,9 +7,9 @@
return loadTemplates([
// Actor partials.
"systems/kidsonbrooms/templates/actor/parts/actor-features.html",
"systems/kidsonbrooms/templates/actor/parts/actor-adversity.html",
"systems/kidsonbrooms/templates/actor/parts/actor-stats.html",
"systems/kidsonbrooms/templates/actor/parts/actor-npc-stats.html",
"systems/fvtt-never-stop-blowing-up/templates/actor/parts/actor-features.html",
"systems/fvtt-never-stop-blowing-up/templates/actor/parts/actor-adversity.html",
"systems/fvtt-never-stop-blowing-up/templates/actor/parts/actor-stats.html",
"systems/fvtt-never-stop-blowing-up/templates/actor/parts/actor-npc-stats.html",
]);
};

View File

@ -1,12 +1,12 @@
// Import document classes.
import { KidsOnBroomsActor } from "./documents/actor.mjs";
import { NeverStopBlowingUpActor } from "./documents/actor.mjs";
// Import sheet classes.
import { KidsOnBroomsActorSheet } from "./sheets/actor-sheet.mjs";
import { NeverStopBlowingUpActorSheet } from "./sheets/actor-sheet.mjs";
// Import helper/utility classes and constants.
import { preloadHandlebarsTemplates } from "./helpers/templates.mjs";
import { KIDSONBROOMS } from "./helpers/config.mjs";
import { NEVERSTOPBLOWINGUP } from "./helpers/config.mjs";
/* -------------------------------------------- */
/* Init Hook */
@ -25,13 +25,13 @@ Hooks.once('init', async function() {
// Add utility classes and functions to the global game object so that they're more easily
// accessible in global contexts.
game.kidsonbrooms = {
KidsOnBroomsActor,
NeverStopBlowingUpActor,
_onTakeAdversityToken: _onTakeAdversityToken, // Add the function to the global object
_onSpendAdversityTokens: _onSpendAdversityTokens // Add the function to the global object
};
// Add custom constants for configuration.
CONFIG.KIDSONBROOMS = KIDSONBROOMS;
CONFIG.NEVERSTOPBLOWINGUP = NEVERSTOPBLOWINGUP;
/**
* Set an initiative formula for the system
@ -44,11 +44,11 @@ Hooks.once('init', async function() {
// Define custom Document classes
CONFIG.Actor.documentClass = KidsOnBroomsActor;
CONFIG.Actor.documentClass = NeverStopBlowingUpActor;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("kidsonbrooms", KidsOnBroomsActorSheet, { makeDefault: true });
Actors.registerSheet("fvtt-never-stop-blowing-up", NeverStopBlowingUpActorSheet, { makeDefault: true });
//If there is a new chat message that is a roll we add the adversity token controls
Hooks.on("renderChatMessage", (message, html, messageData) => {
@ -86,10 +86,10 @@ Hooks.once('init', async function() {
// Update the message content
tokenControls.update({ content: updatedContent });
// Set the flag on the chat message to indicate that the token has been claimed
tokenControls.setFlag("kidsonbrooms", "tokenClaimed", true);
tokenControls.setFlag("fvtt-never-stop-blowing-up", "tokenClaimed", true);
} else {
// Emit a socket request to update the message to show that the token has been claimed
game.socket.emit('system.kidsonbrooms', {
game.socket.emit('system.fvtt-never-stop-blowing-up', {
action: "takeToken",
messageID: message.id,
actorID: actor.id,
@ -117,7 +117,7 @@ Hooks.once('init', async function() {
* if a player wants to claim a token we will update the message since they do not have the permissions
*/
Hooks.once('ready', function() {
game.socket.on('system.kidsonbrooms', async (data) => {
game.socket.on('system.fvtt-never-stop-blowing-up', async (data) => {
console.log("Socket data received:", data);
if (data.action === "spendTokens") {
@ -189,7 +189,7 @@ Hooks.once('ready', function() {
// Update the message content
tokenControls.update({ content: updatedContent });
// Set the flag on the chat message to indicate that the token has been claimed
tokenControls.setFlag("kidsonbrooms", "tokenClaimed", true);
tokenControls.setFlag("fvtt-never-stop-blowing-up", "tokenClaimed", true);
}
});
});
@ -276,7 +276,7 @@ async function _onSpendAdversityTokens(e, rollMessageId) {
console.log(`Requesting to spend ${tokensToSpend} tokens for ${rollActor.name} by ${spendingPlayerActor.name} (cost: ${tokenCost})`);
// Emit a socket request to spend tokens
game.socket.emit('system.kidsonbrooms', {
game.socket.emit('system.fvtt-never-stop-blowing-up', {
action: "spendTokens",
rollActorId: rollActorId,
spendingActorId: spendingPlayerActor.id, // Send the player's actor who is spending the tokens
@ -299,8 +299,8 @@ async function _updateRollMessage(rollMessageId, tokensToSpend, isPlayerOfActor)
}
// Retrieve current tokens spent from flags, or initialize to 0 if not found
let cumulativeTokensSpent = message.getFlag("kidsonbrooms", "tokensSpent") || 0;
let newTotal = message.getFlag("kidsonbrooms", "newRollTotal") || message.rolls[0].total;
let cumulativeTokensSpent = message.getFlag("fvtt-never-stop-blowing-up", "tokensSpent") || 0;
let newTotal = message.getFlag("fvtt-never-stop-blowing-up", "newRollTotal") || message.rolls[0].total;
/*if(isPlayerOfActor)
{
@ -311,10 +311,10 @@ async function _updateRollMessage(rollMessageId, tokensToSpend, isPlayerOfActor)
}*/
cumulativeTokensSpent += tokensToSpend;
newTotal += tokensToSpend;
await message.setFlag("kidsonbrooms", "newRollTotal", newTotal);
await message.setFlag("fvtt-never-stop-blowing-up", "newRollTotal", newTotal);
// Update the message's flags to store the cumulative tokens spent
await message.setFlag("kidsonbrooms", "tokensSpent", cumulativeTokensSpent);
await message.setFlag("fvtt-never-stop-blowing-up", "tokensSpent", cumulativeTokensSpent);
let newContent = "";
if(cumulativeTokensSpent === 1)
{

View File

@ -2,13 +2,13 @@
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
export class KidsOnBroomsActorSheet extends ActorSheet {
export class NeverStopBlowingUpActorSheet extends ActorSheet {
/** @override */
static get defaultOptions()
{
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["kidsonbrooms", "sheet", "actor"],
classes: ["fvtt-never-stop-blowing-up", "sheet", "actor"],
width: 800,
height: 800,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
@ -19,7 +19,7 @@ export class KidsOnBroomsActorSheet extends ActorSheet {
get template()
{
console.log("template", this.actor)
return `systems/kidsonbrooms/templates/actor/actor-${this.actor.type}-sheet.html`;
return `systems/fvtt-never-stop-blowing-up/templates/actor/actor-${this.actor.type}-sheet.html`;
}