Rollable weapons

This commit is contained in:
2021-05-31 00:06:05 +02:00
parent d3eba25f83
commit 9ed56cd435
11 changed files with 144 additions and 71 deletions

View File

@@ -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");

View File

@@ -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();
}
}