Guest User

Untitled

a guest
Aug 2nd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 95.68 KB | None | 0 0
  1. /**
  2. * This is the file where the bot commands are located
  3. *
  4. * @license MIT license
  5. */
  6.  
  7.  
  8. var http = require('http');
  9.  
  10. if (Config.serverid === 'showdown') {
  11. var https = require('https');
  12. var csv = require('csv-parse');
  13. }
  14.  
  15.  
  16. //Functions
  17.  
  18. function shuffle(o){
  19. for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  20. return o;
  21. }
  22.  
  23.  
  24. //rps vars
  25. var rpsgame = ['rock','paper','scissors'];
  26. // .set constants
  27.  
  28. var trainers = ["Hero", "Heroine", "Youngster", "Lass", "Camper", "Picnicker", "Bug Catcher", "Aroma Lady", "Twins", "Hiker", "Battle Girl", "Fisherman", "Cyclist-M", "Cyclist-F", "Black Belt", "Artist", "Pkmn Breeder-M", "Pkmn Breeder-F", "Cowgirl", "Jogger", "Pokefan-M", "Pokefan-F", "Poke Kid", "Young Couple", "Ace Trainer-M", "Ace Trainer-F", "Waitress", "Veteran", "Ninja Boy", "Dragon Tamer", "Bird Keeper", "Double Team", "Rich Boy", "Lady", "Gentleman", "Socialite", "Beauty", "Collector", "Policeman", "Pkmn Ranger-M", "Pkmn Ranger-F", "Scientist", "Swimmer-M", "Swimmer-F", "Tuber-M", "Tuber-F", "Sailor", "Sis and Bro", "Ruin Maniac", "Psychic-M", "Psychic-F", "PI", "Guitarist", "Ace-M2", "Ace-F2", "Skier-M", "Skier-F", "Roughneck", "Clown", "Worker", "School Kid-M", "School Kid-F", "Roark", "Rival", "Byron", "Aaron", "Bertha", "Flint", "Lucian", "Cynthia", "Belle & Pa", "Rancher", "Commander-F", "Galactic Grunt-M", "Gardenia", "Wake", "Maylene", "Fantina", "Candice", "Volkner", "Parasol Lady", "Waiter", "Interviewers", "Cameraman", "Reporter", "Idol", "Galactic Boss", "Commander-F2", "Commander-M", "Galactic Grunt-F", "Hall Matron", "Tower Tycoon", "Factory Head", "Buck", "Castle Valet", "Marly", "Mira", "Cheryl", "Riley", "Arcade Star", "Hero3", "Heroine3", "Twins2", "Lass2", "Ace Trainer-M2", "Ace Trainer-F2", "Juggler", "Sage", "Elder", "Gentleman2", "Teacher", "Beauty2", "Bird Keeper2", "Swimmer-M2", "Swimmer-F2", "Kimono Girl", "Scientist2", "Double Team2", "Young Couple2", "Super Nerd", "Medium", "School Kid", "Black Belt2", "Poke Maniac", "Fire Breather", "Burglar", "Roughneck2", "Boarder-F", "Boarder-M", "Rocket Grunt-M", "Rocket Grunt-F", "Rocket Executive-M", "Rocket Executive-F", "Rocket Commander","Rocket Commander-2", "Mystery Man", "Hero2", "Heroine2", "Socialite", "Waiter", "Falkner", "Bugsy", "Whitney", "Morty", "Chuck", "Jasmine", "Pryce", "Claire", "Will", "Koga", "Bruno", "Karen", "Lance", "Brock", "Misty", "Surge", "Erika", "Janine", "Sabrina", "Blaine", "Blue", "Red", "Red2", "Rival2", "Rocket Boss", "Mystery Trainer-F", "Mystery Trainer-M", "Mystery Trainer-M2", "Hero4", "Heroine4", "Youngster2", "Lass3", "School Kid-M2", "School Kid-F2", "Smasher", "Linebacker", "Waiter2", "Waitress2", "Chili", "Cylan", "Cress", "Nursery Aide", "Preschooler-F", "Preschooler-M", "Twins3", "Pkmn Breeder-M2", "Pkmn Breeder-F2", "Lenora", "Burgh", "Elesa", "Clay", "Skyla", "Pkmn Ranger-M2", "Pkmn Ranger-F2", "Worker2", "Backpacker-M", "Backpacker-F", "Fisherman2", "Musician", "Dancer", "Harlequin", "Artist2", "Baker", "Psychic-M2", "Psychic-F2", "Cheren", "Bianca", "Plasma Grunt-M", "N", "Rich Boy2", "Lady2", "Pilot", "Worker3", "Hoopster", "Scientist-F", "Clerk-F", "Ace Trainer-F3", "Ace Trainer-M3", "Black Belt3", "Scientist3", "Striker", "Brycen", "Iris", "Drayden", "Roughneck3", "Janitor", "Pokefan-M2", "Pokefan-F2", "Doctor-M", "Doctor-F", "Hooligans", "Battle Girl2", "Parasol Lady2", "Clerk-M", "Clerk Boss", "Backer-M", "Backer-F", "Veteran-M", "Veteran-F", "Motorcyclist", "Infielder", "Hiker2", "Socialite2", "Gentleman3", "Plasma Grunt-F", "Shauntal", "Marshall", "Grimsley", "Caitlin", "Ghetsis", "Depot Agent", "Swimmer-M3", "Swimmer-F3", "Policeman2", "Maid", "Ingo", "Alder", "Cyclist-M2", "Cyclist-F2", "Cynthia2", "Emmet", "Hero5", "Heroine5", "Rival3", "Hero6", "Heroine6", "Colress", "Beauty3", "Ghetsis2", "Team Galactic Grunt-M", "Team Galactic Grunt-F", "Iris2", "Brycen-Man", "Ninja", "Rood", "Zinzolin", "Cheren2", "Marlon", "Roxie", "Roxanne", "Brawly", "Wattson", "Flannery", "Norman", "Winona", "Tate", "Liza", "Guitarist2", "Steven", "Wallace", "Benga", "Ash"]
  29.  
  30.  
  31. var megapoke = ['venusaur-mega','charizard-mega-x','charizard-mega-y','blastoise-mega','alakazam-mega','gengar-mega','kangaskhan-mega','pinsir-mega','gyarados-mega','aerodactyl-mega','mewtwo-mega-x','mewtwo-mega-y','ampharos-mega','scizor-mega','heracross-mega','houndoom-mega','tyranitar-mega','blaziken-mega','gardevoir-mega','mawile-mega','aggron-mega','medicham-mega','manectric-mega','bannette-mega','absol-mega','garchomp-mega','lucario-mega','abomasnow-mega','beedrill-mega','pidgeot-mega','slowbro-mega','steelix-mega','sceptile-mega','swampert-mega','sableye-mega','sharpedo-mega','camerupt-mega','altaria-mega','glalie-mega','salamence-mega','metagross-mega','latias-mega','latios-mega','rayquaza-mega','lopunny-mega','gallade-mega','diancie-mega','audino-mega','groudon-primal','kyogre-primal']
  32.  
  33. var requiredAlt = '+'
  34. var requiredPlayers = 0;
  35. var maxPlayers = 9999;
  36. var started = false;
  37. var game = "none";
  38. var checked = false;
  39. var joinusers = [];
  40. var joinusersid = [];
  41. var playerdata = [];
  42. var safeusers = [];//exclusive to ambush(also using for oldrod )
  43. var currentplayer = 0;
  44. var active;//special to ambush atm(also using for oldrod)
  45. var firetimer;
  46. var starttimer;
  47. var turnspassed = 0;
  48.  
  49. //A Game of Trivia
  50. var triviaQuestions = ['This Pokemon helps Nurse Joy in Pokemon Center and also have highest HP stat','blissey','What is the ability of Charizard Mega - X','toughclaws','A two turn move which starts with the absorbtion of sunlight','solarbeam','Its the only Dark Type Pulsating Move','darkpulse','Which colors are Raichu\'s Cheeks?','yellow','Pokemon having Rock type and SandStorm as his/her Ability','tyranitar','What ability boosts the power of Fire-type moves when the Pokemon is below 1/3 of its health?','blaze', 'What is the subtitle of the first Pokémon movie?','mewtwostrikesback','Name a move that can have a 100% chance of flinching the target barring Fake Out.','fling','What is the only Poison-Type Pokemon to learn Rock Polish?','garbodor','What cave lies between Mahogany Town and Blackthorn City?','icepath','This Electric-Type move increases the user\'s Special Defense.','charge','What is the only Pokémon available in the Yellow Forest Pokéwalker route?','pikachu','This is the nickname of the Pokemon acting as the light source of Glitter Lighthouse in Olivine City.','amphy','This Pokemon has the longest cry.','jynx','This Pokemon Conquest warlord has the warrior ability of "chesto!" at rank 2.','yoshihiro','What Pokemon is based on the mythological kitsune?','ninetales','This is the only pure Flying-Type Pokémon (excluding forms)','tornados','This evolutionary stone either removes a type immunity or adds type immunities when used on certain Pokemon that evolve via this stone.','dawnstone','What is the only single-typed Pokemon with Tangled Feet?','spinda','This is the most expensive item that you can obtain in-game.','gorgeousroyalribbon','This Pokémon is the first Pokémon to be revealed.','rhydon','Name a non Psychic-Type Pokémon that can learn Heart Stamp.','pikachu','This type of berry have the longest name.','marangaberry','Name the only Pokemon with a BST of 336.','unown','Name a Pokémon that can be obtained by breeding a Pokémon they cannot evolve into.','phione','This herbal medicine cures infatuation.','mentalherb','This was the only Dragon-type attack in Generation I.','dragonrage','In the games, baseball players are represented by this trainer class.','infielder','Name one of the six moves that is a Self-KO move.',',memento','How much Poke Dollars does an Escape Rope cost?','500','What starter does your rival have in Pokemon Yellow version?','eevee','In the Pokemon anime, Jessie gives herself this name during the Kanto Grand Festival.','jessadia','What is the only Pokemon able to learn Secret Power by leveling up?','audino','This Pokemon in Pokemon Mystery Dungeon: Explorers of Time/Darkness/Sky has the job of waking up you and your partner in the morning.','exploud','In the main series Pokemon games, there are various Pokemon that impede your path to new areas. Name one.','snorlax','Name the only Pokemon to weigh 0.9 kg.','floette','This is the first Key Item you have in Pokemon X and Y.','holocaster','What is Castelia Park shaped like?','pokeball',' This Gym Leader doesn\'t have a Vs. Sprite.','juan'];
  51. var triviaRoom; // This var will check if trivia is going in other room or not..
  52. var triviaON = false; // A switch case to tell if trivia is going on not
  53. var triviaTimer; // Keeps the track of the timer of the trivia
  54. var triviaA; // The answer of the trivia
  55. var triviaQ; // Question of trivia
  56. var triviaPoints = []; // This empty object will keep the track off all the trivia points during a game of trivia
  57. var teamOne = [];
  58. var teamTwo = [];
  59. var teamOnePoints = 0;
  60. var teamTwoPoints = 0;
  61. clearInterval(triviaTimer);
  62.  
  63. //blackjack variables
  64.  
  65. var cards = ["A","A","A","A",2,2,2,2,3,3,3,3,4,4,4,4,
  66. 5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,
  67. 10,10,10,10,"J","J","J","J","Q","Q","Q","Q","K","K","K","K"];
  68.  
  69. var numofaces = 0;
  70. var dealerstotal = 0; //(using this for old rod)
  71.  
  72. //blackjack variables end
  73.  
  74. //oldrod variables
  75.  
  76. var rounds = 1;
  77. var waterpoke = ["Tentacool",50,"Magikarp",50,"Wailmer",50,"Wailord",150,"Relicanth",100];
  78. var wait = ["...","...","...","...","!"]; // I know this is useless xD and the name is horrible lol
  79.  
  80.  
  81.  
  82.  
  83. const CONFIGURABLE_COMMANDS = {
  84. autoban: true,
  85. banword: true,
  86. say: true,
  87. 'checkroom': true,
  88. 'setalt':true,
  89. 'reload': true,
  90. 'rps': true,
  91. 'joingame': true,
  92. 'startgame': true,
  93. 'endgame': true,
  94. 'stay': true,
  95. 'hit': true,
  96. 'fire': true,
  97. 'signup': true,
  98. 'reel': true,
  99. 'randpoke': true,
  100. 'randa': true,
  101. 'custsay': true,
  102. '8ball': true,
  103. 'lennyraid': true
  104. };
  105.  
  106. const CONFIGURABLE_MODERATION_OPTIONS = {
  107. flooding: true,
  108. caps: true,
  109. stretching: true,
  110. bannedwords: true
  111. };
  112.  
  113. const CONFIGURABLE_COMMAND_LEVELS = {
  114. off: false,
  115. disable: false,
  116. 'false': false,
  117. on: true,
  118. enable: true,
  119. 'true': true
  120. };
  121.  
  122. for (let i in Config.groups) {
  123. if (i !== ' ') CONFIGURABLE_COMMAND_LEVELS[i] = i;
  124. }
  125.  
  126. exports.commands = {
  127. /**
  128. * Help commands
  129. *
  130. * These commands are here to provide information about the bot.
  131. */
  132.  
  133. credits: 'about',
  134. about: function (arg, user, room) {
  135. var text = (room === user || user.hasRank(room.id, '#')) ? '' : '/pm ' + user.id + ', ';
  136. text += 'Still Configuring this bot.';
  137. this.say(room, text);
  138. },
  139.  
  140.  
  141.  
  142. git: function (arg, user, room) {
  143. var text = (room === user || user.isExcepted()) ? '' : '/pm ' + user.id + ', ';
  144. text += '**Pokemon Showdown Bot** source code: ' + Config.fork;
  145. this.say(room, text);
  146. },
  147. help: 'guide',
  148. guide: function (arg, user, room) {
  149. var text = (room === user || user.hasRank(room.id, '#')) ? '' : '/pm ' + user.id + ', ';
  150. if (Config.botguide) {
  151. text += 'A guide on how to use this bot can be found here: ' + Config.botguide;
  152. } else {
  153. text += 'There is no guide for this bot. PM the owner with any questions.';
  154. }
  155. this.say(room, text);
  156. },
  157.  
  158. /**
  159. * Dev commands
  160. *
  161. * These commands are here for highly ranked users (or the creator) to use
  162. * to perform arbitrary actions that can't be done through any other commands
  163. * or to help with upkeep of the bot.
  164. */
  165.  
  166. reload: function (arg, user, room) {
  167. //if (!user.isExcepted()) return false;
  168. try {
  169. this.uncacheTree('./commands.js');
  170. Commands = require('./commands.js').commands;
  171. this.say(room, 'Commands reloaded.');
  172. } catch (e) {
  173. error('failed to reload: ' + e.stack);
  174. }
  175. },
  176. custom: function (arg, user, room) {
  177. //if (!user.isExcepted()) return false;
  178. // Custom commands can be executed in an arbitrary room using the syntax
  179. // ".custom [room] command", e.g., to do !data pikachu in the room lobby,
  180. // the command would be ".custom [lobby] !data pikachu". However, using
  181. // "[" and "]" in the custom command to be executed can mess this up, so
  182. // be careful with them.
  183. if (arg.indexOf('[') !== 0 || arg.indexOf(']') < 0) {
  184. return this.say(room, arg);
  185. }
  186. var tarRoomid = arg.slice(1, arg.indexOf(']'));
  187. var tarRoom = Rooms.get(tarRoomid);
  188. if (!tarRoom) return this.say(room, Users.self.name + ' is not in room ' + tarRoomid + '!');
  189. arg = arg.substr(arg.indexOf(']') + 1).trim();
  190. this.say(tarRoom, arg);
  191. },
  192.  
  193. uptime: function (arg, user, room) {
  194. var text = ((room === user || user.isExcepted()) ? '' : '/pm ' + user.id + ', ') + '**Uptime:** ';
  195. var divisors = [52, 7, 24, 60, 60];
  196. var units = ['week', 'day', 'hour', 'minute', 'second'];
  197. var buffer = [];
  198. var uptime = ~~(process.uptime());
  199. do {
  200. let divisor = divisors.pop();
  201. let unit = uptime % divisor;
  202. buffer.push(unit > 1 ? unit + ' ' + units.pop() + 's' : unit + ' ' + units.pop());
  203. uptime = ~~(uptime / divisor);
  204. } while (uptime);
  205.  
  206. switch (buffer.length) {
  207. case 5:
  208. text += buffer[4] + ', ';
  209. /* falls through */
  210. case 4:
  211. text += buffer[3] + ', ';
  212. /* falls through */
  213. case 3:
  214. text += buffer[2] + ', ' + buffer[1] + ', and ' + buffer[0];
  215. break;
  216. case 2:
  217. text += buffer[1] + ' and ' + buffer[0];
  218. break;
  219. case 1:
  220. text += buffer[0];
  221. break;
  222. }
  223.  
  224. this.say(room, text);
  225. },
  226.  
  227.  
  228. /**
  229. * General commands
  230. *
  231. * Add custom commands here.
  232. */
  233.  
  234. tell: 'say',
  235. say: function (arg, user, room) {
  236. if (room === user || !user.canUse('say', room.id)) return false;
  237. this.say(room, stripCommands(arg) + ' (' + user.name + ' said this)');
  238. },
  239.  
  240. '8ball': function (arg, user, room) {
  241. if (room === user) return false;
  242. var text = user.canUse('8ball', room.id) ? '' : '/pm ' + user.id + ', ';
  243. var rand = ~~(21 * Math.random());
  244.  
  245. switch (rand) {
  246. case 0:
  247. text += "Signs point to yes.";
  248. break;
  249. case 1:
  250. text += "Yes.";
  251. break;
  252. case 2:
  253. text += "Reply hazy, try again.";
  254. break;
  255. case 3:
  256. text += "Without a doubt.";
  257. break;
  258. case 4:
  259. text += "My sources say no.";
  260. break;
  261. case 5:
  262. text += "As I see it, yes.";
  263. break;
  264. case 6:
  265. text += "You may rely on it.";
  266. break;
  267. case 7:
  268. text += "Concentrate and ask again.";
  269. break;
  270. case 8:
  271. text += "Outlook not so good.";
  272. break;
  273. case 9:
  274. text += "It is decidedly so.";
  275. break;
  276. case 10:
  277. text += "Better not tell you now.";
  278. break;
  279. case 11:
  280. text += "Very doubtful.";
  281. break;
  282. case 12:
  283. text += "Yes - definitely.";
  284. break;
  285. case 13:
  286. text += "It is certain.";
  287. break;
  288. case 14:
  289. text += "Cannot predict now.";
  290. break;
  291. case 15:
  292. text += "Most likely.";
  293. break;
  294. case 16:
  295. text += "Ask again later.";
  296. break;
  297. case 17:
  298. text += "My reply is no.";
  299. break;
  300. case 18:
  301. text += "Outlook good.";
  302. break;
  303. case 19:
  304. text += "Don't count on it.";
  305. break;
  306. case 20:
  307. text += "What ever. Conbeef is Great :D.";
  308. break;
  309. }
  310.  
  311. this.say(room, text);
  312. },
  313.  
  314.  
  315. /**
  316. * Room specific commands
  317. *
  318. * These commands are used in specific rooms on the Smogon server.
  319. */
  320.  
  321. //my commands
  322.  
  323. 'setalt': function(arg, user, room) {
  324. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  325. var text = "";
  326. switch(arg){
  327.  
  328. default:
  329. text += "No rank specified.";
  330. return this.say(room, text);
  331.  
  332. case "+":
  333. requiredAlt = '+';
  334. text += "Rank required is now set to **+** ";
  335. return this.say(room, text);
  336.  
  337. case "%":
  338. requiredAlt = '%';
  339. text += "Rank required is now set to **%** ";
  340. return this.say(room, text);
  341.  
  342. case "@":
  343. requiredAlt = '@';
  344. text += "Rank required is now set to **@** ";
  345. return this.say(room, text);
  346.  
  347. case "&":
  348. requiredAlt = '&';
  349. text += "Rank required is now set to **&** ";
  350. return this.say(room, text);
  351.  
  352. case "#":
  353. requiredAlt = '#';
  354. text += "Rank required is now set to **#** ";
  355. return this.say(room, text);
  356.  
  357. }
  358. },
  359.  
  360.  
  361. //Trivia Commands
  362. trivia: function(arg, user, room){
  363. if (room === user) return false;
  364. var text = '';
  365. if (game !="none"){
  366. return this.say( room,"Cannot start a game of trivia because a scripted game is running. Do .endgame!")
  367. }
  368. if(triviaON){this.say( room, '**ERROR**: A game of trivia is going on another room and hence it cannot be started here'); return false;}
  369. triviaON = true;
  370. triviaRoom = room.id;
  371. triviaA = '';
  372. triviaPoints = [];
  373. this.say( room, 'Hosting a game of **trivia**. Answer the questions using -ta or -triviaanswer. First to get 10 points wins.');
  374. triviaTimer = setInterval( function() {
  375. if(triviaA){this.say(room, '**BEEP** TIMES UP!! ' + triviaA);}
  376. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  377. triviaQ = triviaQuestions[TQN];
  378. triviaA = triviaQuestions[TQN+ 1];
  379. this.say( room, '**Question**: ' + triviaQ);
  380. }.bind(this), 15000);
  381.  
  382. },
  383. triviapoints: function(arg, user, room){
  384. var text = user.canUse('8ball', room.id) ? '' : '/pm ' + user.id + ', ';
  385. if(!anagramON) return false;
  386. var text = '**Triviapoints so far**: '
  387. for (var i = 0; i < triviaPoints.length; i++){
  388. text += '' + triviaPoints[i] + ': ';
  389. text += triviaPoints[i + 1] + ' Pokepoints, ';
  390. i++
  391. }
  392. this.say(room, text);
  393. },
  394. ta: 'triviaanswer',
  395. triviaanswer: function(arg, user, room){
  396. if(room.id !== triviaRoom) return false;
  397. if (game != "none") return false;
  398. if (!arg) return false;
  399. arg = (arg);
  400. var theuser = (user.name);
  401. if(arg == triviaA){
  402. if (triviaPoints.indexOf(theuser) > -1){
  403. triviaA = '';
  404. triviaPoints[triviaPoints.indexOf(theuser) + 1] += 1;
  405. if (triviaPoints[triviaPoints.indexOf(theuser) + 1] >= 10) {
  406. clearInterval(triviaTimer);
  407. this.say( room, '**Congrats to ' + user.name + ' for winning Trivia!**');
  408. this.say(room,'/pm '+ user.name + ' ,**Congratulations** on winning the game of trivia.')
  409. this.say(room,'/msg lustrousash,' + user.name + ' have been awarded **2 Points** for winning trivia')
  410. triviaON = false;
  411. return false;
  412. }
  413. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoints!');
  414. } else {
  415. triviaA = '';
  416. triviaPoints[triviaPoints.length] = theuser;
  417. triviaPoints[triviaPoints.length] = 1;
  418. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoint!');
  419. }
  420. }
  421. },
  422. triviaend: function(arg, user, room){
  423. if (game != "none") return false;
  424. if(room.id !== triviaRoom)return false;
  425. if(!triviaON) return false;
  426. //if (room === user || !user.hasRank(room.id, '#@+%')) return false;
  427. clearInterval(triviaTimer);
  428. this.say(room, 'The game of trivia has been ended.');
  429. triviaON = false;
  430. },
  431.  
  432. /**
  433. * PMRaid Commands
  434. *
  435. * Commands that are also legit cancer.
  436. */
  437. cr: 'checkroom',
  438. checkroom: function(arg, user, room) {
  439. this.say(room,"room id = "+ room.id + " |" + " serverid = "+ Config.serverid + " | " + "export server = "+ Config.server)
  440. },
  441.  
  442. /*
  443. 'lennyraid': function(arg, user, room) {
  444. //if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  445. var theuser = user.name;
  446. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  447. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  448. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  449. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  450. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  451. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  452. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  453. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  454. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  455. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  456.  
  457.  
  458. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  459. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  460. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  461. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  462. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  463. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  464. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  465. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  466.  
  467.  
  468. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  469. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  470. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  471. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  472. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  473. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  474. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  475. },
  476. */
  477.  
  478.  
  479.  
  480.  
  481. 'randpoke': function (arg, user, room) {
  482. if (room === user) return false;
  483. var text = user.canUse('randpoke', room.id) ? '' : '/pm ' + user.id + ', ';
  484.  
  485. switch (arg){
  486.  
  487. case "gen1":
  488. var rand = Math.round(Math.random() * (151 - 1) + 1);
  489. text += "!dt"+" "+rand;
  490. break;
  491.  
  492. case "gen2":
  493. var rand = Math.round(Math.floor(Math.random() * (251 -152) + 152));
  494. text += "!dt"+" "+rand;
  495. break;
  496.  
  497. case "gen3":
  498. var rand = Math.round(Math.floor(Math.random() * (386 - 252) + 252));
  499. text += "!dt"+" "+rand;
  500. break;
  501.  
  502. case "gen4":
  503. var rand = Math.round(Math.floor(Math.random() * (493 - 387) + 387));
  504. text += "!dt"+" "+rand;
  505. break;
  506.  
  507. case "gen5":
  508. var rand = Math.round(Math.floor(Math.random() * (649 - 494) + 494));
  509. text += "!dt"+" "+rand;
  510. break;
  511.  
  512. case "gen6":
  513. var rand = Math.round(Math.floor(Math.random() * (721 - 650) + 650));
  514. text += "!dt"+" "+rand;
  515. break;
  516.  
  517. default:
  518. var rand = ~~(721 * Math.random());
  519. text += "!dt"+" "+rand;
  520. break;
  521.  
  522. }
  523. this.say(room, text);
  524. },
  525.  
  526. 'custsay': function (arg, user, room) {
  527. if (room === user) return false;
  528. //arg = toId(arg)
  529. var text = user.canUse('custsay', room.id) ? '' : '/pm ' + user.id + ', ';
  530. text += arg;
  531. this.say(room, text);
  532. },
  533.  
  534.  
  535. 'rps': function (arg, user, room) {
  536. var playerschoice = arg.toUpperCase();
  537. var choices = ["Rock","Paper","Scissors"];
  538.  
  539. if (playerschoice == "ROCK"){
  540. playerschoice = "Rock";
  541. }
  542.  
  543.  
  544. if (playerschoice == "PAPER"){
  545. playerschoice = "Paper";
  546. }
  547.  
  548.  
  549. if (playerschoice == "SCISSORS"){
  550. playerschoice = "Scissors";
  551. }
  552.  
  553. switch(playerschoice){
  554.  
  555. case "Rock":
  556.  
  557. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  558. this.say(room,user.name + ", I pick "+ botchoice);
  559.  
  560. if (botchoice == "Rock" ){
  561. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  562. break;
  563. }
  564.  
  565. if (botchoice == "Paper" ){
  566. return this.say(room,"Sorry " + user.name + ", Paper beats Rock. Want to play again? (¬‿¬)");
  567. break;
  568. }
  569.  
  570.  
  571. if (botchoice == "Scissors" ){
  572. return this.say(room,user.name + ", You win. Want to play again? ");
  573. break;
  574. }
  575.  
  576.  
  577.  
  578. case "Paper":
  579.  
  580. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  581. this.say(room,user.name + ", I pick "+ botchoice);
  582.  
  583. if (botchoice == "Paper" ){
  584. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  585. break;
  586. }
  587.  
  588. if (botchoice == "Scissors" ){
  589. return this.say(room,"Sorry " + user.name + ", Scissors beats Paper. Want to play again? (¬‿¬)");
  590. break;
  591. }
  592.  
  593.  
  594. if (botchoice == "Rock" ){
  595. return this.say(room,user.name + ", You win. Want to play again? ");
  596. break;
  597. }
  598.  
  599.  
  600. case "Scissors":
  601.  
  602. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  603. this.say(room,user.name + ", I pick "+ botchoice);
  604.  
  605. if (botchoice == "Scissors" ){
  606. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  607. break;
  608. }
  609.  
  610. if (botchoice == "Rock" ){
  611. return this.say(room,"Sorry " + user.name + ", Rock beats Scissors. Want to play again? (¬‿¬)");
  612. break;
  613. }
  614.  
  615.  
  616. if (botchoice == "Paper" ){
  617. return this.say(room,user.name + ", You win. Want to play again? ");
  618. break;
  619. }
  620.  
  621.  
  622. }
  623.  
  624. },
  625.  
  626. ///////////////////////////////////////////Scripted Game Setup//////////////////////////////////////////////////////////////
  627. signups: 'signup',
  628. 'signup': function (arg, user, room) {
  629. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  630. var text = "";
  631. var gametomake = arg.toLowerCase();
  632.  
  633. if (triviaON){
  634. text += "**That game cannot be created, because there is a game of Trivia running. Do .triviaend**"
  635. return this.say(room, text);
  636. }
  637.  
  638. if (gametomake == "bj" || gametomake == "black jack"){
  639. gametomake = "blackjack";
  640. }
  641.  
  642. if (gametomake == "amb"){
  643. gametomake = "ambush";
  644. }
  645.  
  646. if (gametomake == "old" || gametomake == "rod" || gametomake == "old rod" || gametomake == "or"){
  647. gametomake = "oldrod";
  648. }
  649.  
  650. if (gametomake == "tt" || gametomake == "team trivia" || gametomake == "t trivia"){
  651. gametomake = "ttrivia";
  652. }
  653.  
  654. if (gametomake == "8's" || gametomake == "eights" || gametomake == "eight's"){
  655. gametomake = "8s";
  656. }
  657.  
  658. if (game == "none"){
  659.  
  660. switch(gametomake){
  661.  
  662. default:
  663. text += "**That is not a scripted game. Please check spelling**"
  664. return this.say(room, text);
  665. break;
  666.  
  667. case "blackjack":
  668. game = "blackjack";
  669. requiredPlayers = 1;
  670. maxPlayers = 14;
  671. dealerstotal = 0;
  672. currentplayer = 0;
  673. numofaces = 0;
  674. started = false;
  675. joinusers = [];
  676. joinusersid = [];
  677. playerdata = [];
  678. cards = ["A","A","A","A",2,2,2,2,3,3,3,3,4,4,4,4,
  679. 5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,
  680. 10,10,10,10,"J","J","J","J","Q","Q","Q","Q","K","K","K","K"];
  681. text = "";
  682. text += "**Blackjack was created! Do .joingame to join and .startgame to start!**";
  683. return this.say(room, text);
  684. break;
  685.  
  686. case "ambush":
  687. game = "ambush";
  688. requiredPlayers = 2;
  689. maxPlayers = 9999;
  690. joinusers = [];
  691. joinusersid = [];
  692. playerdata = [];
  693. text = "";
  694. text += "**Ambush was created! Do .joingame to join and .startgame to start!**";
  695. return this.say(room, text);
  696. break;
  697.  
  698. case "oldrod":
  699. game = "oldrod";
  700. requiredPlayers = 2;
  701. maxPlayers = 9999;
  702. dealerstotal = 1;
  703. joinusers = [];
  704. joinusersid = [];
  705. safeusers = [];
  706. playerdata = [];
  707. rounds = 1;
  708. text = "";
  709. text += "**Old Rod was created! Do .joingame to join and .startgame to start!**";
  710. return this.say(room, text);
  711. break;
  712.  
  713. case "ttrivia":
  714. game = "ttrivia";
  715. requiredPlayers = 1;
  716. maxPlayers = 9999;
  717. joinusers = [];
  718. joinusersid = [];
  719. playerdata = [];
  720. teamOne = [];
  721. teamTwo = [];
  722. teamOnePoints = 0;
  723. teamTwoPoints = 0;
  724. text = "";
  725. text += "**Team Trivia was created! Do .joingame to join and .startgame to start!**";
  726. return this.say(room, text);
  727. break;
  728.  
  729. case "8s":
  730. game = "8s";
  731. requiredPlayers = 2;
  732. maxPlayers = 16;
  733. joinusers = [];
  734. joinusersid = [];
  735. playerdata = [];
  736. teamOne = [];
  737. teamTwo = [];
  738. text = "";
  739. text += "**8's was created! Do .joingame to join and .startgame to start!**";
  740. return this.say(room, text);
  741. break;
  742.  
  743. }
  744. }else{
  745. text += "**A scripted game was already made. Please do .endgame to end the game.**";
  746. return this.say(room, text);
  747. text = "";
  748. }
  749.  
  750. },
  751.  
  752. end: 'endgame',
  753. 'endgame': function (arg, user, room) {
  754. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  755. var text = "";
  756.  
  757. switch(game){
  758.  
  759. case "none":
  760. text += "**There is no game currently running.**";
  761. return this.say(room, text);
  762. text = "";
  763. break;
  764.  
  765. case "blackjack":
  766. game = "none";
  767. started = false;
  768. requiredPlayers = 0;
  769. text += "**Blackjack has ended.**";
  770. return this.say(room, text);
  771. break;
  772.  
  773. case "ambush":
  774. game = "none";
  775. started = false;
  776. requiredPlayers = 0;
  777. clearInterval(active);
  778. text += "**Ambush has ended.**";
  779. return this.say(room, text);
  780. break;
  781.  
  782. case "oldrod":
  783. game = "none";
  784. started = false;
  785. requiredPlayers = 0;
  786. clearInterval(active);
  787. clearTimeout(active);
  788. text += "**Old Rod has ended.**";
  789. return this.say(room, text);
  790. break;
  791.  
  792. case "ttrivia":
  793. game = "none";
  794. clearInterval(triviaTimer);
  795. started = false;
  796. triviaON = false;
  797. requiredPlayers = 0;
  798. text += "**Team Trivia has ended.**";
  799. return this.say(room, text);
  800. break;
  801.  
  802. case "8s":
  803. game = "none";
  804. started = false;
  805. requiredPlayers = 0;
  806. text += "**8s has ended.**";
  807. return this.say(room, text);
  808. break;
  809.  
  810. }
  811.  
  812. },
  813.  
  814. start: 'startgame',
  815. 'startgame': function (arg, user, room) {
  816. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  817. var text = "";
  818. if (started == false){
  819. if (game != "none"){
  820. if (joinusers.length >= requiredPlayers){
  821.  
  822. if (game == "blackjack"){
  823. started = true;
  824. text = "";
  825. text += "**The game of Blackjack has started!**";
  826. this.say(room, text);
  827. text = "";
  828.  
  829. var starttimer = setTimeout(function(){
  830.  
  831.  
  832. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  833. var rand = (Math.round(Math.random()*(cards.length-1)));
  834. var choosencard = cards[rand];
  835. var actualcard = choosencard;
  836. cards.splice(rand,1);
  837.  
  838.  
  839. switch(choosencard){
  840. case "A":
  841. numofaces += 1;
  842. choosencard = 11;
  843. actualcard += "(11)";
  844. break;
  845.  
  846. case "J":
  847. choosencard = 10;
  848. actualcard += "(10)";
  849. break;
  850.  
  851. case "Q":
  852. choosencard = 10;
  853. actualcard += "(10)";
  854. break;
  855.  
  856. case "K":
  857. choosencard = 10;
  858. actualcard += "(10)";
  859. break;
  860. }
  861.  
  862. playerdata[currentplayer] = choosencard;
  863. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  864. this.say(room, text);
  865. text = "";
  866.  
  867. text += joinusers[currentplayer] + " .hit or .stay";
  868. this.say(room, text);
  869. text = "";
  870. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  871. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  872. var rand = (Math.round(Math.random()*(cards.length-1)));
  873. var choosencard = cards[rand];
  874. var actualcard = choosencard;
  875. cards.splice(rand,1);
  876.  
  877. if (playerdata[currentplayer] >= 11){
  878.  
  879. switch(choosencard){
  880. case "A":
  881. choosencard = 1;
  882. actualcard += "(1)";
  883. break;
  884.  
  885. case "J":
  886. choosencard = 10;
  887. actualcard += "(10)";
  888. break;
  889.  
  890. case "Q":
  891. choosencard = 10;
  892. actualcard += "(10)";
  893. break;
  894.  
  895. case "K":
  896. choosencard = 10;
  897. actualcard += "(10)";
  898. break;
  899. }
  900. }
  901.  
  902.  
  903. if (playerdata[currentplayer] < 11){
  904.  
  905. switch(choosencard){
  906. case "A":
  907. numofaces += 1;
  908. choosencard = 11;
  909. actualcard += "(11)";
  910. break;
  911.  
  912. case "J":
  913. choosencard = 10;
  914. actualcard += "(10)";
  915. break;
  916.  
  917. case "Q":
  918. choosencard = 10;
  919. actualcard += "(10)";
  920. break;
  921.  
  922. case "K":
  923. choosencard = 10;
  924. actualcard += "(10)";
  925. break;
  926. }
  927. }
  928.  
  929.  
  930. playerdata[currentplayer] += choosencard;
  931.  
  932. if (playerdata[currentplayer] > 21){
  933. if (numofaces > 0){
  934. playerdata[currentplayer] -= 10;
  935. numofaces -= 1
  936. }}
  937.  
  938. text = "";
  939. text += "You got a "+actualcard;
  940. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  941. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  942. text = "";
  943. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  944. }.bind(this), 4000);
  945. }
  946.  
  947. if (game == "ambush"){
  948. var i;
  949. for(i=0;i < joinusers.length; i+=1){
  950. playerdata[i] = 2;
  951. }
  952. started = true;
  953. text = "";
  954. text += "**The game of Ambush has started! (do .fire [user] when I say FIRE!)**";
  955. this.say(room, text);
  956. text = "";
  957.  
  958. var starttimer = setTimeout(function(){
  959. for(i = 0; i < joinusers.length; i +=1){
  960. if (i == joinusers.length-1){
  961. text += joinusers[i]+"! Get ready!";
  962. }
  963. if (i == joinusers.length - 2){
  964. text += joinusers[i]+" and ";
  965. }
  966. if (i != joinusers.length -1 && i != playerdata.length - 2){
  967. text += joinusers[i]+",";
  968. }
  969. }
  970. text = "**"+text+"**";
  971. this.say(room, text);
  972. text = "";
  973.  
  974. checked = true;
  975. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  976. var firetimer = setTimeout(function(){
  977. text = "**FIRE!**";
  978. this.say(room, text);
  979. checked = false;
  980. text = "";;
  981. }.bind(this), delaytime);
  982. active = setInterval(function(){
  983. turnspassed +=1
  984. if (turnspassed < 3){
  985. var starttimer = setTimeout(function(){
  986. for(i = 0; i < joinusers.length; i +=1){
  987. if (i == joinusers.length-1){
  988. text += joinusers[i]+"! Get ready!";
  989. }
  990. if (i == joinusers.length - 2){
  991. text += joinusers[i]+" and ";
  992. }
  993. if (i != joinusers.length -1 && i != playerdata.length - 2){
  994. text += joinusers[i]+",";
  995. }
  996. }
  997. text = "**"+text+"**";
  998. this.say(room, text);
  999. text = "";
  1000.  
  1001. checked = true;
  1002. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  1003. var firetimer = setTimeout(function(){
  1004. text = "**FIRE!**";
  1005. this.say(room, text);
  1006. checked = false;
  1007. text = "";
  1008. active;
  1009.  
  1010. }.bind(this), delaytime);
  1011.  
  1012. }.bind(this), 4000);
  1013. }else{
  1014.  
  1015. text = "A Greninja came out of no where and use water shuriken on everyone. RIP!!! **The game has ended due to inactivity**";
  1016. this.say(room, text);
  1017. text = "";
  1018. clearInterval(active);
  1019. game = "none";
  1020. started = false;
  1021. requiredPlayers = 0;
  1022. turnspassed = 0;
  1023.  
  1024. }
  1025. }.bind(this), 20000);
  1026.  
  1027. }.bind(this), 4000);
  1028. }
  1029.  
  1030.  
  1031. if (game == "ttrivia"){
  1032.  
  1033. started= true;
  1034. shuffle(joinusers);
  1035. triviaON = true;
  1036. triviaRoom = room.id;
  1037. triviaA = '';
  1038. triviaPoints = [];
  1039. var turn = 1;
  1040. var textone = "";
  1041. var texttwo = "";
  1042. var i;
  1043.  
  1044. for(i = 0; i < joinusers.length; i+=1){
  1045.  
  1046. if (turn == 1){
  1047. teamOne[teamOne.length] = joinusers[i]
  1048. //joinusers.splice(i,1);
  1049. }
  1050.  
  1051. if (turn == -1){
  1052. teamTwo[teamTwo.length] = joinusers[i]
  1053. //joinusers.splice(i,1);
  1054. }
  1055.  
  1056. turn = turn * -1
  1057. }
  1058.  
  1059. for(i = 0; i < teamOne.length; i +=1){
  1060.  
  1061. if (i == teamOne.length - 1){
  1062. textone += teamOne[i] + "!"
  1063. }
  1064.  
  1065. if (i == teamOne.length - 2){
  1066. textone += teamOne[i] +" and "
  1067. }
  1068.  
  1069. if (i != teamOne.length - 1 && i != teamOne.length - 2){
  1070. textone += teamOne[i] + ","
  1071. }
  1072.  
  1073. }
  1074.  
  1075. for(i = 0; i < teamTwo.length; i +=1){
  1076.  
  1077. if (i == teamTwo.length - 1){
  1078. texttwo += teamTwo[i]+"!"
  1079. }
  1080.  
  1081. if (i == teamTwo.length - 2){
  1082. texttwo += teamTwo[i] +" and "
  1083. }
  1084.  
  1085. if (i != teamTwo.length - 1 && i != teamTwo.length - 2){
  1086. texttwo += teamTwo[i]+","
  1087. }
  1088.  
  1089. }
  1090.  
  1091. this.say( room, 'Hosting a game of **Team Trivia**. Answer the questions using -tta or -teamtriviaanswer. First to get 10 points wins.');
  1092.  
  1093. this.say( room, "Team Ash: "+textone);
  1094. this.say( room, "Team Conbeef: "+texttwo);
  1095.  
  1096. triviaTimer = setInterval( function() {
  1097. if(triviaA){this.say(room, '**BEEP** TIMES UP!! ' + triviaA);}
  1098. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  1099. triviaQ = triviaQuestions[TQN];
  1100. triviaA = triviaQuestions[TQN+ 1];
  1101. this.say( room, '**Question**: ' + triviaQ);
  1102. }.bind(this), 15000);
  1103.  
  1104. }
  1105.  
  1106.  
  1107. if (game == "oldrod"){
  1108.  
  1109. started= true;
  1110.  
  1111. text = "";
  1112. text += "**The game of Old Rod has started! (do .reel when the fish bite!(! appears when there's a bite))**";
  1113. this.say(room, text);
  1114. text = "";
  1115. text += "**Warning: If you do .reel before '!' appears you'll -30 points! GLHF! ^-^**";
  1116. this.say(room, text);
  1117. text = "";
  1118.  
  1119. var i;
  1120. for(i = 0; i < joinusers.length; i += 1){
  1121. playerdata[i] = 0;
  1122. safeusers[i] = 1;
  1123. }
  1124.  
  1125. var starttimer = setTimeout(function(){
  1126.  
  1127. for(i = 0; i < joinusers.length; i +=1){
  1128.  
  1129. if (i == joinusers.length-1){
  1130. text += joinusers[i]+"! Get ready to fish!";
  1131. }
  1132.  
  1133. if (i == joinusers.length - 2){
  1134. text += joinusers[i]+" and ";
  1135. }
  1136.  
  1137. if (i != joinusers.length -1 && i != playerdata.length - 2){
  1138. text += joinusers[i]+",";
  1139. }
  1140.  
  1141. }
  1142. text = "**"+text+"**";
  1143. this.say(room,"Round "+rounds+"!"+ text);
  1144. text = "";
  1145.  
  1146. checked = true;
  1147. dealerstotal = 0;
  1148. var times = 0;
  1149. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","not even a nibble.","!","!","!"];
  1150. var reeltimer = setTimeout(function(){
  1151.  
  1152. active = setInterval(function(){
  1153.  
  1154. times += 1;
  1155.  
  1156. if (times < 2){
  1157. this.say(room, "**...**");
  1158. active;
  1159. }
  1160.  
  1161. if (times >= 3){
  1162.  
  1163. var rand = (Math.round(Math.random()*(randpull.length-1)));
  1164. var pick = randpull[rand];
  1165.  
  1166. if (pick == "..."){
  1167. this.say(room, "**...**");
  1168. randpull.splice(0,4)
  1169. }
  1170.  
  1171. if (pick == "!"){
  1172. this.say(room, "**!**");
  1173. clearInterval(active);
  1174. checked = false;
  1175.  
  1176. active = setTimeout(function(){
  1177. game = "none";
  1178. started = false;
  1179. requiredPlayers = 0;
  1180. clearInterval(active);
  1181. text = "";
  1182. text += "The Rod has broken. **Game ended due to inactivity.**";
  1183. return this.say(room, text);
  1184. }.bind(this), 60000);
  1185.  
  1186. }
  1187.  
  1188. if (pick == "not even a nibble."){
  1189. this.say(room, "**not even a nibble.**");
  1190. clearInterval(active);
  1191. if (rounds < 10){
  1192. rounds += 1;
  1193.  
  1194.  
  1195.  
  1196. var starttimerr = setTimeout(function(){
  1197.  
  1198.  
  1199. for(i = 0; i < joinusers.length; i +=1){
  1200.  
  1201. if (i == joinusers.length-1){
  1202. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  1203. }
  1204.  
  1205. if (i == joinusers.length - 2){
  1206. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  1207. }
  1208.  
  1209. if (i != joinusers.length -1 && i != playerdata.length - 2){
  1210. text += joinusers[i]+"("+playerdata[i]+")"+",";
  1211. }
  1212.  
  1213. }
  1214. text = "**"+text+"**";
  1215. this.say(room,"Round "+rounds+"!"+ text);
  1216. text = "";
  1217.  
  1218. checked = true;
  1219. dealerstotal = 0;
  1220. var times = 0;
  1221. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","!","!","!","!","!"];
  1222. var reeltimer = setTimeout(function(){
  1223.  
  1224. active = setInterval(function(){
  1225.  
  1226. times += 1;
  1227.  
  1228. if (times < 2){
  1229. this.say(room, "**...**");
  1230. active;
  1231. }
  1232.  
  1233. if (times >= 3){
  1234.  
  1235. var rand = (Math.round(Math.random()*(randpull.length-1)));
  1236. var pick = randpull[rand];
  1237.  
  1238. if (pick == "..."){
  1239. this.say(room, "**...**");
  1240. randpull.splice(0,4)
  1241. }
  1242.  
  1243. if (pick == "!"){
  1244. this.say(room, "**!**");
  1245. clearInterval(active);
  1246. checked = false;
  1247.  
  1248. active = setTimeout(function(){
  1249. game = "none";
  1250. started = false;
  1251. requiredPlayers = 0;
  1252. clearInterval(active);
  1253. text = "";
  1254. text += "The Rod has broken. **Game ended due to inactivity.**";
  1255. return this.say(room, text);
  1256. }.bind(this), 60000);
  1257.  
  1258. }
  1259.  
  1260. }
  1261.  
  1262. }.bind(this), 1500);
  1263.  
  1264. }.bind(this), 4000);
  1265.  
  1266. }.bind(this), 2000);
  1267.  
  1268.  
  1269.  
  1270. }
  1271.  
  1272.  
  1273. }
  1274. }
  1275.  
  1276. }.bind(this), 1500);
  1277.  
  1278. }.bind(this), 4000);
  1279.  
  1280. }.bind(this), 2000);
  1281.  
  1282. }
  1283.  
  1284. if (game == "8s"){
  1285.  
  1286. started= true;
  1287. shuffle(joinusers);
  1288. var turn = 1;
  1289. var textone = "";
  1290. var texttwo = "";
  1291. var i;
  1292.  
  1293. for(i = 0; i < joinusers.length; i+=1){
  1294.  
  1295. if (turn == 1){
  1296. teamOne[teamOne.length] = joinusers[i]
  1297. //joinusers.splice(i,1);
  1298. }
  1299.  
  1300. if (turn == -1){
  1301. teamTwo[teamTwo.length] = joinusers[i]
  1302. //joinusers.splice(i,1);
  1303. }
  1304.  
  1305. turn = turn * -1
  1306. }
  1307.  
  1308. for(i = 0; i < teamOne.length; i +=1){
  1309.  
  1310. if (i == teamOne.length - 1){
  1311. textone += teamOne[i] + "!"
  1312. }
  1313.  
  1314. if (i == teamOne.length - 2){
  1315. textone += teamOne[i] +" and "
  1316. }
  1317.  
  1318. if (i != teamOne.length - 1 && i != teamOne.length - 2){
  1319. textone += teamOne[i] + ","
  1320. }
  1321.  
  1322. }
  1323.  
  1324. for(i = 0; i < teamTwo.length; i +=1){
  1325.  
  1326. if (i == teamTwo.length - 1){
  1327. texttwo += teamTwo[i]+"!"
  1328. }
  1329.  
  1330. if (i == teamTwo.length - 2){
  1331. texttwo += teamTwo[i] +" and "
  1332. }
  1333.  
  1334. if (i != teamTwo.length - 1 && i != teamTwo.length - 2){
  1335. texttwo += teamTwo[i]+","
  1336. }
  1337.  
  1338. }
  1339.  
  1340. var randd = ~~(teamOne.length * Math.random());
  1341. safeusers[safeusers.length] = teamOne[randd];
  1342.  
  1343. randd = ~~(teamTwo.length * Math.random());
  1344. safeusers[safeusers.length] = teamTwo[randd];
  1345.  
  1346. this.say( room, "**Team red:** "+textone+" **The Team captain is** "+safeusers[0]+"**.**");
  1347. this.say( room, "**Team blue:** "+texttwo+" **The Team captain is** "+safeusers[1]+"**.**");
  1348. this.say( room, "**Do .randcapt or choosecapt [user] to change the team captain.**");
  1349.  
  1350. }
  1351.  
  1352.  
  1353. }else{
  1354. text = "";
  1355. text += "**This game requires at least** "+requiredPlayers+" **player(s).**";
  1356. return this.say(room, text);
  1357. }
  1358. }else{
  1359. text = "";
  1360. text += "**No scripted game was created to start.**";
  1361. return this.say(room, text);
  1362. }
  1363. }
  1364. },
  1365.  
  1366. join: 'joingame',
  1367. 'joingame': function (arg, user, room) {
  1368. if (room === user) return false;
  1369. var text = "";
  1370. var checkjoin;
  1371. var i;
  1372. if (started == true) return false;
  1373. if (game == "none") return false;
  1374. if (joinusers.length < maxPlayers){
  1375. for(i = 0; i < joinusers.length; i++){
  1376. checkjoin = joinusersid[i]
  1377. if (checkjoin == user.id){
  1378. text += user.name+" has already joined!"
  1379. return this.say(room, text);
  1380. text = "";
  1381. }
  1382. }
  1383. joinusers[joinusers.length] = user.name;
  1384. joinusersid[joinusersid.length] = user.id;
  1385. text += user.name + " has joined!";
  1386. this.say(room, text);
  1387. text = ""
  1388. }else{
  1389. for(i = 0; i < joinusers.length; i++){
  1390. checkjoin = joinusersid[i]
  1391. if (checkjoin == user.id){
  1392. text += user.name+" has already joined!"
  1393. return this.say(room, text);
  1394. text = "";
  1395. }
  1396. }
  1397. text += "Sorry "+user.name+". The maximum amount of players has been reached."
  1398. return this.say(room, text);
  1399. }
  1400. },
  1401.  
  1402.  
  1403. leave: 'leavegame',
  1404. 'leavegame': function (arg, user, room) {
  1405. if (room === user) return false;
  1406. var text = "";
  1407. var checkjoin;
  1408. var i;
  1409. if (started == true) return false;
  1410. if (game == "none") return false;
  1411.  
  1412. for(i = 0; i < joinusers.length; i++){
  1413. checkjoin = joinusersid[i]
  1414. if (checkjoin == user.id){
  1415. joinusers.splice(i,1);
  1416. joinusersid.splice(i,1);
  1417. text += user.name+" has left the game."
  1418. return this.say(room, text);
  1419. text = "";
  1420. break;
  1421. }}
  1422. },
  1423.  
  1424. ///////////////////////////////////////////Scripted Game Setup//////////////////////////////////////////////////////////////
  1425.  
  1426. //////////////Black Jack///////////////////
  1427.  
  1428. 'hit': function (arg, user, room) {
  1429. if (room === user) return false;
  1430. var text = "";
  1431. if (user.name == joinusers[currentplayer] || user.id == joinusersid[currentplayer]){
  1432. if (game == "blackjack"){
  1433. if (started == true) {
  1434. /////////////////////////////////////////////////////////////////////////////////////////////////////////////HIT
  1435. var rand = (Math.round(Math.random()*(cards.length-1)));
  1436. var choosencard = cards[rand];
  1437. var actualcard = choosencard;
  1438. cards.splice(rand,1);
  1439.  
  1440. if (playerdata[currentplayer] >= 11){
  1441.  
  1442. switch(choosencard){
  1443. case "A":
  1444. choosencard = 1;
  1445. actualcard += "(1)";
  1446. break;
  1447.  
  1448. case "J":
  1449. choosencard = 10;
  1450. actualcard += "(10)";
  1451. break;
  1452.  
  1453. case "Q":
  1454. choosencard = 10;
  1455. actualcard += "(10)";
  1456. break;
  1457.  
  1458. case "K":
  1459. choosencard = 10;
  1460. actualcard += "(10)";
  1461. break;
  1462. }
  1463. }
  1464.  
  1465.  
  1466. if (playerdata[currentplayer] < 11){
  1467.  
  1468. switch(choosencard){
  1469. case "A":
  1470. numofaces += 1;
  1471. choosencard = 11;
  1472. actualcard += "(11)";
  1473. break;
  1474.  
  1475. case "J":
  1476. choosencard = 10;
  1477. actualcard += "(10)";
  1478. break;
  1479.  
  1480. case "Q":
  1481. choosencard = 10;
  1482. actualcard += "(10)";
  1483. break;
  1484.  
  1485. case "K":
  1486. choosencard = 10;
  1487. actualcard += "(10)";
  1488. break;
  1489. }
  1490. }
  1491.  
  1492.  
  1493. playerdata[currentplayer] += choosencard;
  1494.  
  1495. if (playerdata[currentplayer] > 21){
  1496. if (numofaces > 0){
  1497. playerdata[currentplayer] -= 10;
  1498. numofaces -= 1
  1499. }}
  1500. text += "You got a "+actualcard;
  1501. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1502. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1503. text = "";
  1504. /////////////////////////////////////////////////////////////////////////////////////////////////////////////HIT
  1505.  
  1506.  
  1507. if (playerdata[currentplayer] > 21){
  1508. if (numofaces <= 0){
  1509. text = "";
  1510. text += joinusers[currentplayer] + " has busted with " + playerdata[currentplayer] + "!";
  1511. this.say(room, text);
  1512. text = "";
  1513. currentplayer += 1;
  1514.  
  1515. if (currentplayer == joinusers.length){
  1516. text = ""
  1517. text += "**Everyone has finished. Its the dealers turn. Calculating......**"
  1518. this.say(room, text)
  1519. text = "";
  1520. }
  1521.  
  1522. if (currentplayer < joinusers.length){
  1523.  
  1524. var hittimer = setTimeout(function(){
  1525. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  1526. var rand = (Math.round(Math.random()*(cards.length-1)));
  1527. var choosencard = cards[rand];
  1528. var actualcard = choosencard;
  1529. cards.splice(rand,1);
  1530.  
  1531.  
  1532. switch(choosencard){
  1533. case "A":
  1534. numofaces += 1;
  1535. choosencard = 11;
  1536. actualcard += "(11)";
  1537. break;
  1538.  
  1539. case "J":
  1540. choosencard = 10;
  1541. actualcard += "(10)";
  1542. break;
  1543.  
  1544. case "Q":
  1545. choosencard = 10;
  1546. actualcard += "(10)";
  1547. break;
  1548.  
  1549. case "K":
  1550. choosencard = 10;
  1551. actualcard += "(10)";
  1552. break;
  1553. }
  1554.  
  1555. playerdata[currentplayer] = choosencard;
  1556. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  1557. this.say(room, text);
  1558. text = "";
  1559.  
  1560. text += joinusers[currentplayer] + " .hit or .stay";
  1561. this.say(room, text);
  1562. text = "";
  1563. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  1564. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1565. var rand = (Math.round(Math.random()*(cards.length-1)));
  1566. var choosencard = cards[rand];
  1567. var actualcard = choosencard;
  1568. cards.splice(rand,1);
  1569.  
  1570. if (playerdata[currentplayer] >= 11){
  1571.  
  1572. switch(choosencard){
  1573. case "A":
  1574. choosencard = 1;
  1575. actualcard += "(1)";
  1576. break;
  1577.  
  1578. case "J":
  1579. choosencard = 10;
  1580. actualcard += "(10)";
  1581. break;
  1582.  
  1583. case "Q":
  1584. choosencard = 10;
  1585. actualcard += "(10)";
  1586. break;
  1587.  
  1588. case "K":
  1589. choosencard = 10;
  1590. actualcard += "(10)";
  1591. break;
  1592. }
  1593. }
  1594.  
  1595.  
  1596. if (playerdata[currentplayer] < 11){
  1597.  
  1598. switch(choosencard){
  1599. case "A":
  1600. numofaces += 1;
  1601. choosencard = 11;
  1602. actualcard += "(11)";
  1603. break;
  1604.  
  1605. case "J":
  1606. choosencard = 10;
  1607. actualcard += "(10)";
  1608. break;
  1609.  
  1610. case "Q":
  1611. choosencard = 10;
  1612. actualcard += "(10)";
  1613. break;
  1614.  
  1615. case "K":
  1616. choosencard = 10;
  1617. actualcard += "(10)";
  1618. break;
  1619. }
  1620. }
  1621.  
  1622.  
  1623. playerdata[currentplayer] += choosencard;
  1624.  
  1625. if (playerdata[currentplayer] > 21){
  1626. if (numofaces > 0){
  1627. playerdata[currentplayer] -= 10;
  1628. numofaces -= 1
  1629. }}
  1630.  
  1631. text = "";
  1632. text += "You got a "+actualcard;
  1633. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1634. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1635. text = "";
  1636. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1637. }.bind(this), 3000);
  1638. }
  1639. else{// if currentplayer is greater than or equal to the length of users
  1640. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1641. if (currentplayer == joinusers.length){
  1642. var i;
  1643. for(i=0; i < 5; i += 1){
  1644.  
  1645. if (dealerstotal <= 14){
  1646.  
  1647. var rand = ~~(cards.length * Math.random());
  1648. var choosencard = cards[rand];
  1649. var actualcard = choosencard;
  1650. cards.splice(rand,1);
  1651.  
  1652. if (dealerstotal >= 11){
  1653.  
  1654. switch(choosencard){
  1655. case "A":
  1656. choosencard = 1;
  1657. actualcard += "(1)";
  1658. break;
  1659.  
  1660. case "J":
  1661. choosencard = 10;
  1662. actualcard += "(10)";
  1663. break;
  1664.  
  1665. case "Q":
  1666. choosencard = 10;
  1667. actualcard += "(10)";
  1668. break;
  1669.  
  1670. case "K":
  1671. choosencard = 10;
  1672. actualcard += "(10)";
  1673. break;
  1674. }
  1675. }
  1676.  
  1677.  
  1678. if (dealerstotal < 11){
  1679.  
  1680. switch(choosencard){
  1681. case "A":
  1682. numofaces += 1;
  1683. choosencard = 11;
  1684. actualcard += "(11)";
  1685. break;
  1686.  
  1687. case "J":
  1688. choosencard = 10;
  1689. actualcard += "(10)";
  1690. break;
  1691.  
  1692. case "Q":
  1693. choosencard = 10;
  1694. actualcard += "(10)";
  1695. break;
  1696.  
  1697. case "K":
  1698. choosencard = 10;
  1699. actualcard += "(10)";
  1700. break;
  1701. }
  1702. }
  1703.  
  1704.  
  1705. dealerstotal += choosencard;
  1706.  
  1707. if (dealerstotal > 21){
  1708. if (numofaces > 0){
  1709. dealerstotal -= 10;
  1710. numofaces -= 1
  1711. }}
  1712. }else{
  1713. break;
  1714. }
  1715. }
  1716.  
  1717.  
  1718. if (dealerstotal > 14 && dealerstotal <= 21){
  1719. var mytimer = setTimeout(function(){
  1720. text += "The dealer has got the total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  1721. this.say(room, text);
  1722. text = "";
  1723. }.bind(this), 3000);
  1724.  
  1725.  
  1726. var mytimer = setTimeout(function(){
  1727. var i;
  1728. var counter = 0;
  1729. var winners = [];
  1730. text += "Congratulations to our winner(s) "
  1731. for(i = 0; i < joinusers.length; i++){
  1732. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  1733. winners[winners.length] = joinusers[i];
  1734. counter += 1
  1735. }}
  1736.  
  1737. if (winners.length > 0){
  1738. var i;
  1739. for(i = 0;i < winners.length; i += 1){
  1740. if (i != winners.length-1){
  1741. text += winners[i]+","
  1742. }else{
  1743. text += winners[i]
  1744. }
  1745. }
  1746.  
  1747. this.say(room, text+"!");
  1748. game = "none";
  1749. started = false;
  1750. }
  1751. if (counter <=0){
  1752.  
  1753. this.say(room, "**Sorry there are no winners :C**");
  1754. game = "none";
  1755. started = false;
  1756. }
  1757.  
  1758. }.bind(this), 6000);
  1759. }
  1760.  
  1761.  
  1762. if (dealerstotal > 21){
  1763. var mytimer = setTimeout(function(){
  1764. text += "The dealer has busted with a total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  1765. this.say(room, text);
  1766. text = "";
  1767. dealerstotal = 0;
  1768. }.bind(this), 3000);
  1769.  
  1770.  
  1771. var mytimer = setTimeout(function(){
  1772. var i;
  1773. var counter = 0;
  1774. var winners = [];
  1775. text += "Congratulations to our winner(s) "
  1776. for(i = 0; i < joinusers.length; i++){
  1777. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  1778. winners[winners.length] = joinusers[i];
  1779. counter += 1
  1780. }}
  1781.  
  1782. if (winners.length > 0){
  1783. var i;
  1784. for(i = 0;i < winners.length; i += 1){
  1785. if (i != winners.length-1){
  1786. text += winners[i]+","
  1787. }else{
  1788. text += winners[i]
  1789. }
  1790. }
  1791.  
  1792. this.say(room, text+"!");
  1793. game = "none";
  1794. started = false;
  1795. }
  1796.  
  1797. if (counter <=0){
  1798.  
  1799. this.say(room, "**Sorry there are no winners :C**");
  1800. game = "none";
  1801. started = false;
  1802. }
  1803. }.bind(this), 6000);
  1804. }}
  1805. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1806. }
  1807.  
  1808. }}
  1809. }}}
  1810.  
  1811. },
  1812.  
  1813. 'stay': function (arg, user, room) {
  1814. if (room === user) return false;
  1815. var text = "";
  1816. var delay = 2000;
  1817. if (user.name == joinusers[currentplayer] || user.id == joinusersid[currentplayer]){
  1818. if (game == "blackjack"){
  1819. if (started == true) {
  1820.  
  1821. if (playerdata[currentplayer] == 21){
  1822. text += joinusers[currentplayer]+ " has got Blackjack."
  1823. this.say(room, text);
  1824. text = "";
  1825. }
  1826.  
  1827.  
  1828. currentplayer += 1;
  1829.  
  1830. if (currentplayer == joinusers.length){
  1831. text = ""
  1832. text += "**Everyone has finished. Its the dealers turn. Calculating......**"
  1833. this.say(room, text);
  1834. text = "";
  1835. }
  1836.  
  1837.  
  1838. if (currentplayer < joinusers.length){
  1839.  
  1840. var staytimer = setTimeout(function(){
  1841. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  1842. var rand = (Math.round(Math.random()*(cards.length-1)));
  1843. var choosencard = cards[rand];
  1844. var actualcard = choosencard;
  1845. cards.splice(rand,1);
  1846.  
  1847.  
  1848. switch(choosencard){
  1849. case "A":
  1850. numofaces += 1;
  1851. choosencard = 11;
  1852. actualcard += "(11)";
  1853. break;
  1854.  
  1855. case "J":
  1856. choosencard = 10;
  1857. actualcard += "(10)";
  1858. break;
  1859.  
  1860. case "Q":
  1861. choosencard = 10;
  1862. actualcard += "(10)";
  1863. break;
  1864.  
  1865. case "K":
  1866. choosencard = 10;
  1867. actualcard += "(10)";
  1868. break;
  1869. }
  1870.  
  1871. playerdata[currentplayer] = choosencard;
  1872. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  1873. this.say(room, text);
  1874. text = "";
  1875.  
  1876. text += joinusers[currentplayer] + " .hit or .stay";
  1877. this.say(room, text);
  1878. text = "";
  1879. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  1880. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1881. var rand = (Math.round(Math.random()*(cards.length-1)));
  1882. var choosencard = cards[rand];
  1883. var actualcard = choosencard;
  1884. cards.splice(rand,1);
  1885.  
  1886. if (playerdata[currentplayer] >= 11){
  1887.  
  1888. switch(choosencard){
  1889. case "A":
  1890. choosencard = 1;
  1891. actualcard += "(1)";
  1892. break;
  1893.  
  1894. case "J":
  1895. choosencard = 10;
  1896. actualcard += "(10)";
  1897. break;
  1898.  
  1899. case "Q":
  1900. choosencard = 10;
  1901. actualcard += "(10)";
  1902. break;
  1903.  
  1904. case "K":
  1905. choosencard = 10;
  1906. actualcard += "(10)";
  1907. break;
  1908. }
  1909. }
  1910.  
  1911.  
  1912. if (playerdata[currentplayer] < 11){
  1913.  
  1914. switch(choosencard){
  1915. case "A":
  1916. numofaces += 1;
  1917. choosencard = 11;
  1918. actualcard += "(11)";
  1919. break;
  1920.  
  1921. case "J":
  1922. choosencard = 10;
  1923. actualcard += "(10)";
  1924. break;
  1925.  
  1926. case "Q":
  1927. choosencard = 10;
  1928. actualcard += "(10)";
  1929. break;
  1930.  
  1931. case "K":
  1932. choosencard = 10;
  1933. actualcard += "(10)";
  1934. break;
  1935. }
  1936. }
  1937.  
  1938.  
  1939. playerdata[currentplayer] += choosencard;
  1940.  
  1941. if (playerdata[currentplayer] > 21){
  1942. if (numofaces > 0){
  1943. playerdata[currentplayer] -= 10;
  1944. numofaces -= 1
  1945. }}
  1946.  
  1947. text = "";
  1948. text += "You got a "+actualcard;
  1949. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1950. return this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1951. text = "";
  1952. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1953. }.bind(this), 3000);
  1954. }
  1955. else{ // if currentplayer is greater than or equal to the length of users
  1956.  
  1957. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1958. if (currentplayer == joinusers.length){
  1959. var i;
  1960. for(i=0; i < 5; i += 1){
  1961.  
  1962. if (dealerstotal <= 14){
  1963.  
  1964. var rand = ~~(cards.length * Math.random());
  1965. var choosencard = cards[rand];
  1966. var actualcard = choosencard;
  1967. cards.splice(rand,1);
  1968.  
  1969. if (dealerstotal >= 11){
  1970.  
  1971. switch(choosencard){
  1972. case "A":
  1973. choosencard = 1;
  1974. actualcard += "(1)";
  1975. break;
  1976.  
  1977. case "J":
  1978. choosencard = 10;
  1979. actualcard += "(10)";
  1980. break;
  1981.  
  1982. case "Q":
  1983. choosencard = 10;
  1984. actualcard += "(10)";
  1985. break;
  1986.  
  1987. case "K":
  1988. choosencard = 10;
  1989. actualcard += "(10)";
  1990. break;
  1991. }
  1992. }
  1993.  
  1994.  
  1995. if (dealerstotal < 11){
  1996.  
  1997. switch(choosencard){
  1998. case "A":
  1999. numofaces += 1;
  2000. choosencard = 11;
  2001. actualcard += "(11)";
  2002. break;
  2003.  
  2004. case "J":
  2005. choosencard = 10;
  2006. actualcard += "(10)";
  2007. break;
  2008.  
  2009. case "Q":
  2010. choosencard = 10;
  2011. actualcard += "(10)";
  2012. break;
  2013.  
  2014. case "K":
  2015. choosencard = 10;
  2016. actualcard += "(10)";
  2017. break;
  2018. }
  2019. }
  2020.  
  2021.  
  2022. dealerstotal += choosencard;
  2023.  
  2024. if (dealerstotal > 21){
  2025. if (numofaces > 0){
  2026. dealerstotal -= 10;
  2027. numofaces -= 1
  2028. }}
  2029. }else{
  2030. break;
  2031. }
  2032. }
  2033.  
  2034.  
  2035. if (dealerstotal > 14 && dealerstotal <= 21){
  2036. var mytimer = setTimeout(function(){
  2037. text += "The dealer has got the total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  2038. this.say(room, text);
  2039. text = "";
  2040. }.bind(this), 3000);
  2041.  
  2042.  
  2043. var mytimer = setTimeout(function(){
  2044. var i;
  2045. var counter = 0;
  2046. var winners = [];
  2047. text += "Congratulations to our winner(s) "
  2048. for(i = 0; i < joinusers.length; i++){
  2049. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  2050. winners[winners.length] = joinusers[i];
  2051. counter += 1
  2052. }}
  2053.  
  2054. if (winners.length > 0){
  2055. var i;
  2056. for(i = 0;i < winners.length; i += 1){
  2057. if (i != winners.length-1){
  2058. text += winners[i]+","
  2059. }else{
  2060. text += winners[i]
  2061. }
  2062. }
  2063.  
  2064. this.say(room, text+"!");
  2065. game = "none";
  2066. started = false;
  2067. }
  2068. if (counter <=0){
  2069.  
  2070. this.say(room, "**Sorry there are no winners :C**");
  2071. game = "none";
  2072. started = false;
  2073. }
  2074.  
  2075. }.bind(this), 6000);
  2076. }
  2077.  
  2078.  
  2079. if (dealerstotal > 21){
  2080. var mytimer = setTimeout(function(){
  2081. text += "The dealer has busted with a total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  2082. this.say(room, text);
  2083. text = "";
  2084. dealerstotal = 0;
  2085. }.bind(this), 3000);
  2086.  
  2087.  
  2088. var mytimer = setTimeout(function(){
  2089. var i;
  2090. var counter = 0;
  2091. var winners = [];
  2092. text += "Congratulations to our winner(s) "
  2093. for(i = 0; i < joinusers.length; i++){
  2094. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  2095. winners[winners.length] = joinusers[i];
  2096. counter += 1
  2097. }}
  2098.  
  2099. if (winners.length > 0){
  2100. var i;
  2101. for(i = 0;i < winners.length; i += 1){
  2102. if (i != winners.length-1){
  2103. text += winners[i]+","
  2104. }else{
  2105. text += winners[i]
  2106. }
  2107. }
  2108.  
  2109. this.say(room, text+"!");
  2110. game = "none";
  2111. started = false;
  2112. }
  2113.  
  2114. if (counter <=0){
  2115.  
  2116. this.say(room, "**Sorry there are no winners :C**");
  2117. game = "none";
  2118. started = false;
  2119. }
  2120. }.bind(this), 6000);
  2121. }}
  2122. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2123.  
  2124. }
  2125.  
  2126. }}}
  2127.  
  2128. },
  2129. //////////////Black Jack///////////////////
  2130. //////////////Ambush///////////////////////
  2131. kill: 'fire',
  2132. 'fire': function (arg, user, room) {
  2133. if (room === user) return false;
  2134. if (game != "ambush") return false;
  2135. if (started == false) return false;
  2136. var text = "";
  2137. var userin = false;
  2138. var i;
  2139. var bullets;
  2140. var playerid;
  2141. for(i = 0; i< joinusers.length; i+=1){
  2142. if (user.name == joinusers[i] || user.id == joinusersid[i]){
  2143. userin = true;
  2144. bullets = playerdata[i];
  2145. playerid = i;
  2146. break;
  2147. }
  2148. }
  2149. if (userin == true){
  2150. if (checked == true){
  2151.  
  2152. if (bullets > 0){
  2153. playerdata[playerid] -= 1;
  2154. }}else{
  2155. var usershotin;
  2156. var usertokill;
  2157. for(i = 0; i< joinusers.length; i+=1){
  2158. if (arg.toLowerCase() == joinusers[i].toLowerCase() || arg.toLowerCase() == joinusersid[i].toLowerCase()){
  2159. usershotin = true;
  2160. usertokill = i;
  2161. break;
  2162. }
  2163. }
  2164. if (usershotin == true){
  2165. if (bullets > 0){
  2166. var safe = false;
  2167. for(i = 0; i < safeusers.length;i += 2){
  2168. if (arg.toLowerCase() == safeusers[i].toLowerCase() || arg.toLowerCase() == safeusers[i+1].toLowerCase()){
  2169. safe = true;
  2170. }}
  2171. clearInterval(active);
  2172. turnspassed = 0;
  2173. if (safe == false){
  2174. joinusers.splice(usertokill,1);
  2175. joinusersid.splice(usertokill,1);
  2176. safeusers[safeusers.length] = user.name;
  2177. safeusers[safeusers.length] = user.id;
  2178. text += "/pm " + arg+",Sorry you lost. Better luck next time. ( ͡° ͜ʖ ͡°)";
  2179. this.say(room, text);
  2180. text = "";
  2181. }
  2182. }else{return false;}
  2183.  
  2184. if (joinusers.length <= 1){
  2185. clearInterval(active);
  2186. text += "Congratulations to our winner "+joinusers[0]+"!";
  2187. this.say(room, text);
  2188. text = "";
  2189. game = "none";
  2190. started = false;
  2191. requiredPlayers = 0;
  2192. }
  2193. else{
  2194. var i;
  2195. for(i=0;i < joinusers.length; i+=1){
  2196. playerdata[i] = 2;
  2197. }
  2198.  
  2199. clearTimeout(starttimer);
  2200. starttimer = setTimeout(function(){
  2201. for(i = 0; i < joinusers.length; i +=1){
  2202. if (i == joinusers.length-1){
  2203. text += joinusers[i]+"! Get ready!";
  2204. }
  2205. if (i == joinusers.length - 2){
  2206. text += joinusers[i]+" and ";
  2207. }
  2208. if (i != joinusers.length -1 && i != joinusers.length - 2){
  2209. text += joinusers[i]+",";
  2210. }
  2211. }
  2212. text = "**"+text+"**";
  2213. this.say(room, text);
  2214. text = "";
  2215.  
  2216. checked = true;
  2217. safeusers = [];
  2218. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  2219. clearTimeout(firetimer);
  2220. firetimer = setTimeout(function(){
  2221. text = "**FIRE!**";
  2222. this.say(room, text);
  2223. checked = false;
  2224. text = "";;
  2225. }.bind(this), delaytime);
  2226.  
  2227.  
  2228. active = setInterval(function(){
  2229. turnspassed +=1
  2230. if (turnspassed < 3){
  2231. text = "";
  2232. var starttimer = setTimeout(function(){
  2233. for(i = 0; i < joinusers.length; i +=1){
  2234. if (i == joinusers.length-1){
  2235. text += joinusers[i]+"! Get ready!";
  2236. }
  2237. if (i == joinusers.length - 2){
  2238. text += joinusers[i]+" and ";
  2239. }
  2240. if (i != joinusers.length -1 && i != joinusers.length - 2){
  2241. text += joinusers[i]+",";
  2242. }
  2243. }
  2244. text = "**"+text+"**";
  2245. this.say(room, text);
  2246. text = "";
  2247.  
  2248.  
  2249.  
  2250. checked = true;
  2251. safeusers = [];
  2252. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  2253. var firetimer = setTimeout(function(){
  2254. text = "**FIRE!**";
  2255. this.say(room, text);
  2256. checked = false;
  2257. text = "";
  2258. //clearInterval(active);
  2259. active;
  2260.  
  2261. }.bind(this), delaytime);
  2262.  
  2263. }.bind(this), 4000);
  2264. }else{
  2265.  
  2266. text = "A Greninja came out of no where and use water shuriken on everyone. RIP!!! **The game has ended due to inactivity**";
  2267. this.say(room, text);
  2268. text = "";
  2269. clearInterval(active);
  2270. game = "none";
  2271. started = false;
  2272. requiredPlayers = 0;
  2273. turnspassed = 0;
  2274.  
  2275. }
  2276. }.bind(this), 20000);
  2277.  
  2278. }.bind(this), 4000);
  2279. }
  2280. }else{
  2281. return false;
  2282. }
  2283. }
  2284. }
  2285. },
  2286. //////////////Ambush///////////////////////
  2287. //////////////Team Trivia/////////////////
  2288. tta: 'teamtriviaanswer',
  2289. teamtriviaanswer: function(arg, user, room){
  2290. if(room.id !== triviaRoom) return false;
  2291. if (game !== "ttrivia") return false;
  2292. if (started != true) return false;
  2293. if (!arg) return false;
  2294. arg = (arg);
  2295. var i;
  2296. var gotteam = false;
  2297. var theuser;
  2298.  
  2299. for(i = 0 ;i < teamOne.length;i+=1){
  2300. if (gotteam == true){break;}
  2301. if(user.name == teamOne[i]){
  2302. theuser = "Team Ash";
  2303. gotteam = true;
  2304. break;
  2305. }
  2306. }
  2307.  
  2308. for(i = 0 ;i < teamTwo.length;i+=1){
  2309. if (gotteam == true){break;}
  2310. if(user.name == teamTwo[i]){
  2311. theuser = "Team Conbeef";
  2312. gotteam = true;
  2313. break;
  2314. }
  2315. }
  2316.  
  2317.  
  2318. if(arg == triviaA){
  2319. if (triviaPoints.indexOf(theuser) > -1){
  2320. triviaA = '';
  2321. triviaPoints[triviaPoints.indexOf(theuser) + 1] += 1;
  2322. if (triviaPoints[triviaPoints.indexOf(theuser) + 1] >= 10) {
  2323. clearInterval(triviaTimer);
  2324. this.say( room, '**Congrats to ' + theuser + ' for winning Trivia!**');
  2325. this.say(room,'/pm '+ user.name + ' ,**Congratulations** on winning the game of Team Trivia.')
  2326. //this.say(room,'/msg lustrousash,' + user.name + ' have been awarded **2 Points** for winning trivia')
  2327. triviaON = false;
  2328. game = "none";
  2329. started = false;
  2330. requiredPlayers = 0;
  2331. return false;
  2332. }
  2333. this.say(room,'**' + user.name + '** got the right answer,' +"**"+theuser+"**"+ ' has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoints!');
  2334. } else {
  2335. triviaA = '';
  2336. triviaPoints[triviaPoints.length] = theuser;
  2337. triviaPoints[triviaPoints.length] = 1;
  2338. this.say(room,'**' + user.name + '** got the right answer,' +"**"+theuser+"**"+ ' has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoint!');
  2339. }
  2340. }
  2341. },
  2342. ////////////////Team Trivia///////////////
  2343. ////////////////Old Rod//////////////////
  2344. pull: 'reel',
  2345. 'reel': function (arg, user, room) {
  2346. if (room === user) return false;
  2347. if (game != "oldrod") return false;
  2348. if (started == false) return false;
  2349. if (dealerstotal == 1) return false;
  2350. var text = "";
  2351. var userin = false;
  2352. var i;
  2353. var playerid;
  2354. for(i = 0; i< joinusers.length; i+=1){
  2355. if (user.name == joinusers[i] || user.id == joinusersid[i]){
  2356. userin = true;
  2357. playerid = i;
  2358. break;
  2359. }
  2360. }
  2361.  
  2362. if (userin == false){return false;}else{
  2363. if (checked == true){
  2364. safeusers[i] = 0;
  2365. return playerdata[playerid] -= 30;
  2366. /*if (playerdata[playerid] != 0){
  2367. if (playerdata[playerid] >= 30){
  2368. safeusers[i] = 0;
  2369. return playerdata[playerid] -= 30;
  2370. }else{
  2371. safeusers[playerid] = 0;
  2372. playerdata[playerid] = 0;
  2373. }
  2374. }*/
  2375. }else{
  2376.  
  2377.  
  2378. if (safeusers[playerid] == 1){
  2379. dealerstotal = 1;
  2380. checked = true;
  2381. var randd = Math.round((Math.random()*(waterpoke.length-1-0)+0)/2)*2;
  2382. var chosenpoke = waterpoke[randd]
  2383. var addpoints = waterpoke[randd+1]
  2384.  
  2385. playerdata[playerid] += addpoints;
  2386. text = joinusers[playerid] + " caught a "+chosenpoke+"(" +addpoints+").";
  2387. this.say(room, text);
  2388. text = "";
  2389.  
  2390. }
  2391.  
  2392. rounds += 1;
  2393. clearTimeout(active);
  2394. for(i = 0; i < joinusers.length; i +=1){
  2395. safeusers[i] = 1;
  2396. }
  2397.  
  2398. if (rounds != 10){
  2399.  
  2400.  
  2401. var starttimer = setTimeout(function(){
  2402.  
  2403. for(i = 0; i < joinusers.length; i +=1){
  2404.  
  2405. if (i == joinusers.length-1){
  2406. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  2407. }
  2408.  
  2409. if (i == joinusers.length - 2){
  2410. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  2411. }
  2412.  
  2413. if (i != joinusers.length -1 && i != playerdata.length - 2){
  2414. text += joinusers[i]+"("+playerdata[i]+")"+",";
  2415. }
  2416.  
  2417. }
  2418. text = "**"+text+"**";
  2419. this.say(room,"Round "+rounds+"!"+ text);
  2420. text = "";
  2421.  
  2422. checked = true;
  2423. dealerstotal = 0;
  2424. var times = 0;
  2425. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","not even a nibble.","!","!","!"];
  2426. var reeltimer = setTimeout(function(){
  2427.  
  2428. active = setInterval(function(){
  2429.  
  2430. times += 1;
  2431.  
  2432. if (times < 2){
  2433. this.say(room, "**...**");
  2434. active;
  2435. }
  2436.  
  2437. if (times >= 3){
  2438.  
  2439. var rand = (Math.round(Math.random()*(randpull.length-1)));
  2440. var pick = randpull[rand];
  2441.  
  2442. if (pick == "..."){
  2443. this.say(room, "**...**");
  2444. randpull.splice(0,4)
  2445. }
  2446.  
  2447. if (pick == "!"){
  2448. this.say(room, "**!**");
  2449. clearInterval(active);
  2450. checked = false;
  2451.  
  2452. active = setTimeout(function(){
  2453. game = "none";
  2454. started = false;
  2455. requiredPlayers = 0;
  2456. clearInterval(active);
  2457. text = "";
  2458. text += "The Rod has broken. **Game ended due to inactivity.**";
  2459. return this.say(room, text);
  2460. }.bind(this), 60000);
  2461.  
  2462. }
  2463.  
  2464. if (pick == "not even a nibble."){
  2465. this.say(room, "**not even a nibble.**");
  2466.  
  2467. rounds += 1;
  2468. clearTimeout(active);
  2469. for(i = 0; i < joinusers.length; i +=1){
  2470. safeusers[i] = 1;
  2471. }
  2472.  
  2473. if (rounds < 10){
  2474.  
  2475.  
  2476. var starttimerr = setTimeout(function(){
  2477.  
  2478.  
  2479. for(i = 0; i < joinusers.length; i +=1){
  2480.  
  2481. if (i == joinusers.length-1){
  2482. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  2483. }
  2484.  
  2485. if (i == joinusers.length - 2){
  2486. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  2487. }
  2488.  
  2489. if (i != joinusers.length -1 && i != playerdata.length - 2){
  2490. text += joinusers[i]+"("+playerdata[i]+")"+",";
  2491. }
  2492.  
  2493. }
  2494. text = "**"+text+"**";
  2495. this.say(room,"Round "+rounds+"!"+ text);
  2496. text = "";
  2497.  
  2498. checked = true;
  2499. dealerstotal = 0;
  2500. var times = 0;
  2501. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","!","!","!","!","!"];
  2502. var reeltimer = setTimeout(function(){
  2503.  
  2504. active = setInterval(function(){
  2505.  
  2506. times += 1;
  2507.  
  2508. if (times < 2){
  2509. this.say(room, "**...**");
  2510. active;
  2511. }
  2512.  
  2513. if (times >= 3){
  2514.  
  2515. var rand = (Math.round(Math.random()*(randpull.length-1)));
  2516. var pick = randpull[rand];
  2517.  
  2518. if (pick == "..."){
  2519. this.say(room, "**...**");
  2520. randpull.splice(0,4)
  2521. }
  2522.  
  2523. if (pick == "!"){
  2524. this.say(room, "**!**");
  2525. clearInterval(active);
  2526. checked = false;
  2527.  
  2528. active = setTimeout(function(){
  2529. game = "none";
  2530. started = false;
  2531. requiredPlayers = 0;
  2532. clearInterval(active);
  2533. text = "";
  2534. text += "The Rod has broken. **Game ended due to inactivity.**";
  2535. return this.say(room, text);
  2536. }.bind(this), 60000);
  2537.  
  2538. }
  2539.  
  2540. }
  2541.  
  2542. }.bind(this), 1500);
  2543.  
  2544. }.bind(this), 4000);
  2545.  
  2546. }.bind(this), 2000);
  2547.  
  2548.  
  2549.  
  2550. }else{
  2551. var maxtotal = 0;
  2552. var winners = [];
  2553.  
  2554. for(i = 0;i < joinusers.length; i+= 1){
  2555.  
  2556. if (maxtotal < playerdata[i]){
  2557. maxtotal = playerdata[i];
  2558. winners = [];
  2559. }
  2560.  
  2561. if (maxtotal == playerdata[i]){
  2562. winners[winners.length] = joinusers[i]
  2563. }
  2564.  
  2565. }
  2566.  
  2567. if (winners.length > 0){
  2568. var i;
  2569. for(i = 0;i < winners.length; i += 1){
  2570. if (i != winners.length-1){
  2571. text += winners[i]+","
  2572. }else{
  2573. text += winners[i]
  2574. }
  2575. }
  2576.  
  2577. this.say(room,"Congrats to our winner(s) "+ text+"!");
  2578. game = "none";
  2579. started = false;
  2580. }else{
  2581.  
  2582. this.say(room,"Sorry there are no winners. :c");
  2583. game = "none";
  2584. started = false;
  2585.  
  2586. }
  2587. }
  2588. }
  2589. }
  2590.  
  2591.  
  2592.  
  2593. }.bind(this), 1500);
  2594.  
  2595. }.bind(this), 4000);
  2596.  
  2597. }.bind(this), 2000);
  2598.  
  2599.  
  2600. }else{
  2601.  
  2602. var maxtotal = 0;
  2603. var winners = [];
  2604.  
  2605. for(i = 0;i < joinusers.length; i+= 1){
  2606.  
  2607. if (maxtotal < playerdata[i]){
  2608. maxtotal = playerdata[i];
  2609. winners = [];
  2610. }
  2611.  
  2612. if (maxtotal == playerdata[i]){
  2613. winners[winners.length] = joinusers[i]
  2614. }
  2615.  
  2616. }
  2617.  
  2618. if (winners.length > 0){
  2619. var i;
  2620. for(i = 0;i < winners.length; i += 1){
  2621. if (i != winners.length-1){
  2622. text += winners[i]+","
  2623. }else{
  2624. text += winners[i]
  2625. }
  2626. }
  2627.  
  2628. this.say(room,"Congrats to our winner(s) "+ text+"!");
  2629. game = "none";
  2630. started = false;
  2631. }else{
  2632.  
  2633. this.say(room,"Sorry there are no winners. :c");
  2634. game = "none";
  2635. started = false;
  2636.  
  2637. }}
  2638.  
  2639. }}
  2640. },
  2641. ////////////////////////////////////////////////////////////////////////////////////////8s//////////////////////////////////////////////////
  2642. choosecaptain: 'choosecapt',
  2643. 'choosecapt': function (arg, user, room) {
  2644. if (room === user) return false;
  2645. if (game != "8s") return false;
  2646. if (started == false) return false;
  2647. var text = "";
  2648. var i;
  2649. if (user.id == toId(safeusers[0])){
  2650.  
  2651. for(i = 0; i < teamOne.length; i += 1){
  2652. if (arg == teamOne[i] || toId(arg) == toId(teamOne[i])){
  2653. safeusers[0] = teamOne[i];
  2654. text = "Team red team captain is now "+safeusers[0]+".";
  2655. return this.say(room, text);
  2656. text = "";
  2657. }
  2658. }
  2659.  
  2660. }
  2661.  
  2662. if (user.id == toId(safeusers[1])){
  2663.  
  2664. for(i = 0; i < teamTwo.length; i += 1){
  2665. if (arg == teamTwo[i] || toId(arg) == toId(teamTwo[i])){
  2666. safeusers[1] = teamTwo[i];
  2667. text = "Team blue team captain is now "+safeusers[1]+".";
  2668. return this.say(room, text);
  2669. text = "";
  2670. }
  2671. }
  2672.  
  2673. }
  2674.  
  2675. },
  2676.  
  2677. randomcaptain: 'randcapt',
  2678. 'randcapt': function (arg, user, room) {
  2679. if (room === user) return false;
  2680. if (game != "8s") return false;
  2681. if (started == false) return false;
  2682. var text = "";
  2683. var i;
  2684. var randomlist = [];
  2685.  
  2686. if (user.id == toId(safeusers[0])){
  2687. if (teamOne.length > 1){
  2688.  
  2689. for(i = 0; i < teamOne.length; i += 1){
  2690. if (user.id != toId(teamOne[i])){
  2691. randomlist[randomlist.length] = teamOne[i];
  2692. }
  2693. }
  2694. var rand = (Math.round(Math.random()*(randomlist.length-1)));
  2695. safeusers[0] = randomlist[rand];
  2696. text = "Team red team captain is now "+safeusers[0]+".";
  2697. return this.say(room, text);
  2698. text = "";
  2699. }
  2700. }
  2701.  
  2702. if (user.id == toId(safeusers[1])){
  2703. if (teamOne.length > 1){
  2704.  
  2705.  
  2706. for(i = 0; i < teamTwo.length; i += 1){
  2707. if (user.id != toId(teamTwo[i])){
  2708. randomlist[randomlist.length] = teamTwo[i];
  2709. }
  2710. }
  2711. var rand = (Math.round(Math.random()*(randomlist.length-1)));
  2712. safeusers[1] = randomlist[rand];
  2713. text = "Team blue team captain is now "+safeusers[1]+".";
  2714. return this.say(room, text);
  2715. text = "";
  2716. }
  2717. }
  2718.  
  2719. },
  2720.  
  2721. playerout: 'drop',
  2722. 'drop': function (arg, user, room) {
  2723. if (room === user) return false;
  2724. if (game != "8s") return false;
  2725. if (started == false) return false;
  2726. var text = "";
  2727. var i;
  2728.  
  2729. if (user.id == toId(safeusers[0])){
  2730.  
  2731. for(i = 0; i < teamOne.length; i += 1){
  2732. if (arg == teamOne[i] || toId(arg) == toId(teamOne[i])){
  2733.  
  2734. if (arg != safeusers[0] && toId(arg) != toId(safeusers[0])){
  2735. text = "Team red has eliminated "+teamOne[i]+".";
  2736. teamOne.splice(i,1);
  2737. return this.say(room, text);
  2738. text = "";
  2739. }else{
  2740.  
  2741. text = "Team red has eliminated "+teamOne[i]+".";
  2742. teamOne.splice(i,1);
  2743. this.say(room, text);
  2744. text = "";
  2745.  
  2746. if (teamOne.length > 0){
  2747. var rand = (Math.round(Math.random()*(teamOne.length-1)));
  2748. safeusers[0] = teamOne[rand];
  2749. text = "Team red team captain is now "+safeusers[0]+".";
  2750. return this.say(room, text);
  2751. text = "";
  2752. }else{
  2753. var winners = [];
  2754. var j;
  2755.  
  2756. for(j=0; j < teamTwo.length; j +=1){
  2757. if (j != teamTwo.length-1){
  2758. text += teamTwo[j]+","
  2759. }else{
  2760. text += teamTwo[j];
  2761. }
  2762. }
  2763.  
  2764. text = "Team blue team wins.Congrats to "+text+" for surviving.";
  2765. return this.say(room, text);
  2766. text = "";
  2767. }
  2768. }
  2769. }
  2770. }
  2771. }
  2772.  
  2773.  
  2774.  
  2775. if (user.id == toId(safeusers[1])){
  2776.  
  2777. for(i = 0; i < teamTwo.length; i += 1){
  2778. if (arg == teamTwo[i] || toId(arg) == toId(teamTwo[i])){
  2779.  
  2780. if (arg != safeusers[1] && toId(arg) != toId(safeusers[1])){
  2781. text = "Team blue has eliminated "+teamTwo[i]+".";
  2782. teamTwo.splice(i,1);
  2783. return this.say(room, text);
  2784. text = "";
  2785. }else{
  2786.  
  2787. text = "Team blue has eliminated "+teamTwo[i]+".";
  2788. teamTwo.splice(i,1);
  2789. this.say(room, text);
  2790. text = "";
  2791.  
  2792. if (teamTwo.length > 0){
  2793. var rand = (Math.round(Math.random()*(teamTwo.length-1)));
  2794. safeusers[1] = teamTwo[rand];
  2795. text = "Team blue team captain is now "+safeusers[1]+".";
  2796. return this.say(room, text);
  2797. text = "";
  2798. }else{
  2799. var winners = [];
  2800. var j;
  2801.  
  2802. for(j=0; j < teamOne.length; j +=1){
  2803. if (j != teamOne.length-1){
  2804. text += teamOne[j]+","
  2805. }else{
  2806. text += teamOne[j];
  2807. }
  2808. }
  2809.  
  2810. text = "Team red team wins.Congrats to "+text+" for surviving.";
  2811. return this.say(room, text);
  2812. text = "";
  2813. }
  2814. }
  2815. }
  2816. }
  2817. }
  2818.  
  2819.  
  2820. },
  2821.  
  2822. 'randa': function (arg, user, room) {
  2823. if (room === user) return false;
  2824. var text = "";
  2825. var rand = Math.round(Math.random() * (294 - 1) + 1);
  2826. var randstr = rand.toString();
  2827. var strLength = randstr.length
  2828.  
  2829. switch(strLength){
  2830.  
  2831. case 1:
  2832. randstr = "00"+randstr+".png"
  2833. break;
  2834.  
  2835. case 2:
  2836. randstr = "0"+randstr+".png"
  2837. break;
  2838.  
  2839. case 3:
  2840. randstr = randstr+".png"
  2841. break;
  2842. }
  2843.  
  2844. var theimage = "http://play.pokemonshowdown.com/sprites/trainers-ordered/"+randstr;
  2845. this.say(room,'/declare <img src="'+theimage+'"; height="80" width="80"><center>'+trainers[rand-1]+'</center>');
  2846. },
  2847.  
  2848.  
  2849. 'randmega': function (arg, user, room) {
  2850. if (room === user) return false;
  2851. var text = "";
  2852. var rand = (Math.round(Math.random()*(megapoke.length-1)));
  2853. var randstr = megapoke[rand];
  2854. var strLength = randstr.length
  2855. randstr = randstr + ".png"
  2856.  
  2857. if (arg){
  2858. randstr = arg.toLowerCase() + ".png"
  2859. }
  2860.  
  2861. var theimage = "http://play.pokemonshowdown.com/sprites/bw/"+randstr;
  2862. this.say(room,'/declare <img src="'+theimage+'"; height="96" width="96">');//<center>'+trainers[rand-1]+'</center>');
  2863. },
  2864.  
  2865. };
Add Comment
Please, Sign In to add comment