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

Dnd 4.1.2 fix #85

Open
wants to merge 7 commits into
base: main
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
12 changes: 4 additions & 8 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BaseMessage {
}

get prefix() {
return "dialogOptions";
return "options";
}

addMessage(options) {
Expand Down Expand Up @@ -151,10 +151,9 @@ export class SkillMessage extends AbilityCheckMessage {

/** @override */
get messageKeys() {
return super.messageKeys.concat(
return [
"flags.adv-reminder.message.skill.all",
`flags.adv-reminder.message.skill.${this.skillId}`
);
`flags.adv-reminder.message.skill.${this.skillId}`]
}
}

Expand All @@ -165,10 +164,7 @@ export class DeathSaveMessage extends AbilityBaseMessage {

/** @override */
get messageKeys() {
return super.messageKeys.concat(
"flags.adv-reminder.message.ability.save.all",
"flags.adv-reminder.message.deathSave"
);
return ["flags.adv-reminder.message.deathSave"]
}
}

Expand Down
17 changes: 8 additions & 9 deletions src/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,16 @@ export class SkillReminder extends AbilityCheckReminder {

/** @override */
get advantageKeys() {
return super.advantageKeys.concat(["advantage.skill.all", `advantage.skill.${this.skillId}`]);
return [
"advantage.skill.all",
`advantage.skill.${this.skillId}`];
}

/** @override */
get disadvantageKeys() {
return super.disadvantageKeys.concat([
return [
"disadvantage.skill.all",
`disadvantage.skill.${this.skillId}`,
]);
`disadvantage.skill.${this.skillId}`,];
}

/** @override */
Expand Down Expand Up @@ -321,17 +322,15 @@ export class DeathSaveReminder extends AbilityBaseReminder {
super(actor, null);
}

/** @override */
/** @override */
get advantageKeys() {
return super.advantageKeys.concat(["advantage.ability.save.all", "advantage.deathSave"]);
return ["advantage.deathSave"];
}

/** @override */
get disadvantageKeys() {
return super.disadvantageKeys.concat([
"disadvantage.ability.save.all",
"disadvantage.deathSave",
]);
return ["disadvantage.deathSave"];
}
}

Expand Down
94 changes: 46 additions & 48 deletions src/rollers/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export default class CoreRollerHooks {

// register all the dnd5e.pre hooks
Hooks.on("dnd5e.preRollAttackV2", this.preRollAttackV2.bind(this));
Hooks.on("dnd5e.preRollAbilitySave", this.preRollAbilitySave.bind(this));
Hooks.on("dnd5e.preRollConcentration", this.preRollConcentration.bind(this));
Hooks.on("dnd5e.preRollAbilityTest", this.preRollAbilityTest.bind(this));
Hooks.on("dnd5e.preRollSkill", this.preRollSkill.bind(this));
Hooks.on("dnd5e.preRollToolCheck", this.preRollToolCheck.bind(this));
Hooks.on("dnd5e.preRollDeathSave", this.preRollDeathSave.bind(this));
Hooks.on("dnd5e.preRollSkillV2", this.preRollSkillV2.bind(this));
Hooks.on("dnd5e.preRollAbilityCheckV2", this.preRollAbilityCheckV2.bind(this));
Hooks.on("dnd5e.preRollSavingThrowV2", this.preRollSavingThrowV2.bind(this));
//Hooks.on("dnd5e.preRollToolV2", this.preRollToolV2.bind(this));
Hooks.on("dnd5e.preRollDeathSaveV2", this.preRollDeathSaveV2.bind(this));
Hooks.on("dnd5e.preRollConcentrationV2", this.preRollConcentrationV2.bind(this));
Hooks.on("dnd5e.preRollDamageV2", this.preRollDamageV2.bind(this));
}

Expand All @@ -77,70 +77,68 @@ export default class CoreRollerHooks {
if (showSources) new AttackSourceV2(activity.actor, target, activity, distanceFn).updateOptions(dialog);
new AttackReminderV2(activity.actor, target, activity, distanceFn).updateOptions(config.rolls[0].options);
}

preRollSavingThrowV2(config, dialog, message) {
debug("preRollSavingThrowV2 hook called");

preRollAbilitySave(actor, config, abilityId) {
debug("preRollAbilitySave hook called");

const failChecker = new AbilitySaveFail(actor, abilityId);
const failChecker = new AbilitySaveFail(config.subject, config.ability);
if (failChecker.fails(config)) return false;

if (this.isFastForwarding(config)) return;
if (this.isFastForwarding(config, dialog)) return;

new AbilitySaveMessage(actor, abilityId).addMessage(config);
if (showSources) new AbilitySaveSource(actor, abilityId).updateOptions(config);
new AbilitySaveReminder(actor, abilityId).updateOptions(config);
new AbilitySaveMessage(config.subject, config.ability).addMessage(dialog);
if (showSources) new AbilitySaveSource(config.subject, config.ability).updateOptions(dialog);
new AbilitySaveReminder(config.subject, config.ability).updateOptions(config.rolls[0].options);
}

preRollConcentrationV2(config, dialog, message) {
debug("preRollConcentrationV2 hook called");

preRollConcentration(actor, options) {
debug("preRollConcentration hook called");

if (this.isFastForwarding(options)) return;
if (this.isFastForwarding(config, dialog)) return;

new ConcentrationMessage(actor, options.ability).addMessage(options);
if (showSources) new ConcentrationSource(actor, options.ability).updateOptions(options);
new ConcentrationMessage(config.subject, config.ability).addMessage(dialog);
if (showSources) new ConcentrationSource(config.subject, config.ability).updateOptions(dialog);
// don't need a reminder, the system will set advantage/disadvantage
}

preRollAbilityTest(actor, config, abilityId) {
debug("preRollAbilityTest hook called");

if (this.isFastForwarding(config)) return;
preRollAbilityCheckV2(config, dialog, message) {
debug("preRollAbilityCheckV2 hook called");

new AbilityCheckMessage(actor, abilityId).addMessage(config);
if (showSources) new AbilityCheckSource(actor, abilityId).updateOptions(config);
new AbilityCheckReminder(actor, abilityId).updateOptions(config);
if (this.isFastForwarding(config, dialog)) return;

new AbilityCheckMessage(config.subject, config.ability).addMessage(dialog);
if (showSources) new AbilityCheckSource(config.subject, config.ability).updateOptions(dialog);
new AbilityCheckReminder(config.subject, config.ability).updateOptions(config.rolls[0].options);
}

preRollSkill(actor, config, skillId) {
debug("preRollSkill hook called");

if (this.isFastForwarding(config)) return;
preRollSkillV2(config, dialog, message) {
debug("preRollSkillV2 hook called");
if (this.isFastForwarding(config, dialog)) return;

const ability = config.data.defaultAbility;
new SkillMessage(actor, ability, skillId).addMessage(config);
if (showSources) new SkillSource(actor, ability, skillId, true).updateOptions(config);
new SkillReminder(actor, ability, skillId, this.checkArmorStealth).updateOptions(config);
new SkillMessage(config.subject, config.ability, config.skill).addMessage(dialog);
if (showSources) new SkillSource(config.subject, config.ability, config.skill, true).updateOptions(dialog);
new SkillReminder(config.subject, config.ability, config.skill, this.checkArmorStealth).updateOptions(config.rolls[0].options);
}

preRollToolCheck(actor, config, toolId) {
/**preRollToolV2(config, dialog, message) {//toDo: Missing Message for tools
debug("preRollToolCheck hook called");

if (this.isFastForwarding(config)) return;
if (this.isFastForwarding(config, dialog)) return;

const ability = config.data.defaultAbility;
new AbilityCheckMessage(actor, ability).addMessage(config);
if (showSources) new AbilityCheckSource(actor, ability).updateOptions(config);
new AbilityCheckReminder(actor, ability).updateOptions(config);
}
new AbilityCheckMessage(config.subject, config.ability).addMessage(dialog);
if (showSources) new AbilityCheckSource(config.subject, config.ability).updateOptions(dialog);
new AbilityCheckReminder(config.subject, config.ability).updateOptions(dialog);
}*/

preRollDeathSave(actor, config) {
debug("preRollDeathSave hook called");
preRollDeathSaveV2(config, dialog, message) {
debug("preRollDeathSaveV2 hook called");

if (this.isFastForwarding(config)) return;
if (this.isFastForwarding(config, dialog)) return;

new DeathSaveMessage(actor).addMessage(config);
if (showSources) new DeathSaveSource(actor).updateOptions(config);
new DeathSaveReminder(actor).updateOptions(config);
new DeathSaveMessage(config.subject).addMessage(dialog);
if (showSources) new DeathSaveSource(config.subject).updateOptions(dialog);
new DeathSaveReminder(config.subject).updateOptions(config.rolls[0].options);
}

preRollDamageV2(config, dialog, message) {
Expand Down
Loading