Add hotbar

This commit is contained in:
sladecraven 2022-08-04 16:28:10 +02:00
parent ea06648a67
commit f55fc1d59a
11 changed files with 149 additions and 18 deletions

View File

@ -153,12 +153,10 @@ export class CrucibleActorSheet extends ActorSheet {
this.actor.rollWeapon(skillId) this.actor.rollWeapon(skillId)
}); });
html.find('.roll-armor-die').click((event) => { html.find('.roll-armor-die').click((event) => {
//TODO this.actor.rollArmorDie()
ui.notifications.warn("Not implemented")
}); });
html.find('.roll-shield-die').click((event) => { html.find('.roll-shield-die').click((event) => {
//TODO this.actor.rollShieldDie()
ui.notifications.warn("Not implemented")
}); });
html.find('.roll-save').click((event) => { html.find('.roll-save').click((event) => {

View File

@ -570,6 +570,30 @@ export class CrucibleActor extends Actor {
} }
} }
} }
/* -------------------------------------------- */
rollShieldDie() {
let shield = this.getEquippedShield()
if (shield) {
shield = duplicate(shield)
let rollData = this.getCommonRollData()
rollData.mode = "shield"
rollData.shield = shield
rollData.img = shield.img
this.startRoll(rollData)
}
}
/* -------------------------------------------- */
rollArmorDie() {
let armor = this.getEquippedArmor()
if (armor) {
armor = duplicate(armor)
let diceValue = armor.data.absorprionroll
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
rollSave(saveKey) { rollSave(saveKey) {
let saves = this.getSaveRoll() let saves = this.getSaveRoll()

View File

@ -7,11 +7,11 @@ import { CrucibleRollDialog } from "./crucible-roll-dialog.js";
export class CrucibleCommands { export class CrucibleCommands {
static init() { static init() {
if (!game.system.crucible.commands) { if (!game.system.cruciblerpg.commands) {
const crucibleCommands = new CrucibleCommands(); const crucibleCommands = new CrucibleCommands();
//crucibleCommands.registerCommand({ path: ["/char"], func: (content, msg, params) => crucibleCommands.createChar(msg), descr: "Create a new character" }); //crucibleCommands.registerCommand({ path: ["/char"], func: (content, msg, params) => crucibleCommands.createChar(msg), descr: "Create a new character" });
//crucibleCommands.registerCommand({ path: ["/pool"], func: (content, msg, params) => crucibleCommands.poolRoll(msg), descr: "Generic Roll Window" }); //crucibleCommands.registerCommand({ path: ["/pool"], func: (content, msg, params) => crucibleCommands.poolRoll(msg), descr: "Generic Roll Window" });
game.system.crucible.commands = crucibleCommands; game.system.cruciblerpg.commands = crucibleCommands;
} }
} }
constructor() { constructor() {

View File

@ -0,0 +1,86 @@
export class CrucibleHotbar {
/**
* Create a macro when dropping an entity on the hotbar
* Item - open roll dialog for item
* Actor - open actor sheet
* Journal - open journal sheet
*/
static init( ) {
Hooks.on("hotbarDrop", async (bar, documentData, slot) => {
// Create item macro if rollable item - weapon, spell, prayer, trait, or skill
if (documentData.type == "Item") {
console.log("Drop done !!!", bar, documentData, slot)
let item = documentData.data
let command = `game.system.cruciblerpg.CrucibleHotbar.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({
name: item.name,
type: "script",
img: item.img,
command: command
}, { displaySheet: false })
}
game.user.assignHotbarMacro(macro, slot);
}
// Create a macro to open the actor sheet of the actor dropped on the hotbar
else if (documentData.type == "Actor") {
let actor = game.actors.get(documentData.id);
let command = `game.actors.get("${documentData.id}").sheet.render(true)`
let macro = game.macros.contents.find(m => (m.name === actor.name) && (m.command === command));
if (!macro) {
macro = await Macro.create({
name: actor.data.name,
type: "script",
img: actor.data.img,
command: command
}, { displaySheet: false })
game.user.assignHotbarMacro(macro, slot);
}
}
// Create a macro to open the journal sheet of the journal dropped on the hotbar
else if (documentData.type == "JournalEntry") {
let journal = game.journal.get(documentData.id);
let command = `game.journal.get("${documentData.id}").sheet.render(true)`
let macro = game.macros.contents.find(m => (m.name === journal.name) && (m.command === command));
if (!macro) {
macro = await Macro.create({
name: journal.data.name,
type: "script",
img: "",
command: command
}, { displaySheet: false })
game.user.assignHotbarMacro(macro, slot);
}
}
return false;
});
}
/** Roll macro */
static rollMacro(itemName, itemType, bypassData) {
const speaker = ChatMessage.getSpeaker()
let actor
if (speaker.token) actor = game.actors.tokens[speaker.token]
if (!actor) actor = game.actors.get(speaker.actor)
if (!actor) {
return ui.notifications.warn(`Select your actor to run the macro`)
}
let item = actor.items.find(it => it.name === itemName && it.type == itemType)
if (!item ) {
return ui.notifications.warn(`Unable to find the item of the macro in the current actor`)
}
// Trigger the item roll
if (item.type === "weapon") {
return actor.rollWeapon( item.id)
}
if (item.type === "skill") {
return actor.rollSkill( item.id)
}
}
}

View File

@ -15,6 +15,7 @@ import { CrucibleNPCSheet } from "./crucible-npc-sheet.js";
import { CrucibleUtility } from "./crucible-utility.js"; import { CrucibleUtility } from "./crucible-utility.js";
import { CrucibleCombat } from "./crucible-combat.js"; import { CrucibleCombat } from "./crucible-combat.js";
import { CrucibleItem } from "./crucible-item.js"; import { CrucibleItem } from "./crucible-item.js";
import { CrucibleHotbar } from "./crucible-hotbar.js"
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -22,7 +23,12 @@ import { CrucibleItem } from "./crucible-item.js";
/************************************************************************************/ /************************************************************************************/
Hooks.once("init", async function () { Hooks.once("init", async function () {
console.log(`Initializing Crucible RPG`); console.log(`Initializing Crucible RPG`);
game.system.cruciblerpg = {
CrucibleHotbar
}
/* -------------------------------------------- */ /* -------------------------------------------- */
// preload handlebars templates // preload handlebars templates
@ -56,7 +62,6 @@ Hooks.once("init", async function () {
CONFIG.Actor.documentClass = CrucibleActor CONFIG.Actor.documentClass = CrucibleActor
CONFIG.Item.documentClass = CrucibleItem CONFIG.Item.documentClass = CrucibleItem
//CONFIG.Token.objectClass = CrucibleToken //CONFIG.Token.objectClass = CrucibleToken
game.system.crucible = { };
/* -------------------------------------------- */ /* -------------------------------------------- */
// Register sheet application classes // Register sheet application classes
@ -67,8 +72,7 @@ Hooks.once("init", async function () {
Items.unregisterSheet("core", ItemSheet); Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-crucible", CrucibleItemSheet, { makeDefault: true }); Items.registerSheet("fvtt-crucible", CrucibleItemSheet, { makeDefault: true });
CrucibleUtility.init(); CrucibleUtility.init()
}); });
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -103,6 +107,7 @@ Hooks.once("ready", function () {
welcomeMessage(); welcomeMessage();
CrucibleUtility.ready() CrucibleUtility.ready()
CrucibleHotbar.init()
}) })
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -285,6 +285,9 @@ export class CrucibleUtility {
if ( rollData.save) { if ( rollData.save) {
startFormula = String(rollData.save.value) + "d6cs>=5" startFormula = String(rollData.save.value) + "d6cs>=5"
} }
if ( rollData.shield) {
startFormula = "1" + String(rollData.shield.data.shielddie) + "cs>=5"
}
diceFormula = startFormula diceFormula = startFormula
// skill => 2 // skill => 2
@ -344,7 +347,9 @@ export class CrucibleUtility {
// armor => 12 // armor => 12
let skillArmorPenalty = 0 let skillArmorPenalty = 0
for (let armor of rollData.armors) { for (let armor of rollData.armors) {
skillArmorPenalty += armor.data.skillpenalty if (armor.data.equipped) {
skillArmorPenalty += armor.data.skillpenalty
}
} }
if (rollData.skill && rollData.skill.data.armorpenalty && skillArmorPenalty > 0 ) { if (rollData.skill && rollData.skill.data.armorpenalty && skillArmorPenalty > 0 ) {
rollData.skillArmorPenalty = skillArmorPenalty rollData.skillArmorPenalty = skillArmorPenalty

View File

@ -13,7 +13,7 @@
{"_id":"Y4o571K5DQseDaGT","name":"Swim","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Swim.webp","data":{"ability":"str","armorpenalty":true,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Kick you feet and don't forget to breathe!</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"Y4o571K5DQseDaGT","name":"Swim","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Swim.webp","data":{"ability":"str","armorpenalty":true,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Kick you feet and don't forget to breathe!</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"ZfIwXZwaBKaVoYbG","name":"Athletics","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Athletics.png","data":{"ability":"agi","armorpenalty":true,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Your ability to run, jump, and climb; a measure of your physical coordination.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"ZfIwXZwaBKaVoYbG","name":"Athletics","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Athletics.png","data":{"ability":"agi","armorpenalty":true,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Your ability to run, jump, and climb; a measure of your physical coordination.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"cc74gHSQK4hRR8Vj","name":"Brawn","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Brawn.png","data":{"ability":"str","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>A combination of your Size and Strength.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"cc74gHSQK4hRR8Vj","name":"Brawn","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Brawn.png","data":{"ability":"str","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>A combination of your Size and Strength.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"fJjXMpUILcN983XV","name":"Axe","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/icon_skill.webp","data":{"ability":"agi","armorpenalty":false,"isproficient":true,"isweaponskill":true,"isshiedskill":false,"isfeatdie":false,"issl2":false,"islore":false,"skilltype":"complex","isinnate":false,"bonusdice":"none","background":0,"basic":0,"class":0,"exp":0,"explevel":0,"description":"","level":2,"isshieldskill":true},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{"core":{"sourceId":"Item.Cnw8keaxD1SI3vun"}}} {"_id":"fJjXMpUILcN983XV","name":"Axe","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/icon_skill.webp","data":{"ability":"agi","armorpenalty":false,"isproficient":true,"isweaponskill":true,"isshieldskill":true,"isfeatdie":false,"issl2":false,"islore":false,"skilltype":"complex","isinnate":false,"bonusdice":"none","background":0,"basic":0,"class":0,"exp":0,"explevel":0,"description":"","isshiedskill":false,"level":2},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{"core":{"sourceId":"Item.Cnw8keaxD1SI3vun"}}}
{"_id":"fegRI4Vsyr0Us1Ga","name":"Research","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Research.webp","data":{"ability":"int","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Give me a moment to look that up....</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"fegRI4Vsyr0Us1Ga","name":"Research","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Research.webp","data":{"ability":"int","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Give me a moment to look that up....</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"i8eeE2I9vv2kHwdJ","name":"Shadow Lore","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Shadow%20Lore.webp","data":{"ability":"int","armorpenalty":true,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>You can cast Shadow Lore spells.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"i8eeE2I9vv2kHwdJ","name":"Shadow Lore","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Shadow%20Lore.webp","data":{"ability":"int","armorpenalty":true,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>You can cast Shadow Lore spells.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"lfB80K2lFSzQH442","name":"Intuition","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Intuition.png","data":{"ability":"wit","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>I see what you did there.&nbsp; I think you're up to something....</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"lfB80K2lFSzQH442","name":"Intuition","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Intuition.png","data":{"ability":"wit","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>I see what you did there.&nbsp; I think you're up to something....</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
@ -23,5 +23,3 @@
{"_id":"s2AAQviLttcHul3X","name":"Charm","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Charm.png","data":{"ability":"cha","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Getting someone to do what you want because they want to do it.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"s2AAQviLttcHul3X","name":"Charm","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Charm.png","data":{"ability":"cha","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Getting someone to do what you want because they want to do it.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"xlYUHAUSfQrsjQoi","name":"Survival","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Survival.webp","data":{"ability":"wit","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Help me set this snare and we'll eat like kings in the morning.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"xlYUHAUSfQrsjQoi","name":"Survival","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Survival.webp","data":{"ability":"wit","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Help me set this snare and we'll eat like kings in the morning.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"yAhtkgqf7pKyjJTA","name":"Poison Use","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Poison%20Use.webp","data":{"ability":"dex","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Let me apply this to my blade.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}} {"_id":"yAhtkgqf7pKyjJTA","name":"Poison Use","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Poison%20Use.webp","data":{"ability":"dex","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Let me apply this to my blade.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"fJjXMpUILcN983XV","name":"Axe","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/icon_skill.webp","data":{"ability":"agi","armorpenalty":false,"isproficient":true,"isweaponskill":true,"isshieldskill":false,"isfeatdie":false,"issl2":false,"islore":false,"skilltype":"complex","isinnate":false,"bonusdice":"none","background":0,"basic":0,"class":0,"exp":0,"explevel":0,"description":"","isshiedskill":false,"level":2},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{"core":{"sourceId":"Item.Cnw8keaxD1SI3vun"}}}
{"_id":"fJjXMpUILcN983XV","name":"Axe","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/icon_skill.webp","data":{"ability":"agi","armorpenalty":false,"isproficient":true,"isweaponskill":true,"isshieldskill":true,"isfeatdie":false,"issl2":false,"islore":false,"skilltype":"complex","isinnate":false,"bonusdice":"none","background":0,"basic":0,"class":0,"exp":0,"explevel":0,"description":"","isshiedskill":false,"level":2},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{"core":{"sourceId":"Item.Cnw8keaxD1SI3vun"}}}

View File

@ -202,8 +202,8 @@
] ]
} }
], ],
"primaryTokenAttribute": "secondary.health", "primaryTokenAttribute": "secondary.hp",
"secondaryTokenAttribute": "secondary.delirium", "secondaryTokenAttribute": "secondary.effort",
"socket": true, "socket": true,
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"

View File

@ -55,7 +55,7 @@
<li class="item flexrow list-item" data-attr-key="class"> <li class="item flexrow list-item" data-attr-key="class">
<img class="sheet-competence-img" src="{{equippedShield.img}}" /> <img class="sheet-competence-img" src="{{equippedShield.img}}" />
<span class="ability-label " name="equippedShield"> <span class="ability-label " name="equippedShield">
<h4 class="ability-text-white ability-margin"><a class="roll-shield-die ability-margin">{{ability-margin.name}}</a></h4> <h4 class="ability-text-white ability-margin"><a class="roll-shield-die ability-margin">{{equippedShield.name}}</a></h4>
</span> </span>
</li> </li>
{{/if}} {{/if}}
@ -88,7 +88,7 @@
{{!-- Skills Tab --}} {{!-- Skills Tab --}}
<div class="tab skills" data-group="primary" data-tab="skills"> <div class="tab skills" data-group="primary" data-tab="skills">
<ul class="stat-list alternate-list"> <ul class="stat-list alternate-list item-list">
<li class="item flexrow list-item items-title-bg"> <li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header"> <span class="item-name-label-header">
<h3><label class="items-title-text">Skills</label></h3> <h3><label class="items-title-text">Skills</label></h3>

View File

@ -26,6 +26,14 @@
</li> </li>
{{/if}} {{/if}}
{{#if shield}}
<li>Shield : {{shield.name}} - {{shield.data.shieldie}}
({{#each roll.terms.0.results as |die idx|}}
{{die.result}}&nbsp;
{{/each}})
</li>
{{/if}}
{{#if ability}} {{#if ability}}
<li>Ability : {{ability.label}} - {{ability.value}}d6 <li>Ability : {{ability.label}} - {{ability.value}}d6
({{#each roll.terms.0.results as |die idx|}} ({{#each roll.terms.0.results as |die idx|}}
@ -35,7 +43,7 @@
{{/if}} {{/if}}
{{#if skill}} {{#if skill}}
<li>Skill : {{skill.name}} - {{skill.data.level}}d8 <li>Skill : {{skill.name}} - {{skill.data.skilldice}}
{{#if featSL}} {{#if featSL}}
- with Feat SL +{{featSL}} - with Feat SL +{{featSL}}
{{/if}} {{/if}}

View File

@ -8,6 +8,13 @@
<div class="flexcol"> <div class="flexcol">
{{#if shield}}
<div class="flexrow">
<span class="roll-dialog-label">{{shield.name}} : </span>
<span class="roll-dialog-label">{{shield.data.shielddie}}</span>
</div>
{{/if}}
{{#if save}} {{#if save}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">{{save.label}} : </span> <span class="roll-dialog-label">{{save.label}} : </span>