<commit_before>var Data    = require('./data').Data,
    Skills  = require('./skills').Skills,
    crypto  = require('crypto'),
    ansi    = require('sty'),
    util    = require('util');
    events  = require('events');


var npcs_scripts_dir = __dirname + '/../scripts/player/';
var l10n_dir         = __dirname + '/../l10n/scripts/player/';

var Player = function(socket) {
	var self = this;
	self.name     = '';
	self.location = null;
	self.locale   = null;
	self.prompt_string = '%health/%max_healthHP>';
	self.combat_prompt =
	   "<bold>[%health/%max_healthHP] 0--{======> %target_name: [%target_health/%target_max_health]</bold>\r\n>";
	self.password = <PASSWORD>;
	self.inventory = [];
	self.equipment = {};

	// In combat is either false or an NPC vnum
	self.in_combat = false;

	// Attributes
	self.attributes = {
		max_health: 100,
		health : 100,
		level: 1,
		experience: 0,
		'class': ''
	};

	// Anything affecting the player
	self.affects = {
	};

	// Skills the players has
	self.skills = {
	};

	/**#@+
	 * Mutators
	 */
	self.getPrompt       = function () { return self.prompt_string; };
	self.getCombatPrompt = function () { return self.combat_prompt; };
	self.getLocale       = function () { return self.locale; };
	self.getName         = function () { return self.name; };
	self.getLocation     = function () { return self.location; };
	self.getSocket       = function () { return socket; };
	self.getInventory    = function () { return self.inventory; };
	self.getAttribute    = function (attr)  { return typeof self.attributes[attr] !== 'undefined' ? self.attributes[attr] : false; };
	self.getSkills       = function (skill) { return typeof self.skills[skill] !== 'undefined'    ? self.skills[skill]    : self.skills; };
	// Note, only retreives hash, not a real password
	self.getPassword     = function () { return self.password; };
	self.isInCombat      = function () { return self.in_combat; };
	self.setPrompt       = function (str)       { self.prompt_string = str; }
	self.setCombatPrompt = function (str)       { self.combat_prompt = str; }
	self.setLocale       = function (locale)    { self.locale = locale; };
	self.setName         = function (newname)   { self.name = newname; };
	self.setLocation     = function (loc)       { self.location = loc; };
	self.setPassword     = function (pass)      { self.password = crypto.createHash('md5').update(pass).digest('hex'); };
	self.addItem         = function (item)      { self.inventory.push(item); };
	self.removeItem      = function (item)      { self.inventory = self.inventory.filter(function (i) { return item !== i; }); };
	self.setInventory    = function (inv)       { self.inventory = inv; };
	self.setInCombat     = function (combat)    { self.in_combat = combat; };
	self.setAttribute    = function (attr, val) { self.attributes[attr] = val; };
	self.addSkill        = function (name, skill) { self.skills[name] = skill; };
	/**#@-*/

	/**
	 * Get currently applied affects
	 * @param string aff
	 * @return Array|Object
	 */
	self.getAffects = function (aff)
	{
		if (aff) {
			return typeof self.affects[aff] !== 'undefined' ? self.affects[aff] : false;
		}
		return self.affects;
	};

	/**
	 * Add, activate and set a timer for an affect<commit_msg>Add logic to set/get description to player file. Add command and translation strings.<commit_after>var Data    = require('./data').Data,
    Skills  = require('./skills').Skills,
    crypto  = require('crypto'),
    ansi    = require('sty'),
    util    = require('util');
    events  = require('events');


var npcs_scripts_dir = __dirname + '/../scripts/player/';
var l10n_dir         = __dirname + '/../l10n/scripts/player/';

var Player = function(socket) {
	var self = this;
	self.name     = '';
	self.description = '';
	self.location = null;
	self.locale   = null;
	self.prompt_string = '%health/%max_healthHP>';
	self.combat_prompt =
	   "<bold>[%health/%max_healthHP] 0--{======> %target_name: [%target_health/%target_max_health]</bold>\r\n>";
	self.password = <PASSWORD>;
	self.inventory = [];
	self.equipment = {};

	// In combat is either false or an NPC vnum
	self.in_combat = false;

	// Attributes
	self.attributes = {
		max_health: 100,
		health : 100,
		level: 1,
		experience: 0,
		'class': ''
	};

	// Anything affecting the player
	self.affects = {
	};

	// Skills the players has
	self.skills = {
	};

	/**#@+
	 * Mutators
	 */
	self.getPrompt       = function () { return self.prompt_string; };
	self.getCombatPrompt = function () { return self.combat_prompt; };
	self.getLocale       = function () { return self.locale; };
	self.getName         = function () { return self.name; };
	self.getDescription  = function () { return self.description; };
	self.getLocation     = function () { return self.location; };
	self.getSocket       = function () { return socket; };
	self.getInventory    = function () { return self.inventory; };
	self.getAttribute    = function (attr)  { return typeof self.attributes[attr] !== 'undefined' ? self.attributes[attr] : false; };
	self.getSkills       = function (skill) { return typeof self.skills[skill] !== 'undefined'    ? self.skills[skill]    : self.skills; };
	// Note, only retreives hash, not a real password
	self.getPassword     = function () { return self.password; };
	self.isInCombat      = function () { return self.in_combat; };
	self.setPrompt       = function (str)       { self.prompt_string = str; }
	self.setCombatPrompt = function (str)       { self.combat_prompt = str; }
	self.setLocale       = function (locale)    { self.locale = locale; };
	self.setName         = function (newname)   { self.name = newname; };
	self.setDescription  = function (newdesc)	{self.description = newdesc; };
	self.setLocation     = function (loc)       { self.location = loc; };
	self.setPassword     = function (pass)      { self.password = crypto.createHash('md5').update(pass).digest('hex'); };
	self.addItem         = function (item)      { self.inventory.push(item); };
	self.removeItem      = function (item)      { self.inventory = self.inventory.filter(function (i) { return item !== i; }); };
	self.setInventory    = function (inv)       { self.inventory = inv; };
	self.setInCombat     = function (combat)    { self.in_combat = combat; };
	self.setAttribute    = function (attr, val) { self.attributes[attr] = val; };
	self.addSkill        = function (name, skill) { self.skills[name] = skill; };
	/**#@-*/

	/**
	 * Get currently applied affects
	 * @param string aff
	 * @return Array|Object
	 */
	self.getAffects = function (aff)
	{
		if (aff) {
			return typeof self.affects[aff] !== 'undefined' ? self.affects[aff] : false;
		}
		return self.affects;
	};

	/**
	 * Add, activate and set a timer for an affect
{'fraction_non_alphanumeric': 0.1589118477776126, 'fraction_numerical': 0.004162330905306972, 'mean_word_length': 3.026331538001197, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '2302297', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2182, 'n_words': 489}