Initial Import

This commit is contained in:
2023-01-04 22:09:09 +01:00
parent 7665fb32b5
commit 76ca542cbb
26 changed files with 265 additions and 697 deletions

View File

@@ -3,17 +3,17 @@
* @extends {ActorSheet}
*/
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
/* -------------------------------------------- */
export class CrucibleActorSheet extends ActorSheet {
export class WarheroActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["fvtt-crucible-rpg", "sheet", "actor"],
template: "systems/fvtt-crucible-rpg/templates/actor-sheet.html",
classes: ["fvtt-warhero", "sheet", "actor"],
template: "systems/fvtt-warhero/templates/actor-sheet.html",
width: 960,
height: 720,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }],
@@ -46,13 +46,10 @@ export class CrucibleActorSheet extends ActorSheet {
equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ),
equippedArmor: this.actor.getEquippedArmor(),
equippedShield: this.actor.getEquippedShield(),
feats: duplicate(this.actor.getFeats()),
subActors: duplicate(this.actor.getSubActors()),
race: duplicate(this.actor.getRace()),
moneys: duplicate(this.actor.getMoneys()),
encCapacity: this.actor.getEncumbranceCapacity(),
saveRolls: this.actor.getSaveRoll(),
conditions: this.actor.getConditions(),
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
notes: await TextEditor.enrichHTML(this.object.system.biodata.notes, {async: true}),
containersTree: this.actor.containersTree,
@@ -91,7 +88,7 @@ export class CrucibleActorSheet extends ActorSheet {
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item")
CrucibleUtility.confirmDelete(this, li)
WarheroUtility.confirmDelete(this, li)
})
html.find('.item-add').click(ev => {
let dataType = $(ev.currentTarget).data("type")

View File

@@ -1,6 +1,6 @@
/* -------------------------------------------- */
import { CrucibleUtility } from "./crucible-utility.js";
import { CrucibleRollDialog } from "./crucible-roll-dialog.js";
import { WarheroUtility } from "./warhero-utility.js";
import { WarheroRollDialog } from "./warhero-roll-dialog.js";
/* -------------------------------------------- */
const coverBonusTable = { "nocover": 0, "lightcover": 2, "heavycover": 4, "entrenchedcover": 6 };
@@ -16,7 +16,7 @@ const __subkey2title = {
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
export class CrucibleActor extends Actor {
export class WarheroActor extends Actor {
/* -------------------------------------------- */
/**
@@ -43,7 +43,7 @@ export class CrucibleActor extends Actor {
}
if (data.type == 'character') {
const skills = await CrucibleUtility.loadCompendium("fvtt-crucible-rpg.skills");
const skills = await WarheroUtility.loadCompendium("fvtt-warhero.skills");
data.items = skills.map(i => i.toObject())
}
if (data.type == 'npc') {
@@ -113,41 +113,41 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getMoneys() {
let comp = this.items.filter(item => item.type == 'money');
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getFeats() {
let comp = duplicate(this.items.filter(item => item.type == 'feat') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getFeatsWithDie() {
let comp = duplicate(this.items.filter(item => item.type == 'feat' && item.system.isfeatdie) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
getFeatsWithSL() {
let comp = duplicate(this.items.filter(item => item.type == 'feat' && item.system.issl) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getLore() {
let comp = duplicate(this.items.filter(item => item.type == 'spell') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
getEquippedWeapons() {
let comp = duplicate(this.items.filter(item => item.type == 'weapon' && item.system.equipped) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getArmors() {
let comp = duplicate(this.items.filter(item => item.type == 'armor') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
getEquippedArmor() {
@@ -160,7 +160,7 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getShields() {
let comp = duplicate(this.items.filter(item => item.type == 'shield') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
getEquippedShield() {
@@ -190,13 +190,13 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getConditions() {
let comp = duplicate(this.items.filter(item => item.type == 'condition') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getWeapons() {
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
@@ -212,9 +212,9 @@ export class CrucibleActor extends Actor {
getSkills() {
let comp = duplicate(this.items.filter(item => item.type == 'skill') || [])
for (let skill of comp) {
CrucibleUtility.updateSkill(skill)
WarheroUtility.updateSkill(skill)
}
CrucibleUtility.sortArrayObjectsByName(comp)
WarheroUtility.sortArrayObjectsByName(comp)
return comp
}
@@ -273,17 +273,17 @@ export class CrucibleActor extends Actor {
return {
reflex: {
"label": "Reflex Save",
"img": "systems/fvtt-crucible-rpg/images/icons/saves/reflex_save.webp",
"img": "systems/fvtt-warhero/images/icons/saves/reflex_save.webp",
"value": this.system.abilities.agi.value + this.system.abilities.wit.value
},
fortitude: {
"label": "Fortitude Save",
"img": "systems/fvtt-crucible-rpg/images/icons/saves/fortitude_save.webp",
"img": "systems/fvtt-warhero/images/icons/saves/fortitude_save.webp",
"value": this.system.abilities.str.value + this.system.abilities.con.value
},
willpower: {
"label": "Willpower Save",
"img": "systems/fvtt-crucible-rpg/images/icons/saves/will_save.webp",
"img": "systems/fvtt-warhero/images/icons/saves/will_save.webp",
"value": this.system.abilities.int.value + this.system.abilities.cha.value
}
}
@@ -309,7 +309,7 @@ export class CrucibleActor extends Actor {
// Compute whole enc
let enc = 0
for (let item of equipments) {
//item.data.idrDice = CrucibleUtility.getDiceFromLevel(Number(item.data.idr))
//item.data.idrDice = WarheroUtility.getDiceFromLevel(Number(item.data.idr))
if (item.system.equipped) {
if (item.system.iscontainer) {
enc += item.system.contentsEnc
@@ -343,8 +343,8 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
async incDecHP(formula) {
let dmgRoll = new Roll(formula+"[crucible-orange]").roll({ async: false })
await CrucibleUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
let dmgRoll = new Roll(formula+"[warhero-orange]").roll({ async: false })
await WarheroUtility.showDiceSoNice(dmgRoll, game.settings.get("core", "rollMode"))
let hp = duplicate(this.system.secondary.hp)
hp.value = Number(hp.value) + Number(dmgRoll.total)
this.update({ 'system.secondary.hp': hp })
@@ -431,7 +431,7 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
syncRoll(rollData) {
this.lastRollId = rollData.rollId;
CrucibleUtility.saveRollData(rollData);
WarheroUtility.saveRollData(rollData);
}
/* -------------------------------------------- */
@@ -540,7 +540,7 @@ export class CrucibleActor extends Actor {
return
}
let rollData = CrucibleUtility.getBasicRollData()
let rollData = WarheroUtility.getBasicRollData()
rollData.alias = this.name
rollData.actorImg = this.img
rollData.actorId = this.id
@@ -600,7 +600,7 @@ export class CrucibleActor extends Actor {
ui.notifications.warn("You are targetting a token with a skill : please use a Weapon instead.")
return
}
CrucibleUtility.rollCrucible(rollData)
WarheroUtility.rollWarhero(rollData)
}
/* -------------------------------------------- */
@@ -612,7 +612,7 @@ export class CrucibleActor extends Actor {
return
}
skill = duplicate(skill)
CrucibleUtility.updateSkill(skill)
WarheroUtility.updateSkill(skill)
let abilityKey = skill.system.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "skill"
@@ -634,7 +634,7 @@ export class CrucibleActor extends Actor {
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
if (skill) {
skill = duplicate(skill)
CrucibleUtility.updateSkill(skill)
WarheroUtility.updateSkill(skill)
let abilityKey = skill.system.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "weapon"
@@ -644,8 +644,8 @@ export class CrucibleActor extends Actor {
if (!rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isAttackDisadvantage()
}
/*if (rollData.weapon.system.isranged && rollData.tokensDistance > CrucibleUtility.getWeaponMaxRange(rollData.weapon) ) {
ui.notifications.warn(`Your target is out of range of your weapon (max: ${CrucibleUtility.getWeaponMaxRange(rollData.weapon)} - current : ${rollData.tokensDistance})` )
/*if (rollData.weapon.system.isranged && rollData.tokensDistance > WarheroUtility.getWeaponMaxRange(rollData.weapon) ) {
ui.notifications.warn(`Your target is out of range of your weapon (max: ${WarheroUtility.getWeaponMaxRange(rollData.weapon)} - current : ${rollData.tokensDistance})` )
return
}*/
this.startRoll(rollData)
@@ -663,7 +663,7 @@ export class CrucibleActor extends Actor {
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
if (skill) {
skill = duplicate(skill)
CrucibleUtility.updateSkill(skill)
WarheroUtility.updateSkill(skill)
let abilityKey = skill.system.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.defenderTokenId = undefined // Cleanup
@@ -693,10 +693,10 @@ export class CrucibleActor extends Actor {
rollData.mode = "rangeddefense"
if ( attackRollData) {
rollData.attackRollData = duplicate(attackRollData)
rollData.effectiveRange = CrucibleUtility.getWeaponRange(attackRollData.weapon)
rollData.effectiveRange = WarheroUtility.getWeaponRange(attackRollData.weapon)
rollData.tokensDistance = attackRollData.tokensDistance // QoL copy
}
rollData.sizeDice = CrucibleUtility.getSizeDice(this.system.biodata.size)
rollData.sizeDice = WarheroUtility.getSizeDice(this.system.biodata.size)
rollData.distanceBonusDice = 0 //Math.max(0, Math.floor((rollData.tokensDistance - rollData.effectiveRange) + 0.5))
rollData.hasCover = "none"
rollData.situational = "none"
@@ -731,36 +731,36 @@ export class CrucibleActor extends Actor {
let messages = ["Armor applied"]
if (rollData) {
if (CrucibleUtility.isArmorLight(armor) && CrucibleUtility.isWeaponPenetrating(rollData.attackRollData.weapon)) {
if (WarheroUtility.isArmorLight(armor) && WarheroUtility.isWeaponPenetrating(rollData.attackRollData.weapon)) {
return { armorIgnored: true, nbSuccess: 0, messages: ["Armor ignored : Penetrating weapons ignore Light Armors."] }
}
if (CrucibleUtility.isWeaponPenetrating(rollData.attackRollData.weapon)) {
if (WarheroUtility.isWeaponPenetrating(rollData.attackRollData.weapon)) {
messages.push("Armor reduced by 1 (Penetrating weapon)")
reduce = 1
}
if (CrucibleUtility.isWeaponLight(rollData.attackRollData.weapon)) {
if (WarheroUtility.isWeaponLight(rollData.attackRollData.weapon)) {
messages.push("Armor with advantage (Light weapon)")
advantage = true
}
if (CrucibleUtility.isWeaponHeavy(rollData.attackRollData.weapon)) {
if (WarheroUtility.isWeaponHeavy(rollData.attackRollData.weapon)) {
messages.push("Armor with disadvantage (Heavy weapon)")
disadvantage = true
}
if (CrucibleUtility.isWeaponHack(rollData.attackRollData.weapon)) {
if (WarheroUtility.isWeaponHack(rollData.attackRollData.weapon)) {
messages.push("Armor reduced by 1 (Hack weapon)")
reduce = 1
}
if (CrucibleUtility.isWeaponUndamaging(rollData.attackRollData.weapon)) {
if (WarheroUtility.isWeaponUndamaging(rollData.attackRollData.weapon)) {
messages.push("Armor multiplied by 2 (Undamaging weapon)")
multiply = 2
}
}
let diceColor = armor.system.absorprionroll
let armorResult = await CrucibleUtility.getRollTableFromDiceColor(diceColor, false)
let armorResult = await WarheroUtility.getRollTableFromDiceColor(diceColor, false)
console.log("Armor log", armorResult)
let armorValue = Math.max(0, (Number(armorResult.text) + reduce) * multiply)
if (advantage || disadvantage) {
let armorResult2 = await CrucibleUtility.getRollTableFromDiceColor(diceColor, false)
let armorResult2 = await WarheroUtility.getRollTableFromDiceColor(diceColor, false)
let armorValue2 = Math.max(0, (Number(armorResult2.text) + reduce) * multiply)
if (advantage) {
armorValue = (armorValue2 > armorValue) ? armorValue2 : armorValue
@@ -801,7 +801,7 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
async startRoll(rollData) {
this.syncRoll(rollData)
let rollDialog = await CrucibleRollDialog.create(this, rollData)
let rollDialog = await WarheroRollDialog.create(this, rollData)
rollDialog.render(true)
}

View File

@@ -1,7 +1,7 @@
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
/* -------------------------------------------- */
export class CrucibleCombat extends Combat {
export class WarheroCombat extends Combat {
/* -------------------------------------------- */
async rollInitiative(ids, formula = undefined, messageOptions = {} ) {

View File

@@ -1,19 +1,19 @@
/* -------------------------------------------- */
import { CrucibleUtility } from "./crucible-utility.js";
import { CrucibleRollDialog } from "./crucible-roll-dialog.js";
import { WarheroUtility } from "./warhero-utility.js";
import { WarheroRollDialog } from "./warhero-roll-dialog.js";
/* -------------------------------------------- */
const __saveFirstToKey = { r: "reflex", f: "fortitude", w: "willpower"}
/* -------------------------------------------- */
export class CrucibleCommands {
export class WarheroCommands {
static init() {
if (!game.system.cruciblerpg.commands) {
const crucibleCommands = new CrucibleCommands();
crucibleCommands.registerCommand({ path: ["/rtarget"], func: (content, msg, params) => CrucibleCommands.rollTarget(msg, params), descr: "Launch the target roll window" });
crucibleCommands.registerCommand({ path: ["/rsave"], func: (content, msg, params) => CrucibleCommands.rollSave(msg, params), descr: "Performs a save roll" });
const crucibleCommands = new WarheroCommands();
crucibleCommands.registerCommand({ path: ["/rtarget"], func: (content, msg, params) => WarheroCommands.rollTarget(msg, params), descr: "Launch the target roll window" });
crucibleCommands.registerCommand({ path: ["/rsave"], func: (content, msg, params) => WarheroCommands.rollSave(msg, params), descr: "Performs a save roll" });
game.system.cruciblerpg.commands = crucibleCommands;
}
}
@@ -93,7 +93,7 @@ export class CrucibleCommands {
if (command && command.func) {
const result = command.func(content, msg, params);
if (result == false) {
CrucibleCommands._chatAnswer(msg, command.descr);
WarheroCommands._chatAnswer(msg, command.descr);
}
return true;
}

View File

@@ -1,8 +1,8 @@
export class CrucibleHotbar {
export class WarheroHotbar {
static async addToHotbar(item, slot) {
let command = `game.system.cruciblerpg.CrucibleHotbar.rollMacro("${item.name}", "${item.type}");`;
let command = `game.system.cruciblerpg.WarheroHotbar.rollMacro("${item.name}", "${item.type}");`;
let macro = game.macros.contents.find(m => (m.name === item.name) && (m.command === command));
if (!macro) {
macro = await Macro.create({

View File

@@ -1,17 +1,17 @@
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class CrucibleItemSheet extends ItemSheet {
export class WarheroItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["fvtt-crucible-rpg", "sheet", "item"],
template: "systems/fvtt-crucible-rpg/templates/item-sheet.html",
classes: ["fvtt-warhero", "sheet", "item"],
template: "systems/fvtt-warhero/templates/item-sheet.html",
dragDrop: [{ dragSelector: null, dropSelector: null }],
width: 620,
height: 550,
@@ -50,7 +50,7 @@ export class CrucibleItemSheet extends ItemSheet {
async getData() {
if ( this.object.type == "skill") {
CrucibleUtility.updateSkill(this.object)
WarheroUtility.updateSkill(this.object)
}
let objectData = duplicate(this.object.system)
@@ -63,8 +63,8 @@ export class CrucibleItemSheet extends ItemSheet {
name: this.object.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
weaponSkills: CrucibleUtility.getWeaponSkills(),
shieldSkills: CrucibleUtility.getShieldSkills(),
weaponSkills: WarheroUtility.getWeaponSkills(),
shieldSkills: WarheroUtility.getShieldSkills(),
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
data: itemData,
limited: this.object.limited,
@@ -92,7 +92,7 @@ export class CrucibleItemSheet extends ItemSheet {
/* -------------------------------------------- */
postItem() {
let chatData = duplicate(CrucibleUtility.data(this.item));
let chatData = duplicate(WarheroUtility.data(this.item));
if (this.actor) {
chatData.actor = { id: this.actor.id };
}
@@ -107,8 +107,8 @@ export class CrucibleItemSheet extends ItemSheet {
payload: chatData,
});
renderTemplate('systems/fvtt-crucible-rpg/templates/post-item.html', chatData).then(html => {
let chatOptions = CrucibleUtility.chatDataSetup(html);
renderTemplate('systems/fvtt-warhero/templates/post-item.html', chatData).then(html => {
let chatOptions = WarheroUtility.chatDataSetup(html);
ChatMessage.create(chatOptions)
});
}
@@ -159,7 +159,7 @@ export class CrucibleItemSheet extends ItemSheet {
/* -------------------------------------------- */
get template() {
let type = this.item.type;
return `systems/fvtt-crucible-rpg/templates/item-${type}-sheet.html`;
return `systems/fvtt-warhero/templates/item-${type}-sheet.html`;
}
/* -------------------------------------------- */

View File

@@ -1,19 +1,19 @@
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
export const defaultItemImg = {
skill: "systems/fvtt-crucible-rpg/images/icons/icon_skill.webp",
armor: "systems/fvtt-crucible-rpg/images/icons/icon_armour.webp",
weapon: "systems/fvtt-crucible-rpg/images/icons/icon_weapon.webp",
equipment: "systems/fvtt-crucible-rpg/images/icons/icon_equipment.webp",
race: "systems/fvtt-crucible-rpg/images/icons/icon_race.webp",
money: "systems/fvtt-crucible-rpg/images/icons/icon_money.webp",
skill: "systems/fvtt-warhero/images/icons/icon_skill.webp",
armor: "systems/fvtt-warhero/images/icons/icon_armour.webp",
weapon: "systems/fvtt-warhero/images/icons/icon_weapon.webp",
equipment: "systems/fvtt-warhero/images/icons/icon_equipment.webp",
race: "systems/fvtt-warhero/images/icons/icon_race.webp",
money: "systems/fvtt-warhero/images/icons/icon_money.webp",
}
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class CrucibleItem extends Item {
export class WarheroItem extends Item {
constructor(data, context) {
if (!data.img) {

View File

@@ -1,5 +1,5 @@
/**
* Crucible system
* Warhero system
* Author: Uberwald
* Software License: Prop
*/
@@ -8,15 +8,15 @@
/* -------------------------------------------- */
// Import Modules
import { CrucibleActor } from "./crucible-actor.js";
import { CrucibleItemSheet } from "./crucible-item-sheet.js";
import { CrucibleActorSheet } from "./crucible-actor-sheet.js";
import { CrucibleNPCSheet } from "./crucible-npc-sheet.js";
import { CrucibleUtility } from "./crucible-utility.js";
import { CrucibleCombat } from "./crucible-combat.js";
import { CrucibleItem } from "./crucible-item.js";
import { CrucibleHotbar } from "./crucible-hotbar.js"
import { CrucibleCommands } from "./crucible-commands.js"
import { WarheroActor } from "./warhero-actor.js";
import { WarheroItemSheet } from "./warhero-item-sheet.js";
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
import { WarheroNPCSheet } from "./warhero-npc-sheet.js";
import { WarheroUtility } from "./warhero-utility.js";
import { WarheroCombat } from "./warhero-combat.js";
import { WarheroItem } from "./warhero-item.js";
import { WarheroHotbar } from "./warhero-hotbar.js"
import { WarheroCommands } from "./warhero-commands.js"
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@@ -25,16 +25,16 @@ import { CrucibleCommands } from "./crucible-commands.js"
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Crucible RPG`);
console.log(`Initializing Warhero RPG`);
game.system.cruciblerpg = {
CrucibleHotbar,
CrucibleCommands
WarheroHotbar,
WarheroCommands
}
/* -------------------------------------------- */
// preload handlebars templates
CrucibleUtility.preloadHandlebarsTemplates();
WarheroUtility.preloadHandlebarsTemplates();
/* -------------------------------------------- */
// Set an initiative formula for the system
@@ -44,27 +44,27 @@ Hooks.once("init", async function () {
};
/* -------------------------------------------- */
game.socket.on("system.fvtt-crucible-rpg", data => {
CrucibleUtility.onSocketMesssage(data)
game.socket.on("system.fvtt-warhero", data => {
WarheroUtility.onSocketMesssage(data)
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = CrucibleCombat
CONFIG.Actor.documentClass = CrucibleActor
CONFIG.Item.documentClass = CrucibleItem
//CONFIG.Token.objectClass = CrucibleToken
CONFIG.Combat.documentClass = WarheroCombat
CONFIG.Actor.documentClass = WarheroActor
CONFIG.Item.documentClass = WarheroItem
//CONFIG.Token.objectClass = WarheroToken
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-crucible", CrucibleActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("fvtt-crucible", CrucibleNPCSheet, { types: ["npc"], makeDefault: false });
Actors.registerSheet("fvtt-crucible", WarheroActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("fvtt-crucible", WarheroNPCSheet, { types: ["npc"], makeDefault: false });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-crucible", CrucibleItemSheet, { makeDefault: true });
Items.registerSheet("fvtt-crucible", WarheroItemSheet, { makeDefault: true });
CrucibleUtility.init()
WarheroUtility.init()
});
/* -------------------------------------------- */
@@ -73,7 +73,7 @@ function welcomeMessage() {
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-crucible"><span class="rdd-roll-part">
<strong>Welcome to the Crucible RPG.</strong>
<strong>Welcome to the Warhero RPG.</strong>
` });
}
@@ -98,9 +98,9 @@ Hooks.once("ready", function () {
}
welcomeMessage();
CrucibleUtility.ready()
CrucibleCommands.init()
CrucibleHotbar.initDropbar()
WarheroUtility.ready()
WarheroCommands.init()
WarheroHotbar.initDropbar()
})

View File

@@ -3,17 +3,17 @@
* @extends {ActorSheet}
*/
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
/* -------------------------------------------- */
export class CrucibleNPCSheet extends ActorSheet {
export class WarheroNPCSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["crucible-rpg", "sheet", "actor"],
template: "systems/fvtt-crucible-rpg/templates/npc-sheet.html",
classes: ["warhero-rpg", "sheet", "actor"],
template: "systems/fvtt-warhero/templates/npc-sheet.html",
width: 640,
height: 720,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
@@ -88,7 +88,7 @@ export class CrucibleNPCSheet extends ActorSheet {
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item")
CrucibleUtility.confirmDelete(this, li)
WarheroUtility.confirmDelete(this, li)
})
html.find('.item-add').click(ev => {
let dataType = $(ev.currentTarget).data("type")

View File

@@ -1,14 +1,14 @@
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
export class CrucibleRollDialog extends Dialog {
export class WarheroRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData) {
let options = { classes: ["CrucibleDialog"], width: 540, height: 340, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html', rollData);
let options = { classes: ["WarheroDialog"], width: 540, height: 340, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-warhero/templates/roll-dialog-generic.html', rollData);
return new CrucibleRollDialog(actor, rollData, html, options);
return new WarheroRollDialog(actor, rollData, html, options);
}
/* -------------------------------------------- */
@@ -39,12 +39,12 @@ export class CrucibleRollDialog extends Dialog {
/* -------------------------------------------- */
roll() {
CrucibleUtility.rollCrucible(this.rollData)
WarheroUtility.rollWarhero(this.rollData)
}
/* -------------------------------------------- */
async refreshDialog() {
const content = await renderTemplate("systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html", this.rollData)
const content = await renderTemplate("systems/fvtt-warhero/templates/roll-dialog-generic.html", this.rollData)
this.data.content = content
this.render(true)
}

View File

@@ -1,6 +1,6 @@
import { CrucibleUtility } from "./crucible-utility.js";
import { WarheroUtility } from "./warhero-utility.js";
/* -------------------------------------------- */
export class CrucibleToken extends Token {
export class WarheroToken extends Token {
}

View File

@@ -1,32 +1,24 @@
/* -------------------------------------------- */
import { CrucibleCombat } from "./crucible-combat.js";
import { CrucibleCommands } from "./crucible-commands.js";
import { WarheroCombat } from "./warhero-combat.js";
import { WarheroCommands } from "./warhero-commands.js";
/* -------------------------------------------- */
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"];
const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 }
const __skillLevel2Dice = ["0d8", "1d8", "2d8", "3d8", "4d8", '6d8', "8d8", "10d8"]
const __color2RollTable = {
blue: "Blue Armor Die", black: "Black Armor Die", green: "Green Armor Die", purple: "Purple Armor Die",
white: "White Armor Die", red: "Red Armor Die", blackgreen: "Black & Green Armor Dice"
}
const __size2Dice = [{ nb: 0, dice: "d0" }, { nb: 5, dice: "d8" }, { nb: 3, dice: "d8" }, { nb: 2, dice: "d8" }, { nb: 1, dice: "d8" }, { nb: 1, dice: "d6" }, { nb: 1, noAddFirst: true, dice: "d6" }]
/* -------------------------------------------- */
export class CrucibleUtility {
export class WarheroUtility {
/* -------------------------------------------- */
static async init() {
Hooks.on('renderChatLog', (log, html, data) => CrucibleUtility.chatListeners(html));
Hooks.on('renderChatLog', (log, html, data) => WarheroUtility.chatListeners(html));
/*Hooks.on("dropCanvasData", (canvas, data) => {
CrucibleUtility.dropItemOnToken(canvas, data)
WarheroUtility.dropItemOnToken(canvas, data)
});*/
this.rollDataStore = {}
this.defenderStore = {}
CrucibleCommands.init();
WarheroCommands.init();
Handlebars.registerHelper('count', function (list) {
return list.length;
@@ -57,7 +49,7 @@ export class CrucibleUtility {
/*-------------------------------------------- */
static gameSettings() {
/*game.settings.register("fvtt-crucible-rpg", "dice-color-skill", {
/*game.settings.register("fvtt-warhero", "dice-color-skill", {
name: "Dice color for skills",
hint: "Set the dice color for skills",
scope: "world",
@@ -68,7 +60,7 @@ export class CrucibleUtility {
})
Hooks.on('renderSettingsConfig', (event) => {
const element = event.element[0].querySelector(`[name='fvtt-crucible-rpg.dice-color-skill']`)
const element = event.element[0].querySelector(`[name='fvtt-warhero.dice-color-skill']`)
if (!element) return
// Replace placeholder element
console.log("Element Found !!!!")
@@ -78,7 +70,7 @@ export class CrucibleUtility {
/*-------------------------------------------- */
static addDiceColors() {
game.dice3d.addColorset({
name: 'crucible-orange',
name: 'warhero-orange',
category: "crucible",
foreground: '#9F8003',
background: "#FFA500",
@@ -86,7 +78,7 @@ export class CrucibleUtility {
}, "preferred");
game.dice3d.addColorset({
name: 'crucible-purple',
name: 'warhero-purple',
category: "crucible",
foreground: '#9F8003',
background: "#800080",
@@ -94,7 +86,7 @@ export class CrucibleUtility {
}, "preferred");
game.dice3d.addColorset({
name: 'crucible-darkgreen',
name: 'warhero-darkgreen',
category: "crucible",
foreground: '#9F8003',
background: "#006400",
@@ -123,12 +115,12 @@ export class CrucibleUtility {
/* -------------------------------------------- */
static async ready() {
const skills = await CrucibleUtility.loadCompendium("fvtt-crucible-rpg.skills")
const skills = await WarheroUtility.loadCompendium("fvtt-warhero.skills")
this.skills = skills.map(i => i.toObject())
this.weaponSkills = duplicate(this.skills.filter(item => item.system.isweaponskill))
this.shieldSkills = duplicate(this.skills.filter(item => item.system.isshieldskill))
const rollTables = await CrucibleUtility.loadCompendium("fvtt-crucible-rpg.rolltables")
const rollTables = await WarheroUtility.loadCompendium("fvtt-warhero.rolltables")
this.rollTables = rollTables.map(i => i.toObject())
this.addDiceColors()
@@ -143,7 +135,7 @@ export class CrucibleUtility {
/* -------------------------------------------- */
static async loadCompendium(compendium, filter = item => true) {
let compendiumData = await CrucibleUtility.loadCompendiumData(compendium)
let compendiumData = await WarheroUtility.loadCompendiumData(compendium)
return compendiumData.filter(filter)
}
@@ -222,7 +214,7 @@ export class CrucibleUtility {
static async getRollTableFromDiceColor(diceColor, displayChat = true) {
let rollTableName = __color2RollTable[diceColor]
if (rollTableName) {
const pack = game.packs.get("fvtt-crucible-rpg.rolltables")
const pack = game.packs.get("fvtt-warhero.rolltables")
const index = await pack.getIndex()
const entry = index.find(e => e.name === rollTableName)
let table = await pack.getDocument(entry._id)
@@ -237,7 +229,7 @@ export class CrucibleUtility {
/* -------------------------------------------- */
static async getCritical(level, weapon) {
const pack = game.packs.get("fvtt-crucible-rpg.rolltables")
const pack = game.packs.get("fvtt-warhero.rolltables")
let tableName = "Crit " + level + " (" + this.upperFirst(weapon.system.damage) + ")"
const index = await pack.getIndex()
@@ -255,7 +247,7 @@ export class CrucibleUtility {
})
html.on("click", '.roll-defense-melee', event => {
let rollId = $(event.currentTarget).data("roll-id")
let rollData = CrucibleUtility.getRollData(rollId)
let rollData = WarheroUtility.getRollData(rollId)
rollData.defenseWeaponId = $(event.currentTarget).data("defense-weapon-id")
let actor = game.canvas.tokens.get(rollData.defenderTokenId).actor
if (actor && (game.user.isGM || actor.isOwner)) {
@@ -264,7 +256,7 @@ export class CrucibleUtility {
})
html.on("click", '.roll-defense-ranged', event => {
let rollId = $(event.currentTarget).data("roll-id")
let rollData = CrucibleUtility.getRollData(rollId)
let rollData = WarheroUtility.getRollData(rollId)
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
if (defender && (game.user.isGM || defender.isOwner)) {
defender.rollDefenseRanged(rollData)
@@ -277,14 +269,14 @@ export class CrucibleUtility {
static async preloadHandlebarsTemplates() {
const templatePaths = [
'systems/fvtt-crucible-rpg/templates/editor-notes-gm.html',
'systems/fvtt-crucible-rpg/templates/partial-roll-select.html',
'systems/fvtt-crucible-rpg/templates/partial-actor-ability-block.html',
'systems/fvtt-crucible-rpg/templates/partial-actor-status.html',
'systems/fvtt-crucible-rpg/templates/partial-options-abilities.html',
'systems/fvtt-crucible-rpg/templates/partial-item-nav.html',
'systems/fvtt-crucible-rpg/templates/partial-item-description.html',
'systems/fvtt-crucible-rpg/templates/partial-actor-equipment.html'
'systems/fvtt-warhero/templates/editor-notes-gm.html',
'systems/fvtt-warhero/templates/partial-roll-select.html',
'systems/fvtt-warhero/templates/partial-actor-ability-block.html',
'systems/fvtt-warhero/templates/partial-actor-status.html',
'systems/fvtt-warhero/templates/partial-options-abilities.html',
'systems/fvtt-warhero/templates/partial-item-nav.html',
'systems/fvtt-warhero/templates/partial-item-description.html',
'systems/fvtt-warhero/templates/partial-actor-equipment.html'
]
return loadTemplates(templatePaths);
}
@@ -297,7 +289,7 @@ export class CrucibleUtility {
}
static findChatMessageId(current) {
return CrucibleUtility.getChatMessageId(CrucibleUtility.findChatMessage(current));
return WarheroUtility.getChatMessageId(WarheroUtility.findChatMessage(current));
}
static getChatMessageId(node) {
@@ -305,7 +297,7 @@ export class CrucibleUtility {
}
static findChatMessage(current) {
return CrucibleUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
return WarheroUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
}
static findNodeMatching(current, predicate) {
@@ -313,7 +305,7 @@ export class CrucibleUtility {
if (predicate(current)) {
return current;
}
return CrucibleUtility.findNodeMatching(current.parentElement, predicate);
return WarheroUtility.findNodeMatching(current.parentElement, predicate);
}
return undefined;
}
@@ -357,7 +349,7 @@ export class CrucibleUtility {
}
/* -------------------------------------------- */
static saveRollData(rollData) {
game.socket.emit("system.crucible-rpg", {
game.socket.emit("system.warhero-rpg", {
name: "msg_update_roll", data: rollData
}); // Notify all other clients of the roll
this.updateRollData(rollData)
@@ -380,7 +372,7 @@ export class CrucibleUtility {
name: defender.name,
alias: defender.name,
//user: defender.id,
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-request-defense.html`, rollData),
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-request-defense.html`, rollData),
whisper: [defender.id].concat(ChatMessage.getWhisperRecipients('GM')),
})
}
@@ -426,7 +418,7 @@ export class CrucibleUtility {
/* -------------------------------------------- */
static async getFumble(weapon) {
const pack = game.packs.get("fvtt-crucible-rpg.rolltables")
const pack = game.packs.get("fvtt-warhero.rolltables")
const index = await pack.getIndex()
let entry
@@ -456,16 +448,16 @@ export class CrucibleUtility {
result.damageWeaponFormula = result.defenderDamage + dmgDice
result.defenderHPLossValue = await defender.incDecHP("-" + result.damageWeaponFormula)
}
if (result.fumble || (result.dangerous_fumble && CrucibleUtility.isWeaponDangerous(rollData.attackRollData.weapon))) {
if (result.fumble || (result.dangerous_fumble && WarheroUtility.isWeaponDangerous(rollData.attackRollData.weapon))) {
result.fumbleDetails = await this.getFumble(rollData.weapon)
}
if (result.critical_1 || result.critical_2) {
let isDeadly = CrucibleUtility.isWeaponDeadly(rollData.attackRollData.weapon)
let isDeadly = WarheroUtility.isWeaponDeadly(rollData.attackRollData.weapon)
result.critical = await this.getCritical((result.critical_1) ? "I" : "II", rollData.attackRollData.weapon)
result.criticalText = result.critical.text
}
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-attack-defense-result.html`, rollData)
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-attack-defense-result.html`, rollData)
})
console.log("Results processed", rollData)
}
@@ -490,7 +482,7 @@ export class CrucibleUtility {
if (game.user.isGM) {
this.processSuccessResult(rollData)
} else {
game.socket.emit("system.fvtt-crucible-rpg", { msg: "msg_gm_process_attack_defense", data: rollData });
game.socket.emit("system.fvtt-warhero", { msg: "msg_gm_process_attack_defense", data: rollData });
}
}
}
@@ -583,7 +575,7 @@ export class CrucibleUtility {
}
/* -------------------------------------------- */
static async rollCrucible(rollData) {
static async rollWarhero(rollData) {
let actor = game.actors.get(rollData.actorId)
@@ -622,9 +614,9 @@ export class CrucibleUtility {
if (rollData.skill.system.isfeatdie) {
rollData.hasFeatDie = true
diceFormula += "+ 1d10cs>=5[crucible-purple]"
diceFormula += "+ 1d10cs>=5[warhero-purple]"
} else {
diceFormula += `+ 0d10cs>=5[crucible-purple]`
diceFormula += `+ 0d10cs>=5[warhero-purple]`
}
if (rollData.skill.system.bonusdice != "none") {
rollData.hasBonusDice = rollData.skill.system.bonusdice
@@ -639,10 +631,10 @@ export class CrucibleUtility {
// advantage => 8
let advFormula = "+ 0d8cs>=5"
if (rollData.advantage == "advantage1" || rollData.forceAdvantage) {
advFormula = "+ 1d8cs>=5[crucible-darkgreen]"
advFormula = "+ 1d8cs>=5[warhero-darkgreen]"
}
if (rollData.advantage == "advantage2") {
advFormula = "+ 2d8cs>=5[crucible-darkgreen]"
advFormula = "+ 2d8cs>=5[warhero-darkgreen]"
}
diceFormula += advFormula
@@ -699,7 +691,7 @@ export class CrucibleUtility {
rollData.rollOrder = 1
rollData.rollType = (rollData.rollAdvantage == "roll-advantage") ? "Advantage" : "Disadvantage"
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
})
rollData.rollOrder = 2
@@ -709,7 +701,7 @@ export class CrucibleUtility {
rollData.roll = myRoll2 // Tmp switch to display the proper results
rollData.nbSuccess = myRoll2.total
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
})
rollData.roll = myRoll // Revert the tmp switch
rollData.nbSuccess = myRoll.total
@@ -743,7 +735,7 @@ export class CrucibleUtility {
actor.lastRoll = rollData
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-crucible-rpg/templates/chat-generic-result.html`, rollData)
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
})
console.log("Rolldata result", rollData)
@@ -794,7 +786,7 @@ export class CrucibleUtility {
chatGM.whisper = this.getUsers(user => user.isGM);
chatGM.content = "Blinde message of " + game.user.name + "<br>" + chatOptions.content;
console.log("blindMessageToGM", chatGM);
game.socket.emit("system.fvtt-crucible-rpg", { msg: "msg_gm_chat_message", data: chatGM });
game.socket.emit("system.fvtt-warhero", { msg: "msg_gm_chat_message", data: chatGM });
}
@@ -855,13 +847,13 @@ export class CrucibleUtility {
rollMode: game.settings.get("core", "rollMode"),
advantage: "none"
}
CrucibleUtility.updateWithTarget(rollData)
WarheroUtility.updateWithTarget(rollData)
return rollData
}
/* -------------------------------------------- */
static updateWithTarget(rollData) {
let target = CrucibleUtility.getTarget()
let target = WarheroUtility.getTarget()
if (target) {
rollData.defenderTokenId = target.id
}