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 @@
@@ -32,34 +31,34 @@ diff --git a/templates/actor/partials/actor-stats.html b/templates/actor/partials/actor-stats.html index 3d89248..45cfff9 100644 --- a/templates/actor/partials/actor-stats.html +++ b/templates/actor/partials/actor-stats.html @@ -14,26 +14,19 @@ - Health + {{localize "FROSTGRAVE.Health"}}

-

- Actual - -

-
-
- Effective + {{localize "FROSTGRAVE.Max"}}

- Current + {{localize "FROSTGRAVE.Current"}}

@@ -59,35 +52,26 @@ - {{key}} + {{localize key}}

- Actual + {{localize "FROSTGRAVE.Actual"}}

- Effective + {{localize "FROSTGRAVE.Max"}}

- {{#if (or (eq key "fight") (eq key "shoot"))}} -
- Dmg. Bonus -

- -

-
- {{/if}} diff --git a/templates/actor/partials/actor-tab-experience.html b/templates/actor/partials/actor-tab-experience.html index 45a95e2..183b937 100644 --- a/templates/actor/partials/actor-tab-experience.html +++ b/templates/actor/partials/actor-tab-experience.html @@ -3,17 +3,17 @@
- +
- +
- +
@@ -21,7 +21,7 @@ -

Leveling Log

+

{{localize "FROSTGRAVE.LevellingLog"}}

{{editor content=data.data.levellog target="data.levellog" button=true owner=owner editable=editable}}
\ No newline at end of file diff --git a/templates/actor/partials/actor-tab-items.html b/templates/actor/partials/actor-tab-items.html index 7397236..802b1b5 100644 --- a/templates/actor/partials/actor-tab-items.html +++ b/templates/actor/partials/actor-tab-items.html @@ -30,7 +30,7 @@
{{#if (ne item.data.data.damage null)}} -
{{item.name}}
+
{{item.name}}
{{else}}
{{item.name}}
{{/if}} @@ -48,7 +48,7 @@ {{#if (ne item.data.data.damage null)}}
- Damage + {{localize Damage}} {{item.data.data.damage}}
@@ -57,7 +57,7 @@ {{#if (ne item.data.data.range null)}}
- Range + {{localize Range}} {{item.data.data.range}}
@@ -66,7 +66,7 @@ {{#if (ne item.data.data.armour null)}}
- Armour + {{localize Armour}} {{item.data.data.armour}}
@@ -75,7 +75,7 @@ {{#if (and (ne item.data.data.effect "") (ne item.data.data.effect null))}}
- Effect + {{localize Effect}} {{item.data.effect}}
@@ -84,7 +84,7 @@ {{#if (ne item.data.data.price null)}}
- Price + {{localize Price}} {{item.data.data.price}}
@@ -93,7 +93,7 @@ {{#if (ne item.data.data.sale null)}}
- Sale + {{localize Sale}} {{item.data.data.sale}}
@@ -110,7 +110,7 @@ - Add Item + {{localize "FROSTGRAVE.AddItem"}}
\ No newline at end of file diff --git a/templates/actor/partials/actor-tab-navigation.html b/templates/actor/partials/actor-tab-navigation.html index a569bd4..c11450c 100644 --- a/templates/actor/partials/actor-tab-navigation.html +++ b/templates/actor/partials/actor-tab-navigation.html @@ -1,13 +1,13 @@