reformat castle.js / move helper functions from data.js

move help functions from data to castle.js so they are all grouped
together
reformat data.js
reformat characters.js
reformat gui.js
reformat persist.js
reformat puzzles.js

kept structure same as original ignoring line wrapping and the like
reformat redundancy.js

did not touch MakeRedundancy()
reformat tools.js
Merge remote-tracking branch 'upstream/master' into reformat_merge

Conflicts:
	gui.js
Merge pull request #610 from LucidCrux/reformat_merge

Reformat merge