Advertisement
Icegoten

game-fun.js

Mar 24th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var secret_word_on = false;
  2. var secret_word = "";
  3.  
  4. var taboo_on = false;
  5. var taboo_word = "";
  6.  
  7. var hot_potato_on = false;
  8. var hot_potato_holder = "";
  9.  
  10. var current_alive = [];
  11.  
  12. var roulette_on = false;
  13. var roulette_loaded = [];
  14. var roulette_capacity = 6;
  15. var roulette_rounds = 1;
  16. var roulette_shots = 0;
  17. var roulette_people_fired = [];
  18.  
  19. var auto_target = {};
  20.  
  21.  
  22. function pick_random_alive(){
  23.     update_current_alive();
  24.     return current_alive[Math.floor(Math.random()*current_alive.length)];
  25. }
  26.  
  27. function update_current_alive(){
  28.     current_alive = [];
  29.     $('ul#alive > li > .username').each(function() {
  30.         current_alive.push($(this).text());
  31.     });
  32. }  
  33.  
  34. function play_roulette(n_shots, n_capacity) {
  35.     roulette_rounds = n_shots;
  36.     roulette_capacity = n_capacity;
  37.     roulette_people_fired = [];
  38.     roulette_loaded = [];
  39.     roulette_shots = 0;
  40.     roulette_on = true;
  41.  
  42.     var temp_loaded = 0;
  43.  
  44.     for(i=0; i<n_capacity; i++) {
  45.         roulette_loaded[i] = false;
  46.     }
  47.  
  48.     while(temp_loaded < n_shots) {
  49.         for(i=0; i<n_capacity; i++) {
  50.             if(Math.floor(Math.random() * 11) == 1) {
  51.                 if(!roulette_loaded[i]) {
  52.                     roulette_loaded[i] = true;
  53.                     temp_loaded += 1;
  54.                 }
  55.             }
  56.         }
  57.     }
  58.  
  59.     epicmafia_say('ROULETTE HAS STARTED, ' + n_shots + ' LOADED WITH ' + n_capacity + ' CHAMBERS. TYPE !ROULETTE TO PRESS YOUR LUCK.');
  60. }
  61.  
  62. function hot_potato(n_timer){
  63.     var timeout = 0;
  64.     if (typeof n_timer == "undefined" || n_timer == ""){
  65.         n_timer = 5 + (Math.floor(Math.random()*25)+1);
  66.     }
  67.     timeout = 1000 * n_timer;
  68.     hot_potato_holder = pick_random_alive();
  69.     hot_potato_on = true;
  70.    
  71.     epicmafia_say('HOT POTATO, HOT POTATO, WHO\'S GOT THE HOT POTATO? PASS WITH !pass OR PICK SOMEONE TO PASS TO!');
  72.     epicmafia_say(hot_potato_holder + ' HAS THE HOT POTATO!');
  73.     setTimeout("hot_potato_splat()",timeout);
  74. }
  75.  
  76. function hot_potato_splat(){
  77.     if(hot_potato_on){
  78.         epicmafia_say('TIME\'S UP! ' + hot_potato_holder + ' HAD THE HOT POTATO!');
  79.         epicmafia_vote('gun', hot_potato_holder);
  80.         hot_potato_on = false;
  81.     }
  82. }
  83. function play_secret_word(word) {
  84.     epicmafia_say("WATCH WHAT YOU SAY THERE\'S A SECRET WORD ABOUT!")
  85.     secret_word_on = true;
  86.     var createword = function() { secret_word = word; }
  87.     setTimeout(createword,50);
  88. }
  89.  
  90. function play_taboo(word) {
  91.     epicmafia_say("WATCH WHAT YOU SAY THE TABOO WORD IS " + word)
  92.     taboo_on = true;
  93.     taboo_word = word;
  94. }
  95.  
  96. function whisper_all(message) {
  97.     $('ul#alive > li > .username').each(function lol(index, element) {
  98.         setTimeout(function() {
  99.             who = $.trim(element.innerHTML);
  100.             epicmafia_whisper(message, who);
  101.         }, index * 1000);
  102.     });
  103. }
  104.  
  105. $('#contactselect').children().each(function(index, element) {
  106.     console.log($.trim($(element).val()));
  107. })
  108.  
  109. function contact_all_fun() {
  110.     $('#contactselect').children().each(function(index, element) {
  111.         setTimeout(function() {
  112.             who = $.trim($(element).val());
  113.             var players = $('ul#alive > li > .username');
  114.             var random_alive = $.trim(players[Math.floor(Math.random() * players.length)].innerHTML);
  115.             epicmafia_contact('SUP ' + who + ', GUILTY ON ' + random_alive, who);
  116.         }, index * 1000);
  117.     });
  118. }
  119.  
  120.  
  121. function contact_all(message) {
  122.     $('#contactselect').children().each(function(index, element) {
  123.         setTimeout(function() {
  124.             who = $.trim($(element).val());
  125.             var random = Math.floor(Math.random() * 15);
  126.             var padding = '';
  127.             for(x=0; x<=random; x++) {
  128.                 padding += ' ';
  129.             }
  130.             epicmafia_contact(message + padding, who);
  131.         }, index * 1000);
  132.     });
  133. }
  134.  
  135. function vent_all(message) {
  136.     $('ul#alive > li > .username').each(function lol(index, element) {
  137.         setTimeout(function() {
  138.             who = $.trim(element.innerHTML);
  139.             epicmafia_vent(message, who);
  140.         }, index * 1000);
  141.     });
  142. }
  143.  
  144.  
  145. function vent_combo(message) {
  146.     $('#ventuser').children().each(function(d, e) {
  147.         if(d < message.length) {
  148.             ventuser = e.value;
  149.             venttarget = '*';
  150.             ventriloon = true
  151.             $('#typebox').val(message[d]).submit();
  152.         }
  153.     })
  154. }
  155.  
  156.  
  157.  
  158. function on_games(b, a) {
  159.     if(user == 'Icegoten') {
  160.         return;
  161.     }
  162.  
  163.     if(a.msg.toLowerCase() == '!roulette') {
  164.         if(roulette_on && roulette_shots < roulette_capacity && roulette_people_fired.indexOf(a.user) < 0) {
  165.             if(roulette_loaded[roulette_shots]) {
  166.                 epicmafia_vote('gun', a.user);
  167.                 epicmafia_say('CONGRATULATIONS TO THE WINNER, THIS ROULETTE IS OVER.');
  168.                 roulette_on = false;
  169.             } else {
  170.                 epicmafia_say(a.user + ' PRESSES HIS LUCK AND FIRES THE GUN. *CLICK*');
  171.             }
  172.             roulette_people_fired.push(a.user);
  173.             roulette_shots += 1;
  174.         }
  175.     } else if(a.msg.toLowerCase() == '!random_alive' && a.user == user) {
  176.         var random_alive = pick_random_alive();
  177.         epicmafia_say('AND THE LOTTERY WINNER IS: ' + random_alive);
  178.     }
  179.     if(secret_word_on) {
  180.         var re = new RegExp(secret_word, 'gi');
  181.         if(re.test(a.msg)) {
  182.             epicmafia_vote('gun', a.user);
  183.             epicmafia_say('CONGRATULATIONS TO THE WINNER, THE SECRET WORD WAS ' + secret_word);
  184.             secret_word_on = false;
  185.         }
  186.     }
  187.     if(taboo_on) {
  188.         var re = new RegExp(taboo_word, 'gi');
  189.         if(re.test(a.msg) && a.user != user) {
  190.             epicmafia_vote('gun', a.user);
  191.             epicmafia_say(a.user + ' BROKE THE TABOO');
  192.             taboo_on = false;
  193.         }
  194.     }
  195.    
  196.     if(hot_potato_on && a.user == hot_potato_holder) {
  197.        
  198.         if (a.msg.toLowerCase().substr(0,5) == '!pass'){
  199.             hot_potato_holder = pick_random_alive();
  200.             epicmafia_say(a.user + ' THREW THE HOT POTATO TO ' + hot_potato_holder);
  201.         } else if (a.msg.substr(0,4).toLowerCase() == "!eat") {
  202.             epicmafia_say(a.user + ' WAS SO HUNGRY, HE ATE THE HOT POTATO');
  203.             hot_potato_splat();
  204.         } else {
  205.             update_current_alive();
  206.             if(current_alive.indexOf(a.msg) != -1){
  207.                 hot_potato_holder = a.msg;
  208.                 epicmafia_say(a.user + ' THREW THE HOT POTATO TO ' + a.msg);
  209.             }
  210.         }
  211.     }
  212.     if(a.msg.substr(0,6) == '!name ') {
  213.         var name = find_name(a.msg.substr(6));
  214.         if(name != null) {
  215.             epicmafia_say(name);
  216.         }
  217.     }
  218. }
  219.  
  220.  
  221. /*
  222. (function($){
  223.   $.fn.shuffle = function() {
  224.     return this.each(function(){
  225.       var items = $(this).children();
  226.       return (items.length)
  227.         ? $(this).html($.shuffle(items))
  228.         : this;
  229.     });
  230.   }
  231.  
  232.   $.shuffle = function(arr) {
  233.     for(
  234.       var j, x, i = arr.length; i;
  235.       j = parseInt(Math.random() * i),
  236.       x = arr[--i], arr[i] = arr[j], arr[j] = x
  237.     );
  238.     return arr;
  239.   }
  240. })(jQuery);
  241.  
  242.  
  243.  
  244. function find_name(text) {
  245.     var people = $.map($('ul#alive > li > .username'), function(element, index) {return $(element).text();});
  246.     people = $.shuffle(people);
  247.     var re = new RegExp('^' + text + '.*$', 'i');
  248.    
  249.  
  250.     for(var index in people) {
  251.         var name = people[index];
  252.         if(name.match(re)) {
  253.             return name;
  254.         }
  255.     }
  256.  
  257.     return null;
  258. }
  259. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement