Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Sep 21, 2022
2 parents 66dd4db + b2ea21e commit 543aeec
Show file tree
Hide file tree
Showing 25 changed files with 225 additions and 339 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ wfrp4e-ua1:
wfrp4e-dotr:
wfrp4e-archives1:
wfrp4e-middenheim:
wfrp4e-archives1:
wfrp4e-pbtt:
wfrp4e-altdorf:
wfrp4e-ua2:
wfrp4e-owb1:
wfrp4e-horned-rat:
wfrp4e-empire-ruins:
8 changes: 4 additions & 4 deletions modules/actor/actor-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class ActorWfrp4e extends Actor {
createData.prototypeToken = data.prototypeToken

// Set custom default token
if (data.img == "icons/svg/mystery-man.svg") {
if (!data.img || data.img == "icons/svg/mystery-man.svg") {
createData.img = "systems/wfrp4e/tokens/unknown.png"
if (data.type == "vehicle")
createData.img = "systems/wfrp4e/tokens/vehicle.png"
Expand All @@ -94,7 +94,7 @@ export default class ActorWfrp4e extends Actor {
async _preUpdate(updateData, options, user) {
await super._preUpdate(updateData, options, user)

if (hasProperty(updateData, "system.status.advantage.value") && game.settings.get("wfrp4e", "useGroupAdvantage"))
if (!options.skipGroupAdvantage && hasProperty(updateData, "system.status.advantage.value") && game.settings.get("wfrp4e", "useGroupAdvantage"))
{
let combatant = game.combat?.getCombatantByActor(this.id)

Expand Down Expand Up @@ -376,7 +376,7 @@ export default class ActorWfrp4e extends Actor {
}
}

// this.checkWounds();
this.checkWounds();


if (this.isMounted && !game.actors) {
Expand Down Expand Up @@ -1566,7 +1566,7 @@ export default class ActorWfrp4e extends Actor {

// Update hook?
checkWounds() {
if (this.flags.autoCalcWounds) {
if (this.type != "vehicle" && this.flags.autoCalcWounds) {
let wounds = this._calculateWounds()

if (this.status.wounds.max != wounds) // If change detected, reassign max and current wounds
Expand Down
16 changes: 8 additions & 8 deletions modules/actor/sheet/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export default class ActorSheetWfrp4e extends ActorSheet {
async _handleEnrichment()
{
let enrichment = {}
enrichment["system.details.biography.value"] = await TextEditor.enrichHTML(this.actor.system.details.biography.value, {async: true})
enrichment["system.details.gmnotes.value"] = await TextEditor.enrichHTML(this.actor.system.details.gmnotes.value, {async: true})
enrichment["system.details.biography.value"] = await TextEditor.enrichHTML(this.actor.system.details.biography.value, {async: true, secrets: this.actor.isOwner, relativeTo: this.actor})
enrichment["system.details.gmnotes.value"] = await TextEditor.enrichHTML(this.actor.system.details.gmnotes.value, {async: true, secrets: this.actor.isOwner, relativeTo: this.actor})

return expandObject(enrichment)
}
Expand Down Expand Up @@ -1471,11 +1471,11 @@ export default class ActorSheetWfrp4e extends ActorSheet {
}

// Add condition description dropdown
_onConditionClicked(ev) {
async _onConditionClicked(ev) {
ev.preventDefault();
let li = $(ev.currentTarget).parents(".sheet-condition"),
elementToAddTo = $(ev.currentTarget).parents(".condition-list"),
condkey = li.attr("data-cond-id"), expandData = TextEditor.enrichHTML(`<h2>${game.wfrp4e.config.conditions[condkey]}</h2>` + game.wfrp4e.config.conditionDescriptions[condkey])
condkey = li.attr("data-cond-id"), expandData = await TextEditor.enrichHTML(`<h2>${game.wfrp4e.config.conditions[condkey]}</h2>` + game.wfrp4e.config.conditionDescriptions[condkey], {async: true})

if (elementToAddTo.hasClass("expanded")) {
let summary = elementToAddTo.parents(".effects").children(".item-summary");
Expand Down Expand Up @@ -1793,7 +1793,7 @@ export default class ActorSheetWfrp4e extends ActorSheet {
let system = duplicate(this.actor._source.system);
system.details.experience.total += dragData.payload;
system.details.experience.log = this.actor._addToExpLog(dragData.payload, "Character Creation", undefined, system.details.experience.total);
this.actor.update({ "data": data })
this.actor.update({ "system": system })
}

// From Income results - drag money value over to add
Expand Down Expand Up @@ -1894,12 +1894,12 @@ export default class ActorSheetWfrp4e extends ActorSheet {
*
* @param {Object} ev ev generated by the click
*/
_onItemSummary(ev) {
async _onItemSummary(ev) {
ev.preventDefault();
let li = $(ev.currentTarget).parents(".item"),
item = this.actor.items.get(li.attr("data-item-id"));
// Call the item's expandData() which gives us what to display
let expandData = item.getExpandData(
let expandData = await item.getExpandData(
{
secrets: this.actor.isOwner
});
Expand Down Expand Up @@ -2203,6 +2203,6 @@ export default class ActorSheetWfrp4e extends ActorSheet {

toggleItemCheckbox(itemId, target) {
let item = this.actor.items.get(itemId)
return item.update({ [`${target}`]: !getProperty(item.system, target) })
return item.update({ [`${target}`]: !getProperty(item, target) })
}
}
4 changes: 2 additions & 2 deletions modules/actor/sheet/creature-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ export default class ActorSheetWfrp4eCreature extends ActorSheetWfrp4e {
*
* @param {Object} event event fired from clicking on an item
*/
_onCreatureItemSummary(event) {
async _onCreatureItemSummary(event) {
event.preventDefault();
let li = $(event.currentTarget).parent('.list'),
item = this.actor.items.get($(event.currentTarget).attr("data-item-id")),
// Get expansion info to place in the dropdown
expandData = item.getExpandData(
expandData = await item.getExpandData(
{
secrets: this.actor.isOwner
});
Expand Down
7 changes: 3 additions & 4 deletions modules/actor/sheet/vehicle-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ export default class ActorSheetWfrp4eVehicle extends ActorSheetWfrp4e {

async _onDrop(event) {
let dragData = JSON.parse(event.dataTransfer.getData("text/plain"));
let actor = await Actor.implementation.fromDropData(dragData)

if (actor)

if (dragData?.type == "Actor")
{
let actor = await fromUuid(dragData.uuid)
let passengers = duplicate(this.actor.system.passengers);
passengers.push({ id: actor.id, count: 1 });
this.actor.update({ "system.passengers": passengers })

}
else return super._onDrop(event);
}
Expand Down
56 changes: 40 additions & 16 deletions modules/apps/roll-dialog.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import WFRP_Utility from "../system/utility-wfrp4e";

export default class RollDialog extends Dialog {

static get defaultOptions() {
Expand All @@ -14,25 +16,22 @@ export default class RollDialog extends Dialog {
let modifier = html.find('[name="testModifier"]')[0]
let successBonus = html.find('[name="successBonus"]')[0]

modifier.value = (this.userEntry.testModifier || 0) + (this.cumulativeBonuses.testModifier || 0)


// Called Shot
if (this.selectedHitLocation?.value && !["none", "roll"].includes(this.selectedHitLocation.value))
{

if (!this.data.testData.deadeyeShot && !(this.data.testData.strikeToStun && this.selectedHitLocation.value == "head")) // Deadeye shot and strike to stun not applied
modifier.value -= 20;
}
modifier.value =
(this.userEntry.testModifier || 0) +
(this.cumulativeBonuses.testModifier || 0) +
(this.userEntry.calledShot || 0)


if (!game.settings.get("wfrp4e", "mooAdvantage"))
if (!game.settings.get("wfrp4e", "mooAdvantage") && game.settings.get("wfrp4e", "autoFillAdvantage"))
modifier.value = Number(modifier.value) + (game.settings.get("wfrp4e", "advantageBonus") * this.advantage || 0) || 0

successBonus.value = (this.userEntry.successBonus || 0) + (this.cumulativeBonuses.successBonus || 0)
//@HOUSE
if (game.settings.get("wfrp4e", "mooAdvantage"))
{
successBonus.value = Number(successBonus.value) + Number(this.advantage || 0)
WFRP_Utility.logHomebrew("mooAdvantage")
}
//@/HOUSE

html.find('[name="slBonus"]')[0].value = (this.userEntry.slBonus || 0) + (this.cumulativeBonuses.slBonus || 0)
Expand Down Expand Up @@ -63,10 +62,22 @@ export default class RollDialog extends Dialog {
}).val());

html.find('[name="charging"]').change(ev => {

let onlyModifier = game.settings.get("wfrp4e","useGroupAdvantage");
if (ev.target.checked)
game.settings.get("wfrp4e","useGroupAdvantage") ? this.userEntry.testModifier += (+10) : this.changeAdvantage((this.advantage || 0) + 1)
else if (this.advantage >= 1)
game.settings.get("wfrp4e","useGroupAdvantage") ? this.userEntry.testModifier += (-10) : this.changeAdvantage((this.advantage || 0) - 1)
{
// If advantage cap, only add modifier if at cap
if (!onlyModifier && game.settings.get("wfrp4e", "capAdvantageIB"))
{
onlyModifier = (this.advantage >= this.data.actor.characteristics.i.bonus)
}

onlyModifier ? this.userEntry.testModifier += (+10) : this.changeAdvantage((this.advantage || 0) + 1)
}
else
{
onlyModifier ? this.userEntry.testModifier += (-10) : this.changeAdvantage((this.advantage || 0) - 1)
}

html.find('[name="advantage"]')[0].value = this.advantage
this.updateValues(html)
Expand Down Expand Up @@ -97,7 +108,7 @@ export default class RollDialog extends Dialog {

this.userEntry.testModifier = Number(html.find('[name="testModifier"]').change(ev => {
this.userEntry.testModifier = Number(ev.target.value)
if (!game.settings.get("wfrp4e", "mooAdvantage"))
if (!game.settings.get("wfrp4e", "mooAdvantage") && game.settings.get("wfrp4e", "autoFillAdvantage"))
this.userEntry.testModifier -= (game.settings.get("wfrp4e", "advantageBonus") * this.advantage || 0) || 0

this.updateValues(html)
Expand All @@ -117,12 +128,25 @@ export default class RollDialog extends Dialog {
this.updateValues(html)
}).val()

this.userEntry.calledShot = 0;
this.selectedHitLocation = html.find('[name="selectedHitLocation"]').change(ev => {
// Called Shot - If targeting a specific hit location
if (ev.currentTarget.value && !["none", "roll"].includes(ev.currentTarget.value))
{
// If no talents prevent the penalty from being applied
if (!this.data.testData.deadeyeShot && !(this.data.testData.strikeToStun && this.selectedHitLocation.value == "head")) // Deadeye shot and strike to stun not applied
this.userEntry.calledShot = -20;
else
this.userEntry.calledShot = 0;
}
else {
this.userEntry.calledShot = 0;
}
this.updateValues(html);
})[0]


if (!game.settings.get("wfrp4e", "mooAdvantage"))
if (!game.settings.get("wfrp4e", "mooAdvantage") && game.settings.get("wfrp4e", "autoFillAdvantage"))
this.userEntry.testModifier -= (game.settings.get("wfrp4e", "advantageBonus") * this.advantage || 0)
else if (game.settings.get("wfrp4e", "mooAdvantage"))
this.userEntry.successBonus -= (this.advantage || 0)
Expand Down
12 changes: 10 additions & 2 deletions modules/apps/table-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ export default class WFRPTableConfig extends RollTableConfig {
return mergeObject(super.defaultOptions, {width: 725})
}

get template() {
return "systems/wfrp4e/templates/apps/table-config.html"
activateListeners(html)
{
super.activateListeners(html);

html.prepend($(`<div class="form-group">
<label>${game.i18n.localize("TABLE.Key")}</label>
<input type="text" name="flags.wfrp4e.key" value="${this.object.flags.wfrp4e?.key || ""}"/>
<label>${game.i18n.localize("TABLE.Column")}</label>
<input type="text" name="flags.wfrp4e.column" value="${this.object.flags.wfrp4e?.column || ""}"/>
</div>`))
}
}
11 changes: 9 additions & 2 deletions modules/apps/wfrp-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,14 @@ export default class BrowserWfrp4e extends Application {
async loadItems() {
this.items = [];
this.filterId = 0;

let packCount = game.packs.size;
let packCounter = 0;

for (let p of game.packs) {
packCounter++;
SceneNavigation.displayProgressBar({label: game.i18n.localize("BROWSER.LoadingBrowser"), pct: (packCounter / packCount)*100 })

if (p.metadata.type == "Item" && (game.user.isGM || !p.private)) {
await p.getDocuments().then(content => {
this.addItems(content)
Expand Down Expand Up @@ -525,8 +532,8 @@ export default class BrowserWfrp4e extends Application {

Hooks.on("renderCompendiumDirectory", (app, html, data) => {
if (game.user.isGM || game.settings.get("wfrp4e", "playerBrowser")) {
const button = $(`<button class="browser-btn">${game.i18n.localize("BROWSER.Button")}</button>`);
html.find(".directory-footer").append(button);
const button = $(`<button class="browser-btn" data-tooltip="${game.i18n.localize("BROWSER.Button")}"><i class="fa-solid fa-filter"></i></button>`);
html.find(".header-actions").append(button);

button.click(ev => {
game.wfrpbrowser.render(true)
Expand Down
4 changes: 2 additions & 2 deletions modules/hooks/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export default function() {


Hooks.on("updateActor", (actor) =>{
actor.checkWounds();
// actor.checkWounds();
})
}
}
16 changes: 8 additions & 8 deletions modules/hooks/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import WFRPTokenHUD from "../apps/tokenHUD.js";
export default function() {
Hooks.on("canvasInit", (canvas) => {

if (!(game.modules.get("fxmaster") && game.modules.get("fxmaster").active)) {
// canvas.background.filters = [];
// canvas.foreground.filters = [];
// canvas.tokens.filters = [];
}
/**
* Double every other diagonal movement
*/
Expand Down Expand Up @@ -46,9 +41,14 @@ export default function() {
if (!(game.modules.get("fxmaster") && game.modules.get("fxmaster").active)) {
let morrsliebActive = canvas.scene.getFlag("wfrp4e", "morrslieb")
if (morrsliebActive) {
canvas.background.filters.push(CONFIG.Morrslieb)
canvas.foreground.filters.push(CONFIG.Morrslieb)
canvas.tokens.filters.push(CONFIG.Morrslieb)
if (!canvas.primary.filters)
canvas.primary.filters = [];
canvas.primary.filters.push(CONFIG.Morrslieb)
}
else if (canvas.primary.filters?.length)
{
// If morrslieb is not active, remove any morrslieb filters
canvas.primary.filters = canvas.primary.filters.filter(i => !i.morrslieb)
}
}
//canvas.hud.token = new WFRPTokenHUD();
Expand Down
Loading

0 comments on commit 543aeec

Please sign in to comment.