JacobMcAuley / critical-fumble

Automatically rolls from a critical sucess/critical fail when you roll that natural success/fail during an attack!
GNU General Public License v3.0
0 stars 0 forks source link

Quick code review #3

Closed kakaroto closed 4 years ago

kakaroto commented 4 years ago

Been reviewing the code to see what it does and have some comments.. unfortunately, since this isn't from a pull request, or a single commit with all the code, I can't do random review comments on a file, and I don't want to put comments spread over all the various commits. So I'm creating an issue for it here.

Note: this isn't a critique of your code, and you don't have to listen to any of my suggestions as they might not match your own coding style, but maybe something helps you here if you find it more practical and hadn't thought of it, or you see it as a potential fix for a bug that hasn't appeared yet. Some of the comments might also be irrelevant if you switch to using a compendium roll table, but I'll still make the comment in case it helps you notice something else.

Starting with criticalLoot.js :

Note that I always do the this.tables.push(table) in here, and that assumes that the _generateTable only generates the table and doesn't add it to this.tables as well which simplifies code for both functions.

isValidTarget(actor) {
   let targets = game.users.entities.map(u => u.targets)
                        .reduce((acc, t) => { return acc.concat(...t); }, [])
   return !!targets.find(t => t.actor && t.actor.id === actor.id)
}

That's it for this file. I'll do a really quick pass over the criticalFumble.js now

JacobMcAuley commented 4 years ago

Hey Kakaroto, Thanks for the review! I'm not the most experienced programmer yet, with less practical experience than I want. I appreciate you taking the time out of your day to provide a code review! Any future reviews will be accepted gladly!

Almost all the advice you offered I took. I hope the next time I work on something I can follow better design practice. Thanks!

kakaroto commented 4 years ago

You're welcome! I'll do another review later, but quick notes : your module.json includes src/hooks.js which doesn't exist and and your config.js still has all the roll tables data.