Advertisement
Guest User

Untitled

a guest
Jan 26th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. var accmanager = new account(socket); //this var is defined a little earlier but I added it in so you know what accmanager is
  2. socket.on("character", function(choice){
  3. if(accmanager.changeChar(choice)){
  4. socket.emit('message','Character selection: Changed to '+choice.name+"-"+choice.realm+"-"+choice.region+".");
  5. }else{
  6. socket.emit('message','Character selection: Failed to switch characters.');
  7. }
  8. });
  9.  
  10. //This function is basically a javascript class to hold all the info/change the info on that socket.
  11. function account(socket){
  12. var socket = socket;
  13. var charlist = {};
  14. var selected = {'name':'','realm':'','region':''};
  15.  
  16. //removed the extra function so it's not so bloated
  17. this.changeChar = function(choice){
  18. //needs to check if you own that character
  19. if(!choice.name || !choice.realm || !choice.region || !choice.roll){
  20. console.log(choice);
  21. console.log(choice.name);
  22. console.log(choice.realm);
  23. console.log(choice.region);
  24. console.log(choice.roll);
  25. return false;
  26. }
  27. if(charlist.name == choice.name && charlist.realm == choice.realm && charlist.region == choice.region){
  28. console.log("equal");
  29. return false;
  30. }
  31. selected.name = choice.name;
  32. selected.realm = choice.realm;
  33. selected.region = choice.region
  34. console.log(selected);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement