Rollable weapons

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

View File

@ -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"
}

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

View File

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

View File

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

View File

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

View File

@ -17,11 +17,10 @@
<div class="select is-fullwidth">
<select name="data.category" data-dtype="String">
{{#select data.data.category}}
<option value="Wizard">Wizard</option>
<option value="Apprentice">Apprentice</option>
<option value="Soldier">Soldier</option>
<option value="Creature">Creature</option>
<option value="Base">Base</option>
<option value="Wizard">{{localize Wizard}}</option>
<option value="Apprentice">{{localize Apprentice}}</option>
<option value="Soldier">{{localize Soldier}}</option>
<option value="Creature">{{localize Creature}}</option>
{{/select}}
</select>
</div>
@ -32,34 +31,34 @@
<select name="data.class" data-dtype="String">
{{#select data.data.class}}
{{#if (or (eq data.data.category "Wizard") (eq data.data.category "Apprentice"))}}
<option value="Chronomancer">Chronomancer</option>
<option value="Elementalist">Elementalist</option>
<option value="Enchanter">Enchanter</option>
<option value="Illusionist">Illusionist</option>
<option value="Necromancer">Necromancer</option>
<option value="Sigilist">Sigilist</option>
<option value="Soothsayer">Soothsayer</option>
<option value="Summoner">Summoner</option>
<option value="Thaumaturge">Thaumaturge</option>
<option value="Witch">Witch</option>
<option value="Chronomancer">{{localize Chronomancer}}</option>
<option value="Elementalist">{{localize Elementalist}}</option>
<option value="Enchanter">{{localize Enchanter}}</option>
<option value="Illusionist">{{localize Illusionist}}</option>
<option value="Necromancer">{{localize Necromancer}}</option>
<option value="Sigilist">{{localize Sigilist}}</option>
<option value="Soothsayer">{{localize Soothsayer}}</option>
<option value="Summoner">{{localize Summoner}}</option>
<option value="Thaumaturge">{{localize Thaumaturge}}</option>
<option value="Witch">{{localize Witch}}</option>
{{/if}}
{{#if (eq data.data.category "Soldier")}}
<option value="Standard">Standard</option>
<option value="Specialist">Specialist</option>
<option value="Standard">{{localize Standard}}</option>
<option value="Specialist">{{localize Specialist}}</option>
{{/if}}
{{#if (eq data.data.category "Creature")}}
<option value="Uncontrolled">Uncontrolled</option>
<option value="Controlled">Controlled</option>
<option value="Uncontrolled">{{localize Uncontrolled}}</option>
<option value="Controlled">{{localize Controlled}}</option>
{{/if}}
{{#if (eq data.data.category "Base")}}
<option value="Inn">Inn</option>
<option value="Temple">Temple</option>
<option value="Crypt">Crypt</option>
<option value="Tower">Tower</option>
<option value="Treasury">Treasury</option>
<option value="Brewery">Brewery</option>
<option value="Library">Library</option>
<option value="Laboratory">Laboratory</option>
<option value="Inn">{{localize Inn}}</option>
<option value="Temple">{{localize Temple}}</option>
<option value="Crypt">{{localize Crypt}}</option>
<option value="Tower">{{localize Tower}}</option>
<option value="Treasury">{{localize Treasury}}</option>
<option value="Brewery">{{localize Brewery}}</option>
<option value="Library">{{localize Library}}</option>
<option value="Laboratory">{{localize Laboratory}}</option>
{{/if}}
{{/select}}
</select>

View File

@ -14,26 +14,19 @@
<i class="fas fa-dice-d20"></i>
</span>
<span>
Health
{{localize "FROSTGRAVE.Health"}}
</span> </button>
</p>
</div>
<div class="column">
<p class="control">
<span class="help">Actual</span>
<input class="input" type="text" name="data.health.actual" value="{{data.data.health.actual}}"
data-dtype="Number">
</p>
</div>
<div class="column">
<span class="help">Effective</span>
<span class="help">{{localize "FROSTGRAVE.Max"}}</span>
<p class="control">
<input class="input" type="text" name="data.health.max" value="{{data.data.health.max}}"
data-dtype="Number">
</p>
</div>
<div class="column">
<span class="help">Current</span>
<span class="help">{{localize "FROSTGRAVE.Current"}}</span>
<p class="control">
<input class="input is-danger" type="text" name="data.health.value" value="{{data.data.health.value}}"
data-dtype="Number">
@ -59,35 +52,26 @@
<i class="fas fa-dice-d20"></i>
</span>
<span>
{{key}}
{{localize key}}
</span>
</button>
</p>
</div>
<div class="column">
<p class="control">
<span class="help">Actual
<span class="help">{{localize "FROSTGRAVE.Actual"}}
</p>
<input class="input" type="text" name="data.stats.{{key}}.actual" value="{{stat.actual}}"
data-dtype="Number">
</p>
</div>
<div class="column">
<span class="help">Effective</span>
<span class="help">{{localize "FROSTGRAVE.Max"}}</span>
<p class="control">
<input class="input" type="text" name="data.stats.{{key}}.effective" value="{{stat.effective}}"
data-dtype="Number">
</p>
</div>
{{#if (or (eq key "fight") (eq key "shoot"))}}
<div class="column">
<span class="help">Dmg. Bonus</span>
<p class="control">
<input class="input" type="text" name="data.stats.{{key}}.bonus" value="{{stat.bonus}}"
data-dtype="Number">
</p>
</div>
{{/if}}
</div>
</div>

View File

@ -3,17 +3,17 @@
<div class="columns">
<div class="column">
<label class="label">Level</label>
<label class="label">{{localize "FROSTGRAVE.Level"}}</label>
<input class="input" name="data.level" type="text" value="{{data.data.level}}" data-dtype="Number" />
</div>
<div class="column">
<label class="label">Scenario Experience</label>
<label class="label">{{localize "FROSTGRAVE.ScenarioExperience"}}</label>
<input class="input" name="data.expscenario" type="text" value="{{data.data.expscenario}}" data-dtype="Number" />
</div>
<div class="column">
<label class="label">Banked Experience</label>
<label class="label">{{localize "FROSTGRAVE.BankedExperience"}}</label>
<input class="input" name="data.expbanked" type="text" value="{{data.data.expbanked}}" data-dtype="Number" />
</div>
@ -21,7 +21,7 @@
<progress class="progress is-large is-info" value="{{data.data.exptotal}}" max="100"></progress>
<h2 class="mb-2">Leveling Log</h2>
<h2 class="mb-2">{{localize "FROSTGRAVE.LevellingLog"}}</h2>
{{editor content=data.data.levellog target="data.levellog" button=true owner=owner editable=editable}}
</div>

View File

@ -30,7 +30,7 @@
</div>
<div class="media-content">
{{#if (ne item.data.data.damage null)}}
<div class="is-capitalized is-size-5 has-text-weight-bold"><a>{{item.name}} <i class="fas fa-dice-d20"></i></a></div>
<div class="is-capitalized is-size-5 has-text-weight-bold weapon-attack"><a>{{item.name}} <i class="fas fa-dice-d20"></i></a></div>
{{else}}
<div class="is-capitalized is-size-5 has-text-weight-bold">{{item.name}}</div>
{{/if}}
@ -48,7 +48,7 @@
{{#if (ne item.data.data.damage null)}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-info">Damage</span>
<span class="tag is-info">{{localize Damage}}</span>
<span class="tag is-info is-light">{{item.data.data.damage}}</span>
</div>
</div>
@ -57,7 +57,7 @@
{{#if (ne item.data.data.range null)}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-info">Range</span>
<span class="tag is-info">{{localize Range}}</span>
<span class="tag is-info is-light">{{item.data.data.range}}</span>
</div>
</div>
@ -66,7 +66,7 @@
{{#if (ne item.data.data.armour null)}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-info">Armour</span>
<span class="tag is-info">{{localize Armour}}</span>
<span class="tag is-info is-light">{{item.data.data.armour}}</span>
</div>
</div>
@ -75,7 +75,7 @@
{{#if (and (ne item.data.data.effect "") (ne item.data.data.effect null))}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-primary">Effect</span>
<span class="tag is-primary">{{localize Effect}}</span>
<span class="tag is-primary is-light">{{item.data.effect}}</span>
</div>
</div>
@ -84,7 +84,7 @@
{{#if (ne item.data.data.price null)}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-warning">Price</span>
<span class="tag is-warning">{{localize Price}}</span>
<span class="tag is-warning is-light">{{item.data.data.price}}</span>
</div>
</div>
@ -93,7 +93,7 @@
{{#if (ne item.data.data.sale null)}}
<div class="control">
<div class="tags has-addons">
<span class="tag is-warning">Sale</span>
<span class="tag is-warning">{{localize Sale}}</span>
<span class="tag is-warning is-light">{{item.data.data.sale}}</span>
</div>
</div>
@ -110,7 +110,7 @@
<span class="icon is-small">
<i class="fas fa-plus"></i>
</span>
<span>Add Item</span>
<span>{{localize "FROSTGRAVE.AddItem"}}</span>
</button>
</div>

View File

@ -1,13 +1,13 @@
<div class="sheet-tabs tabs is-medium is-centered" data-group="primary">
<ul>
<li><a class="item" data-tab="items">{{#if (eq data.category "Base")}}Vault{{else}}Items{{/if}}</a></li>
<li><a class="item" data-tab="items">{{localize "FROSTGRAVE.Items"}}</a></li>
{{#if (eq data.data.category "Base")}}
<li><a class="item" data-tab="homebase">Homebase</a></li>
{{#if (eq data.data.category "Wizard")}}
<li><a class="item" data-tab="homebase">{{localize "FROSTGRAVE.Homebase"}}</a></li>
{{/if}}
{{#if (or (eq data.data.category "Wizard") (eq data.category "Apprentice"))}}
<li><a class="item" data-tab="spells">Spells</a></li>
<li><a class="item" data-tab="spells">{{localize "FROSTGRAVE.Spells"}}</a></li>
{{/if}}
{{#if (eq data.data.category "Wizard")}}