Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var accmanager = new account(socket); //this var is defined a little earlier but I added it in so you know what accmanager is
- socket.on("character", function(choice){
- if(accmanager.changeChar(choice)){
- socket.emit('message','Character selection: Changed to '+choice.name+"-"+choice.realm+"-"+choice.region+".");
- }else{
- socket.emit('message','Character selection: Failed to switch characters.');
- }
- });
- //This function is basically a javascript class to hold all the info/change the info on that socket.
- function account(socket){
- var socket = socket;
- var charlist = {};
- var selected = {'name':'','realm':'','region':''};
- //removed the extra function so it's not so bloated
- this.changeChar = function(choice){
- //needs to check if you own that character
- if(!choice.name || !choice.realm || !choice.region || !choice.roll){
- console.log(choice);
- console.log(choice.name);
- console.log(choice.realm);
- console.log(choice.region);
- console.log(choice.roll);
- return false;
- }
- if(charlist.name == choice.name && charlist.realm == choice.realm && charlist.region == choice.region){
- console.log("equal");
- return false;
- }
- selected.name = choice.name;
- selected.realm = choice.realm;
- selected.region = choice.region
- console.log(selected);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement