Skip to content

Commit

Permalink
refactor: code repetition
Browse files Browse the repository at this point in the history
Signed-off-by: arcanist <[email protected]>
  • Loading branch information
arcanistzed committed Jul 3, 2022
1 parent 5e12a86 commit 7578707
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/ctg.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,17 @@ export default class Ctg {
// Reduce combat turns into an array of groups by matching a given property path
groups = Object.values(
game.combat?.turns.reduce((accumulator, current) => {
const value = recursiveGetPropertyConcat(current, path);

// Conditions for not grouping:
if (
current.visible &&
recursiveGetPropertyConcat(current, path) &&
value &&
!(game.settings.get(Ctg.ID, "noGroupHidden") && current.hidden) &&
!(game.settings.get(Ctg.ID, "noGroupPCs") && current.hasPlayerOwner)
)
// Group by the property
accumulator[recursiveGetPropertyConcat(current, path)] = [
...(accumulator[recursiveGetPropertyConcat(current, path)] || []),
current,
];
accumulator[value] = [...(accumulator[value] || []), current];
return accumulator;
}, {})
).reverse();
Expand Down

0 comments on commit 7578707

Please sign in to comment.