View difference between Paste ID: uU3j8A78 and 0TgnCkPX
SHOW: | | - or go back to the newest paste.
1
function Obj(data){
2
	
3
	var hash = objs[data.type] ? objs[data.type] : objs[data.type] = {};
4
5
	this.expensiveProperty = data;
6
7
	//other logic
8
9
	hash[json.id] = this;
10
}
11
12
function Player(data, socket){
13
	var thisObj = this;
14
	
15
	Obj.call(this, data);
16
	
17
	this.vars.private['name'] = data.name;
18
	
19
	socket.player = this;
20
	this.socket = socket;
21
}
22
Player.prototype = Object.create(Obj.prototype);
23
Player.prototype.constructor = Obj;
24
Player.prototype.emit = function(data){
25
	this.socket.emit(data);
26
}
27
28
new Player({type:'type1', ...});
29-
	return Object.create(Player);
29+
new Player({type:'type2', ...});
30
new Player({type:'type3', ...});
31
32
function instancePlayer(){
33
	return Object.create( objs['player']['type1'] );
34
}