diff --git a/lang/en.json b/lang/en.json index 077404a..482d28c 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,3 +1,17 @@ { - + "FROSTGRAVE.Homebase": "Homebase", + "FROSTGRAVE.Level": "Level", + "FROSTGRAVE.ScenarioExperience": "Scenario Experience", + "FROSTGRAVE.BankedExperience": "Banked Experience", + "FROSTGRAVE.LevellingLog": "Levelling log", + "FROSTGRAVE.Health": "Health", + "FROSTGRAVE.Max": "Max", + "FROSTGRAVE.Current": "Current", + "FROSTGRAVE.Actual": "Actual", + "FROSTGRAVE.Spells": "Spells", + "FROSTGRAVE.Items": "Items", + "FROSTGRAVE.AddItem":"Add Item", + + "FROSTGRAVE.SelectTargetNeeded": "You must select a target to attack with a Weapon" + } \ No newline at end of file diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js index 410e213..0f5b60b 100644 --- a/module/actor/actor-sheet.js +++ b/module/actor/actor-sheet.js @@ -55,10 +55,17 @@ export class frostgraveActorSheet extends ActorSheet { // Edit Inventory Item html.find(".item-edit").click((ev) => { const card = $(ev.currentTarget).parents(".item-card"); - const item = this.actor.getOwnedItem(card.data("item-id")); + const item = this.actor.items.get(card.data("item-id")); item.sheet.render(true); }); + html.find(".weapon-attack a").click((ev) => { + const card = $(ev.currentTarget).parents(".item-card"); + const item = this.actor.items.get(card.data("item-id")); + console.log("ACTOR: ", this.actor); + this.actor.attackWeapon(item); + }); + // Delete Inventory Item html.find(".item-delete").click((ev) => { const card = $(ev.currentTarget).parents(".item-card"); diff --git a/module/actor/actor.js b/module/actor/actor.js index 74e4b16..6bc6f85 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -1,3 +1,4 @@ +import { FrostgraveUtility } from "../frostgrave-utility.js"; /** * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * @extends {Actor} @@ -30,4 +31,27 @@ export class frostgraveActor extends Actor { data.exptotal = data.expscenario + data.expbanked; } + async attackWeapon( weapon ) { + + let target = FrostgraveUtility.getTarget(); + if ( target == undefined) { + ui.notifications.warn(game.i18n.localize("FROSTGRAVE.SelectTargetNeeded")); + return; + } + + let stat + if ( FrostgraveUtility.isRanged( weapon.data.data.subcategory)) { + stat = this.data.data.stats.shoot; + console.log("TIR"); + } else { + stat = this.data.data.stats.fight; + console.log("CC"); + } + + let roll = new Roll("1d20+"+stat.actual); + let score = roll.evaluate( {async:false}).total; + await FrostgraveUtility.showDiceSoNice(roll); + roll.toMessage(); + } + } \ No newline at end of file diff --git a/module/frostgrave-utility.js b/module/frostgrave-utility.js new file mode 100644 index 0000000..f5a6cef --- /dev/null +++ b/module/frostgrave-utility.js @@ -0,0 +1,44 @@ +/* -------------------------------------------- */ +export class FrostgraveUtility { + + static isRanged( subcategory ) { + if (subcategory == 'Bow' || subcategory == 'Crossbow') + return true; + return false; + } + + /* -------------------------------------------- */ + static getTarget() { + if (game.user.targets && game.user.targets.size == 1) { + for (let target of game.user.targets) { + return target; + } + } + return undefined; + } + + /* -------------------------------------------- */ + static async showDiceSoNice(roll, rollMode = undefined) { + if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) { + let whisper = null; + let blind = false; + rollMode = rollMode ?? game.settings.get("core", "rollMode"); + switch (rollMode) { + case "blindroll": //GM only + blind = true; + case "gmroll": //GM + rolling player + whisper = ChatUtility.getUsers(user => user.isGM); + break; + case "roll": //everybody + whisper = ChatUtility.getUsers(user => user.active); + break; + case "selfroll": + whisper = [game.user.id]; + break; + } + await game.dice3d.showForRoll(roll, game.user, true, whisper, blind); + } + } + + +} diff --git a/module/frostgrave.js b/module/frostgrave.js index 30660a5..68465d0 100644 --- a/module/frostgrave.js +++ b/module/frostgrave.js @@ -21,12 +21,13 @@ Hooks.once("init", async function () { }; // Define custom Entity classes - CONFIG.Actor.documentClas = frostgraveActor; - CONFIG.Item.documentClas = frostgraveItem; + CONFIG.Actor.documentClass = frostgraveActor; + CONFIG.Item.documentClass = frostgraveItem; // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); Actors.registerSheet("foundryvtt-frostgrave", frostgraveActorSheet, { + types: ["character"], makeDefault: true, }); Items.unregisterSheet("core", ItemSheet); diff --git a/system.json b/system.json index a0a9f16..022ed8f 100644 --- a/system.json +++ b/system.json @@ -2,10 +2,10 @@ "name": "foundryvtt-frostgrave", "title": "Frostgrave", "description": "The Frostgrave system for Foundry VTT", - "version": "2.0.1", + "version": "2.0.2", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "0.8.5", - "templateVersion": 3, + "templateVersion": 4, "author": "LeRatierBretonnien/Phenomen", "esmodules": [ "module/frostgrave.js" diff --git a/templates/actor/partials/actor-header.html b/templates/actor/partials/actor-header.html index ebc8101..73687e7 100644 --- a/templates/actor/partials/actor-header.html +++ b/templates/actor/partials/actor-header.html @@ -17,11 +17,10 @@
- Actual - -
-
@@ -59,35 +52,26 @@ - {{key}} + {{localize key}}
- Actual + {{localize "FROSTGRAVE.Actual"}}
- -
-