Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// obfuscate.js

/* global AdventureJS A */

/**
 * Obfuscate a string. Used to make saved game files
 * non human readable via a simple character shift.
 * @method AdventureJS#obfuscate
 * @memberOf AdventureJS
 * @param {String} text
 * @returns {String}
 */
AdventureJS.FX.obfuscate = function AdventureJS_obfuscate(text) {
  if (!text) return "";
  return Array.from(text)
    .map((c) => String.fromCharCode(c.charCodeAt(0) + 3))
    .join("");
};