Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update compatibility for pf2e 5.13.6 #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"type": "system",
"manifest": "https://github.com/foundryvtt/pf2e/releases/download/3.13.6/system.json",
"compatibility": {
"verified": "3.13.6"
"verified": "5.13.6"
}
},
{
Expand Down
13 changes: 7 additions & 6 deletions src/lmrtfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,16 @@ class LMRTFY {

static buildAbilityModifier(actor, ability) {
const modifiers = [];

const mod = game.pf2e.AbilityModifier.fromScore(ability, actor.data.data.abilities[ability].value);
const attribute = actor.system.abilities[ability];
const attributeLabel = game.i18n.localize(attribute.label);
const mod = new game.pf2e.Modifier(attributeLabel, attribute.mod, 'ability', true);
modifiers.push(mod);

[`${ability}-based`, 'ability-check', 'all'].forEach((key) => {
(actor.synthetics.statisticsModifier[key] || []).forEach((m) => modifiers.push(m.clone()));
(actor.synthetics.modifierAdjustments[key] || []).forEach((m) => modifiers.push(m.clone()));
});

return new game.pf2e.StatisticModifier(`${game.i18n.localize('LMRTFY.AbilityCheck')} ${game.i18n.localize(mod.label)}`, modifiers);
const slug = `${game.i18n.localize('LMRTFY.AbilityCheck')}${attributeLabel}`;
const statisticModifier = new game.pf2e.StatisticModifier(slug, modifiers);
return statisticModifier;
}

static async hideBlind(app, html, msg) {
Expand Down
51 changes: 27 additions & 24 deletions src/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,12 @@ class LMRTFYRoller extends Application {

case this.pf2eRollFor.SKILL:
// system specific roll handling
const skill = actor.system.skills[args[0]];
const skillSlug = actor.system.skills[args[0]].slug;
const skill = actor.skills[skillSlug];
// roll lore skills only for actors who have them ...
if (!skill) continue;

const skillOptions = actor.getRollOptions(['all', `${skill.ability ?? 'int'}-based`, 'skill-check', skill.name]);
const skillOptions = actor.getRollOptions(['all', `${skill.ability ?? 'int'}-based`, 'skill-check', skillSlug]);
skill.roll({ event, skillOptions, dc: this.dc });
break;

Expand Down Expand Up @@ -361,27 +362,9 @@ class LMRTFYRoller extends Application {
}

_makePF2EInitiativeRoll(event) {
// save the current roll mode to reset it after this roll
const rollMode = game.settings.get("core", "rollMode");
game.settings.set("core", "rollMode", this.mode || CONST.DICE_ROLL_MODES);

for (let actor of this.actors) {
const initiative = actor.data.data.attributes.initiative;
const rollNames = ['all', 'initiative'];
if (initiative.ability === 'perception') {
rollNames.push('wis-based');
rollNames.push('perception');
} else {
const skill = actor.data.data.skills[initiative.ability];
rollNames.push(`${skill.ability}-based`);
rollNames.push(skill.name);
}
const options = actor.getRollOptions(rollNames);
initiative.roll({ event, options });
for (const actor of this.actors) {
actor.initiative.roll();
}

game.settings.set("core", "rollMode", rollMode);

event.currentTarget.disabled = true;
this._checkClose();
}
Expand Down Expand Up @@ -651,7 +634,17 @@ class LMRTFYRoller extends Application {
this._checkClose();
} else if (game.system.id == "pf2e") {
for (let actor of this.actors) {
actor.rollRecovery();
actor.rollRecovery().then(rollResult => {
if (!rollResult) return;
const adjustDyingCounterFn = rollResult.degreeOfSuccess >= 2 ? () => actor.decreaseCondition('dying') : () => actor.increaseCondition('dying', { max: actor.system.attributes.dying.max ?? 4 });
const dosToNumberOfCalls = { 0: 2, 1: 1, 2: 1, 3: 2 };
const adjustDyingCounterCalls = Array.from({ length: dosToNumberOfCalls[rollResult.degreeOfSuccess] }, () => adjustDyingCounterFn());
Promise.all(adjustDyingCounterCalls).then(() => {
if (actor.system.attributes.dying.value === 0) {
actor.increaseCondition('wounded', { max: actor.system.attributes.wounded.max ?? 3 });
}
});
});
}
event.currentTarget.disabled = true;
this._checkClose();
Expand All @@ -662,7 +655,17 @@ class LMRTFYRoller extends Application {

_onPerception(event) {
event.preventDefault();
this._makeDiceRoll(event, `1d20 + @attributes.perception.totalModifier`, game.i18n.localize("LMRTFY.PerceptionRollMessage"));

if (game.system.id !== 'pf2e') {
return this._makeDiceRoll(event, `1d20 + @attributes.perception.totalModifier`, game.i18n.localize("LMRTFY.PerceptionRollMessage"));
}

const ability = event.currentTarget.dataset.ability;
this.pf2Roll = this.pf2eRollFor.PERCEPTION;
if (!this.hasMidi || this.midiUseNewRoller) {
return this._makeRoll(event, LMRTFY.abilityRollMethod, false, ability);
}
this._makeRoll(event, LMRTFY.abilityRollMethod, ability);
}

_onRollTable(event) {
Expand Down