<commit_before>var _   = require('lodash');
var fs  = require('fs');
var jsf = require('jsonfile');

/**
 * Object Definition
 */

var Player = function (username) {
  this.username = username;
  this.data     = null;
  this.settings = null;
};

/**
 * Prototypes
 */

Player.prototype.load = function (data) {
  if (fs.existsSync(__dirname + '/../data/save/' + this.username)) {
    this.data = jsf.readFileSync(__dirname + '/../data/save/' + this.username + '/player-data.json');
    this.settings = jsf.readFileSync(__dirname + '/../data/save/' + this.username + '/player-settings.json');
    this.update(data);
  } else {
    this.data = data;
    this.settings = {
      spreadsheet: {
        color:  {
          iv:   false,
          move: false
        },
        display: {
          move_1:       true,
          move_2:       false,
          move_energy:  false,
          move_dps:     false,
          level:        true,
          cp:           true,
          hp:           true,
          atk:          false,
          def:          false,
          iva:          true,
          ivd:          true,
          ivs:          true,
          dps:          false,
          piv:          true,
          pcp:          true
        }
      }
    };
  }
};

Player.prototype.save = function () {
  if (!fs.existsSync(__dirname + '/../data/save/' + this.username)) fs.mkdirSync(__dirname + '/../data/save/' + this.username);
  jsf.writeFileSync(__dirname + '/../data/save/' + this.username + '/player-data.json', this.data, {spaces: 2});
  jsf.writeFileSync(__dirname + '/../data/save/' + this.username + '/player-settings.json', this.settings, {spaces: 2});
};

Player.prototype.update = function (data) {
  this.data = data;
};

Player.prototype.toJSON = function () {
  return {
    data: this.data,
    settings: this.settings
  };
};

module.exports = Player;<commit_msg>Fixed the undefined settings message<commit_after>var _   = require('lodash');
var fs  = require('fs');
var jsf = require('jsonfile');

/**
 * Object Definition
 */

var Player = function (username) {
  this.username = username;
  this.data     = null;
  this.settings = null;
};

/**
 * Prototypes
 */

Player.prototype.load = function (data) {
  if (fs.existsSync(__dirname + '/../data/save/' + this.username)) {
    this.data = jsf.readFileSync(__dirname + '/../data/save/' + this.username + '/player-data.json');
    this.settings = jsf.readFileSync(__dirname + '/../data/save/' + this.username + '/player-settings.json');
    if (this.settings === undefined) {
      this.settings = {
        spreadsheet: {
          color:  {
            iv:   false,
            move: false
          },
          display: {
            move_1:       true,
            move_2:       false,
            move_energy:  false,
            move_dps:     false,
            level:        true,
            cp:           true,
            hp:           true,
            atk:          false,
            def:          false,
            iva:          true,
            ivd:          true,
            ivs:          true,
            dps:          false,
            piv:          true,
            pcp:          true
          }
        }
      };
    }
    this.update(data);
  } else {
    this.data = data;
    this.settings = {
      spreadsheet: {
        color:  {
          iv:   false,
          move: false
        },
        display: {
          move_1:       true,
          move_2:       false,
          move_energy:  false,
          move_dps:     false,
          level:        true,
          cp:           true,
          hp:           true,
          atk:          false,
          def:          false,
          iva:          true,
          ivd:          true,
          ivs:          true,
          dps:          false,
          piv:          true,
          pcp:          true
        }
      }
    };
  }
};

Player.prototype.save = function () {
  if (!fs.existsSync(__dirname + '/../data/save/' + this.username)) fs.mkdirSync(__dirname + '/../data/save/' + this.username);
  jsf.writeFileSync(__dirname + '/../data/save/' + this.username + '/player-data.json', this.data, {spaces: 2});
  jsf.writeFileSync(__dirname + '/../data/save/' + this.username + '/player-settings.json', this.settings, {spaces: 2});
};

Player.prototype.update = function (data) {
  this.data = data;
};

Player.prototype.toJSON = function () {
  return {
    data: this.data,
    settings: this.settings
  };
};

module.exports = Player;
{'fraction_non_alphanumeric': 0.14516843971631205, 'fraction_numerical': 0.002216312056737589, 'mean_word_length': 1.464773347897324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6559930', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1348, 'n_words': 278}