Skip to content

Commit

Permalink
Roll improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JPMeehan committed Feb 2, 2024
1 parent da8f9e2 commit 4f7f653
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 80 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.2.0

- Updated minimum system version to 3.0
- Added edit button to items now that they can render properly
- Warfare units now roll as themselves
- Warfare and Organization sheet rolls now accept standard 5e key modifiers to speed up rolls
- Shift to roll normally
- Ctrl to roll with disadvantage
- Alt to roll with advantage

## 1.1.0 Derived Stats

- [BREAKING] Organization skill bonuses and defense scores are now derived from their allocated development points
Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"infantry": "Infantry"
},
"Statistics": {
"Test": "{stat} Test",
"Test": "{stat} Test: {actorName}",
"atk": {
"long": "Attack",
"abbr": "ATK"
Expand Down
3 changes: 2 additions & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"id": "dnd5e",
"type": "system",
"compatibility": {
"minimum": "2.4"
"minimum": "3.0",
"verified": "3.0.0"
}
}
]
Expand Down
20 changes: 11 additions & 9 deletions src/module/data/organizationData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ export default class OrganizationData extends foundry.abstract.TypeDataModel {
* @param {string} actorID The ID of the actor rolling their power die
*/
async rollPowerDie(actorID) {
const roll = new Roll("1d@powerDie", { powerDie: this.powerDie });
const roll = new Roll('1d@powerDie', { powerDie: this.powerDie });
await roll.toMessage({
speaker: { actor: actorID },
flavor: game.i18n.localize("KNW.Organization.Powers.RollFlavor"),
flavor: game.i18n.localize('KNW.Organization.Powers.RollFlavor'),
});
this.parent.update({ [`system.powerPool.${actorID}`]: roll.total });
}
Expand All @@ -207,7 +207,7 @@ export default class OrganizationData extends foundry.abstract.TypeDataModel {
async decrementPowerDie(actorID) {
const currentValue = this.powerPool[actorID];
this.parent.update({
["system.powerPool." + actorID]: Math.max(currentValue - 1, 0),
['system.powerPool.' + actorID]: Math.max(currentValue - 1, 0),
});
}

Expand All @@ -216,8 +216,9 @@ export default class OrganizationData extends foundry.abstract.TypeDataModel {
* @param {string} skill The abbreviation of the skill being rolled
* @param {Actor5e} actor The actor making the skill test
* @param {boolean} useProf Whether to use the actor's proficiency
* @param {Event} [event] Click event that triggered the roll
*/
async rollSkillTest(skill, actor, useProf) {
async rollSkillTest(skill, actor, useProf, event) {
const isProf = CONFIG.KNW.ORGANIZATION.assocSkills[skill].reduce(
(accumulator, currentValue) => {
return actor.system.skills[currentValue].proficient >= 1 || accumulator;
Expand All @@ -226,22 +227,23 @@ export default class OrganizationData extends foundry.abstract.TypeDataModel {
);
const prof =
isProf && useProf
? foundry.utils.getProperty(actor, "system.attributes.prof")
? foundry.utils.getProperty(actor, 'system.attributes.prof')
: 0;
if (prof === undefined)
ui.notifications.warn("KNW.Organization.skills.Warning.Prof", {
ui.notifications.warn('KNW.Organization.skills.Warning.Prof', {
localize: true,
});
const label = game.i18n.localize("KNW.Organization.skills." + skill);
const label = game.i18n.localize('KNW.Organization.skills.' + skill);
return game.dnd5e.dice.d20Roll({
parts: ["@skill", "@prof"],
parts: ['@skill', '@prof'],
data: { skill: this.skills[skill].bonus, prof },
title: game.i18n.format("KNW.Organization.skills.Test.Title", {
title: game.i18n.format('KNW.Organization.skills.Test.Title', {
skill: label,
}),
messageData: {
speaker: { actor },
},
event,
});
}
}
32 changes: 20 additions & 12 deletions src/module/data/warfareData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ export default class WarfareData extends foundry.abstract.TypeDataModel {
}),
experience: new fields.StringField({
choices: CONFIG.KNW.CHOICES.EXPERIENCE,
initial: "regular",
initial: 'regular',
textSearch: true,
}),
gear: new fields.StringField({
choices: CONFIG.KNW.CHOICES.GEAR,
initial: "light",
initial: 'light',
textSearch: true,
}),
type: new fields.StringField({
choices: CONFIG.KNW.CHOICES.TYPE,
initial: "infantry",
initial: 'infantry',
textSearch: true,
}),
atk: new fields.NumberField({
Expand Down Expand Up @@ -119,7 +119,7 @@ export default class WarfareData extends foundry.abstract.TypeDataModel {
}),
}),
traitList: new fields.StringField({
initial: "",
initial: '',
nullable: false,
textSearch: true,
}),
Expand All @@ -138,24 +138,32 @@ export default class WarfareData extends foundry.abstract.TypeDataModel {
get commanderName() {
const commander = game.actors.get(this.commander);
if (commander) return commander.name;
else return game.i18n.localize("KNW.Warfare.Commander.None");
else return game.i18n.localize('KNW.Warfare.Commander.None');
}

async rollStat(stat) {
const commander = game.actors.get(this.commander);

/**
*
* @param {string} stat Warfare stat to roll
* @param {Event} [event] Optional event
*/
async rollStat(stat, event) {
const roll = game.dnd5e.dice.d20Roll({
parts: ["@stat"],
parts: ['@stat'],
data: {
stat: this[stat],
},
title: game.i18n.format("KNW.Warfare.Statistics.Test", {
title: game.i18n.format('KNW.Warfare.Statistics.Test', {
stat: game.i18n.localize(`KNW.Warfare.Statistics.${stat}.long`),
actorName: this.parent.name,
}),
flavor: game.i18n.format('KNW.Warfare.Statistics.Test', {
stat: game.i18n.localize(`KNW.Warfare.Statistics.${stat}.long`),
actorName: game.actors.get(this.commander)?.name ?? '',
}),
messageData: {
speaker: { actor: commander },
speaker: { actor: this.parent },
},
event,
});
// console.log(await roll);
}
}
Loading

0 comments on commit 4f7f653

Please sign in to comment.