Skip to content

Commit

Permalink
Merge pull request #960 from moo-man/develop
Browse files Browse the repository at this point in the history
5.0.3
  • Loading branch information
moo-man committed Dec 24, 2021
2 parents 0e261ba + bf7de31 commit 86270de
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Warhammer Fantasy Roleplay 4th Ed. (FoundryVTT)

![](https://user-images.githubusercontent.com/28637157/97379891-e4a1cc00-1893-11eb-9e0c-d93b92844d5b.jpg)
**[Current Version]**: `5.0.2`
**[Current Version]**: `5.0.3`

**[Compatibility]**: `FoundryVTT V9`

Expand Down
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@
"TABLE.ConvertTable" : "Convert to WFRP4e Table",
"TABLE.Lookup" : "Lookup: ",
"TABLE.Cancel" : "Roll: {result} - canceled",
"TABLE.Key" : "Table Key",
"TABLE.Column" : "Table Column",

"NAME.Pray" : "Pray",
"NAME.Language" : "Language",
Expand Down Expand Up @@ -1311,6 +1313,7 @@
"Updater3": "Only use this if you've initialized this module previously.",
"UPDATER.OverwriteActors": "Overwrite Actors",
"UPDATER.OverwriteItems": "Overwrite Items",
"UPDATER.OverwriteTables": "Overwrite Tables",
"UPDATER.OverwriteJournals": "Overwrite Journals",
"UPDATER.OverwriteScenes": "Overwrite Scenes",
"UPDATER.Exclude": "Exclude Name Changes",
Expand Down
27 changes: 17 additions & 10 deletions modules/actor/actor-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ export default class ActorWfrp4e extends Actor {
let cardOptions = {
speaker: {
alias: this.data.token.name,
actor: this.data._id,
actor: this.id,
},
title: title,
template: template,
Expand All @@ -1258,8 +1258,8 @@ export default class ActorWfrp4e extends Actor {
// If the test is coming from a token sheet
if (this.token) {
cardOptions.speaker.alias = this.token.data.name; // Use the token name instead of the actor name
cardOptions.speaker.token = this.token.data._id;
cardOptions.speaker.scene = canvas.scene._id
cardOptions.speaker.token = this.token.id;
cardOptions.speaker.scene = canvas.scene.id
cardOptions.flags.img = this.token.data.img; // Use the token image instead of the actor image

if (this.token.getFlag("wfrp4e", "mask")) {
Expand All @@ -1270,7 +1270,7 @@ export default class ActorWfrp4e extends Actor {
else // If a linked actor - use the currently selected token's data if the actor id matches
{
let speaker = ChatMessage.getSpeaker()
if (speaker.actor == this.data._id) {
if (speaker.actor == this.id) {
cardOptions.speaker.alias = speaker.alias
cardOptions.speaker.token = speaker.token
cardOptions.speaker.scene = speaker.scene
Expand Down Expand Up @@ -2325,12 +2325,12 @@ ChatWFRP.renderRollCard() as well as handleOpposedTarget().
}
// The Roll class used to randomly select skills
let skillSelector = new Roll(`1d${skillList.length}- 1`);
skillSelector.roll().total;
await skillSelector.roll()

// Store selected skills
let skillsSelected = [];
while (skillsSelected.length < 6) {
skillSelector = skillSelector.reroll()
skillSelector = await skillSelector.reroll()
if (!skillsSelected.includes(skillSelector.total)) // Do not push duplicates
skillsSelected.push(skillSelector.total);
}
Expand Down Expand Up @@ -2375,7 +2375,7 @@ ChatWFRP.renderRollCard() as well as handleOpposedTarget().
{
for (let i = 0; i < talent; i++) {
let result = await game.wfrp4e.tables.rollTable("talents")
await this._advanceTalent(result.name);
await this._advanceTalent(result.object.text);
}
continue
}
Expand Down Expand Up @@ -2989,7 +2989,7 @@ ChatWFRP.renderRollCard() as well as handleOpposedTarget().
attacker = {
speaker: this.data.flags.oppose.speaker,
test: attackMessage.getTest(),
messageId: attackMessage.data._id,
messageId: attackMessage.id,
img: WFRP_Utility.getSpeaker(this.data.flags.oppose.speaker).data.img
};
}
Expand Down Expand Up @@ -3132,7 +3132,7 @@ ChatWFRP.renderRollCard() as well as handleOpposedTarget().



runEffects(trigger, args) {
runEffects(trigger, args, options={}) {
let effects = this.effects.filter(e => e.trigger == trigger && e.script && !e.isDisabled)

if (trigger == "oneTime") {
Expand All @@ -3154,7 +3154,14 @@ ChatWFRP.renderRollCard() as well as handleOpposedTarget().

effects.forEach(e => {
try {
let func = new Function("args", e.script).bind({ actor: this, effect: e, item: e.item })
let func
if (!options.async)
func = new Function("args", e.script).bind({ actor: this, effect: e, item: e.item })
else if (options.async)
{
let asyncFunction = Object.getPrototypeOf(async function () { }).constructor
func = new asyncFunction("args", e.script).bind({ actor: this, effect: e, item: e.item })
}
func(args)
}
catch (ex) {
Expand Down
14 changes: 7 additions & 7 deletions modules/actor/sheet/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ export default class ActorSheetWfrp4e extends ActorSheet {
if (this.actor.type == "character")
return
try {
let initialValues = WFRP_Utility.speciesCharacteristics(speciesKey, true, subspeciesKey);
let initialValues = await WFRP_Utility.speciesCharacteristics(speciesKey, true, subspeciesKey);
let characteristics = this.actor.toObject().data.characteristics;
for (let c in characteristics) {
characteristics[c].initial = initialValues[c].value
Expand Down Expand Up @@ -1357,27 +1357,27 @@ export default class ActorSheetWfrp4e extends ActorSheet {
let characteristics = this.actor.toObject().data.characteristics;
if (this.actor.type == "creature" || !species) creatureMethod = true;
if (!creatureMethod) {
let averageCharacteristics = WFRP_Utility.speciesCharacteristics(species, true, subspecies);
let averageCharacteristics = await WFRP_Utility.speciesCharacteristics(species, true, subspecies);
for (let char in characteristics) {
if (characteristics[char].initial != averageCharacteristics[char].value) creatureMethod = true
}
}
if (!creatureMethod) {
let rolledCharacteristics = WFRP_Utility.speciesCharacteristics(species, false, subspecies);
let rolledCharacteristics = await WFRP_Utility.speciesCharacteristics(species, false, subspecies);
for (let char in rolledCharacteristics) {
characteristics[char].initial = rolledCharacteristics[char].value
}
await this.actor.update({ "data.characteristics": characteristics })
}
else if (creatureMethod) {
let roll = new Roll("2d10");
roll.roll();
await roll.roll();
let characteristics = this.actor.toObject().data.characteristics;
for (let char in characteristics) {
if (characteristics[char].initial == 0)
continue
characteristics[char].initial -= 10;
characteristics[char].initial += roll.reroll().total;
characteristics[char].initial += (await roll.reroll()).total;
if (characteristics[char].initial < 0)
characteristics[char].initial = 0
}
Expand Down Expand Up @@ -1831,12 +1831,12 @@ export default class ActorSheetWfrp4e extends ActorSheet {


if (expandData.targetEffects.length) {
let effectButtons = expandData.targetEffects.map(e => `<a class="apply-effect" data-item-id=${item.id} data-effect-id=${e._id}>${game.i18n.format("SHEET.ApplyEffect", { effect: e.label })}</a>`)
let effectButtons = expandData.targetEffects.map(e => `<a class="apply-effect" data-item-id=${item.id} data-effect-id=${e.id}>${game.i18n.format("SHEET.ApplyEffect", { effect: e.label })}</a>`)
let effects = $(`<div>${effectButtons}</div>`)
div.append(effects)
}
if (expandData.invokeEffects.length) {
let effectButtons = expandData.invokeEffects.map(e => `<a class="invoke-effect" data-item-id=${item.id} data-effect-id=${e._id}>${game.i18n.format("SHEET.InvokeEffect", { effect: e.label })}</a>`)
let effectButtons = expandData.invokeEffects.map(e => `<a class="invoke-effect" data-item-id=${item.id} data-effect-id=${e.id}>${game.i18n.format("SHEET.InvokeEffect", { effect: e.label })}</a>`)
let effects = $(`<div>${effectButtons}</div>`)
div.append(effects)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/actor/sheet/creature-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ export default class ActorSheetWfrp4eCreature extends ActorSheetWfrp4e {
expandData.properties.forEach(p => props.append(`<span class="tag">${p}</span>`));
div.append(props);
if (expandData.targetEffects.length) {
let effectButtons = expandData.targetEffects.map(e => `<a class="apply-effect" data-item-id=${item.id} data-effect-id=${e._id}>${game.i18n.format("SHEET.ApplyEffect", { effect: e.label })}</a>`)
let effectButtons = expandData.targetEffects.map(e => `<a class="apply-effect" data-item-id=${item.id} data-effect-id=${e.id}>${game.i18n.format("SHEET.ApplyEffect", { effect: e.label })}</a>`)
let effects = $(`<div>${effectButtons}</div>`)
div.append(effects)
}
if (expandData.invokeEffects.length) {
let effectButtons = expandData.invokeEffects.map(e => `<a class="invoke-effect" data-item-id=${item.id} data-effect-id=${e._id}>${game.i18n.format("SHEET.InvokeEffect", { effect: e.label })}</a>`)
let effectButtons = expandData.invokeEffects.map(e => `<a class="invoke-effect" data-item-id=${item.id} data-effect-id=${e.id}>${game.i18n.format("SHEET.InvokeEffect", { effect: e.label })}</a>`)
let effects = $(`<div>${effectButtons}</div>`)
div.append(effects)
}
Expand Down
6 changes: 5 additions & 1 deletion modules/apps/module-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class ModuleUpdater extends Dialog {
updateSettings.journals = html.find('[name="journals"]').is(':checked')
updateSettings.items = html.find('[name="items"]').is(':checked')
updateSettings.scenes = html.find('[name="scenes"]').is(':checked')
updateSettings.tables = html.find('[name="tables"]').is(':checked')
updateSettings.excludeNameChange = html.find('[name="excludeNameChange"]').is(':checked')
return updateSettings
}
Expand Down Expand Up @@ -116,7 +117,8 @@ export default class ModuleUpdater extends Dialog {
actors : [],
journals : [],
items : [],
scenes : []
scenes : [],
tables : [],
};
for (let pack of packs)
{
Expand All @@ -129,6 +131,8 @@ export default class ModuleUpdater extends Dialog {
break;
case "Item": documents.items = documents.items.concat(docs)
break;
case "RollTable": documents.tables = documents.tables.concat(docs)
break;
case "Scene": documents.scenes = documents.scenes.concat(docs)
break;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/name-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default class NameGenWfrp {

let base = nameGroup[0]
let option;
roll = Math.floor(Math.random()*size)
roll = Math.floor(Math.random()*(nameGroup.length))
if (roll != 0)
option = nameGroup[roll].substr(1)

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/wfrp-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export default class BrowserWfrp4e extends Application {

html.on("click", ".item-name", ev => {
let itemId = $(ev.currentTarget).parents(".browser-item").attr("data-item-id")
this.items.find(i => i._id == itemId).sheet.render(true);
this.items.find(i => i.id == itemId).sheet.render(true);

})

Expand Down
11 changes: 10 additions & 1 deletion modules/item/item-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export default class ItemWfrp4e extends Item {
data.properties.push(`<b>${game.i18n.localize("Skills")}</b>: ${this.skills.map(i => i = " " + i)}`);
data.properties.push(`<b>${game.i18n.localize("Talents")}</b>: ${this.talents.map(i => i = " " + i)}`);
data.properties.push(`<b>${game.i18n.localize("Trappings")}</b>: ${this.trappings.map(i => i = " " + i)}`);
data.properties.push(`<b>${game.i18n.localize("Income")}</b>: ${this.incomeSkill.map(i => ` <a class = 'career-income' data-career-id=${this._id}> ${this.skills[i]} <i class="fas fa-coins"></i></a>`)}`);
data.properties.push(`<b>${game.i18n.localize("Income")}</b>: ${this.incomeSkill.map(i => ` <a class = 'career-income' data-career-id=${this.id}> ${this.skills[i]} <i class="fas fa-coins"></i></a>`)}`);
// When expansion data is called, a listener is added for 'career-income'
return data;
}
Expand Down Expand Up @@ -1058,15 +1058,24 @@ export default class ItemWfrp4e extends Item {

// If range modification was handwritten, process it
if (ammoValue.toLowerCase() == game.i18n.localize("as weapon")) { }
else if (ammoValue.toLowerCase() == "as weapon") { }
// Do nothing to weapon's range
else if (ammoValue.toLowerCase() == game.i18n.localize("half weapon"))
value /= 2;
else if (ammoValue.toLowerCase() == "half weapon")
value /= 2;
else if (ammoValue.toLowerCase() == game.i18n.localize("third weapon"))
value /= 3;
else if (ammoValue.toLowerCase() =="third weapon")
value /= 3;
else if (ammoValue.toLowerCase() == game.i18n.localize("quarter weapon"))
value /= 4;
else if (ammoValue.toLowerCase() == "quarter weapon")
value /= 4;
else if (ammoValue.toLowerCase() == game.i18n.localize("twice weapon"))
value *= 2;
else if (ammoValue.toLowerCase() == "twice weapon")
value *= 2;
else // If the range modification is a formula (supports +X -X /X *X)
{
try // Works for + and -
Expand Down
2 changes: 1 addition & 1 deletion modules/system/chat-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class ChatWFRP {

// Blank if manual chat cards
if (game.settings.get("wfrp4e", "manualChatCards") && !rerenderMessage)
test.roll = test.SL = null;
test.result.roll = test.result.SL = null;

if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active && chatOptions.sound?.includes("dice"))
chatOptions.sound = undefined;
Expand Down
6 changes: 3 additions & 3 deletions modules/system/combat.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class CombatHelpers {
turn.actor.displayStatus(combat.data.round, turn.name);

if (game.settings.get("wfrp4e", "focusOnTurnStart")) {
canvas.tokens.get(turn.token._id).control();
canvas.tokens.get(turn.token.id).control();
canvas.tokens.cycleTokens(1, true);
}

Expand Down Expand Up @@ -270,7 +270,7 @@ export default class CombatHelpers {
conditionName += ` ${cond.flags.wfrp4e.value}`
msgContent = `
<h2>${conditionName}</h2>
<a class="condition-script" data-combatant-id="${turn._id}" data-cond-id="${cond.statusId}">${game.i18n.format("CONDITION.Apply", { condition: conditionName })}</a>
<a class="condition-script" data-combatant-id="${turn.id}" data-cond-id="${cond.statusId}">${game.i18n.format("CONDITION.Apply", { condition: conditionName })}</a>
`
ChatMessage.create({ content: msgContent, speaker: { alias: turn.token.name } })

Expand All @@ -291,7 +291,7 @@ export default class CombatHelpers {
}
}
}
turn.actor.runEffects("endRound", combat)
turn.actor.runEffects("endRound", combat, {async: true})

}
if (removedConditions.length)
Expand Down
Loading

0 comments on commit 86270de

Please sign in to comment.