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)
});
html.find('.roll-armor-die').click((event) => {
//TODO
ui.notifications.warn("Not implemented")
this.actor.rollArmorDie()
});
html.find('.roll-shield-die').click((event) => {
//TODO
ui.notifications.warn("Not implemented")
this.actor.rollShieldDie()
});
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) {
let saves = this.getSaveRoll()

View File

@ -7,11 +7,11 @@ import { CrucibleRollDialog } from "./crucible-roll-dialog.js";
export class CrucibleCommands {
static init() {
if (!game.system.crucible.commands) {
if (!game.system.cruciblerpg.commands) {
const crucibleCommands = new CrucibleCommands();
//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" });
game.system.crucible.commands = crucibleCommands;
game.system.cruciblerpg.commands = crucibleCommands;
}
}
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 { CrucibleCombat } from "./crucible-combat.js";
import { CrucibleItem } from "./crucible-item.js";
import { CrucibleHotbar } from "./crucible-hotbar.js"
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -22,8 +23,13 @@ import { CrucibleItem } from "./crucible-item.js";
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Crucible RPG`);
game.system.cruciblerpg = {
CrucibleHotbar
}
/* -------------------------------------------- */
// preload handlebars templates
CrucibleUtility.preloadHandlebarsTemplates();
@ -56,7 +62,6 @@ Hooks.once("init", async function () {
CONFIG.Actor.documentClass = CrucibleActor
CONFIG.Item.documentClass = CrucibleItem
//CONFIG.Token.objectClass = CrucibleToken
game.system.crucible = { };
/* -------------------------------------------- */
// Register sheet application classes
@ -67,8 +72,7 @@ Hooks.once("init", async function () {
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-crucible", CrucibleItemSheet, { makeDefault: true });
CrucibleUtility.init();
CrucibleUtility.init()
});
/* -------------------------------------------- */
@ -103,6 +107,7 @@ Hooks.once("ready", function () {
welcomeMessage();
CrucibleUtility.ready()
CrucibleHotbar.init()
})
/* -------------------------------------------- */

View File

@ -285,6 +285,9 @@ export class CrucibleUtility {
if ( rollData.save) {
startFormula = String(rollData.save.value) + "d6cs>=5"
}
if ( rollData.shield) {
startFormula = "1" + String(rollData.shield.data.shielddie) + "cs>=5"
}
diceFormula = startFormula
// skill => 2
@ -344,7 +347,9 @@ export class CrucibleUtility {
// armor => 12
let skillArmorPenalty = 0
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 ) {
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":"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":"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":"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":{}}
@ -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":"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":"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",
"secondaryTokenAttribute": "secondary.delirium",
"primaryTokenAttribute": "secondary.hp",
"secondaryTokenAttribute": "secondary.effort",
"socket": true,
"styles": [
"styles/simple.css"

View File

@ -55,7 +55,7 @@
<li class="item flexrow list-item" data-attr-key="class">
<img class="sheet-competence-img" src="{{equippedShield.img}}" />
<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>
</li>
{{/if}}
@ -88,7 +88,7 @@
{{!-- Skills Tab --}}
<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">
<span class="item-name-label-header">
<h3><label class="items-title-text">Skills</label></h3>

View File

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

View File

@ -8,6 +8,13 @@
<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}}
<div class="flexrow">
<span class="roll-dialog-label">{{save.label}} : </span>