Skip to content

Instantly share code, notes, and snippets.

@anubisthejackle
Created November 10, 2014 01:19
Show Gist options
  • Save anubisthejackle/8887048f7efec6a16f71 to your computer and use it in GitHub Desktop.
Save anubisthejackle/8887048f7efec6a16f71 to your computer and use it in GitHub Desktop.
selectID: function(channel){
var id, nick, list = [];
if( typeof this.weights[ channel ] == 'undefined' || this.weights[ channel ].length < 1 ){
this.identities[ channel ] = this.nicks[ channel ][ Math.floor( Math.random() * this.nicks[ channel ].length ) ];
return;
}
for( nick in this.weights[ channel ] ){
list = list.concat( Array(this.weights[ channel ][ nick ]+1).join( nick + ',' ).slice(0, -1).split( ',' ) );
}
this.identities[ channel ] = list[ Math.floor( Math.random() * list.length ) ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment