Syndaryl / DFRPGRandomDungeonGenerator

A HTML/CSS/JavaScript based random dungeon generator for GURPS. Eventual goals are to not only produce a map, but also populate the rooms with descriptions and challenges. Game statistics will be for the DFRPG / GURPS 4e.
Other
35 stars 13 forks source link

Added documentation to functions #37

Closed natfarleydev closed 6 years ago

natfarleydev commented 6 years ago

This PR adds docs to functions in canvas.js

I plan to make more documentation (since I want to actively develop, but single letter varnames make it difficult) but figured there's no harm in pull requesting as I go.

This PR also includes one small change to fmt_color function which is now fmt_color(r, g, b) instead of fmt_color(a, c, b).

Any comments/suggestions/improvements are welcome.

Syndaryl commented 6 years ago

I'm slowly refactoring all the routines inherited from drow to eliminate those single letter variables and try to document some of what's going on. I welcome all help in this area :)

natfarleydev commented 6 years ago

Excellent! How can I help?

My vague plan was to document everything so it's easy to understand what the code is achieving and then maybe build some tests in order to refactor?

This PR can be merged immediately, I'm happy to reopen new ones as I document more.

Syndaryl commented 6 years ago

As far as refactoring goes, it's not radical: I'm using Visual Studio to rename variables (thank you Visual Studio). Giving them sensible names requires tracing what the heck everything is and sometimes that requires going all the way up and down the call stack. Documenting the functions will help assign sensible names, so anywhere you can do that (either function arguments or internal variables) will help.

I'm also targetting the re-used variables, I can't stand that (particularly when combined with obscure variable names).

natfarleydev commented 6 years ago

Sounds good to me! I'll focus on pure documentation for now as without tests I'm not sure I trust VS Code's renaming variables without understanding how the JS code works (esp. with the shadowing/reusing of variables)