Guest User

Untitled

a guest
Jul 3rd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 83.14 KB | None | 0 0
  1. /**
  2. * This is the file where the bot commands are located
  3. *
  4. * @license MIT license
  5. */
  6.  
  7. var http = require('http');
  8.  
  9. if (Config.serverid === 'showdown') {
  10. var https = require('https');
  11. var csv = require('csv-parse');
  12. }
  13.  
  14.  
  15. //Functions
  16.  
  17. function shuffle(o){
  18. for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  19. return o;
  20. }
  21.  
  22.  
  23. //rps vars
  24. var rpsgame = ['rock','paper','scissors'];
  25. // .set constants
  26. var requiredAlt = '+'
  27. var requiredPlayers = 0;
  28. var maxPlayers = 9999;
  29. var started = false;
  30. var game = "none";
  31. var checked = false;
  32. var joinusers = [];
  33. var joinusersid = [];
  34. var playerdata = [];
  35. var safeusers = [];//exclusive to ambush(also using for oldrod )
  36. var currentplayer = 0;
  37. var active;//special to ambush atm(also using for oldrod)
  38. var firetimer;
  39. var starttimer;
  40. var turnspassed = 0;
  41.  
  42. //A Game of Trivia
  43. 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'];
  44. var triviaRoom; // This var will check if trivia is going in other room or not..
  45. var triviaON = false; // A switch case to tell if trivia is going on not
  46. var triviaTimer; // Keeps the track of the timer of the trivia
  47. var triviaA; // The answer of the trivia
  48. var triviaQ; // Question of trivia
  49. var triviaPoints = []; // This empty object will keep the track off all the trivia points during a game of trivia
  50. var teamOne = [];
  51. var teamTwo = [];
  52. var teamOnePoints = 0;
  53. var teamTwoPoints = 0;
  54. clearInterval(triviaTimer);
  55.  
  56. //blackjack variables
  57.  
  58. var cards = ["A","A","A","A",2,2,2,2,3,3,3,3,4,4,4,4,
  59. 5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,
  60. 10,10,10,10,"J","J","J","J","Q","Q","Q","Q","K","K","K","K"];
  61.  
  62. var numofaces = 0;
  63. var dealerstotal = 0; //(using this for old rod)
  64.  
  65. //blackjack variables end
  66.  
  67. //oldrod variables
  68.  
  69. var rounds = 1;
  70. var waterpoke = ["Tentacool",50,"Magikarp",50,"Wailmer",50,"Wailord",150,"Relicanth",100];
  71. var wait = ["...","...","...","...","!"]; // I know this is useless xD and the name is horrible lol
  72.  
  73.  
  74.  
  75.  
  76. const CONFIGURABLE_COMMANDS = {
  77. autoban: true,
  78. banword: true,
  79. say: true,
  80. 'checkroom': true,
  81. 'setalt':true,
  82. 'reload': true,
  83. 'rps': true,
  84. 'joingame': true,
  85. 'startgame': true,
  86. 'endgame': true,
  87. 'stay': true,
  88. 'hit': true,
  89. 'fire': true,
  90. 'signup': true,
  91. 'reel': true,
  92. 'randpoke': true,
  93. 'custsay': true,
  94. '8ball': true,
  95. 'lennyraid': true
  96. };
  97.  
  98. const CONFIGURABLE_MODERATION_OPTIONS = {
  99. flooding: true,
  100. caps: true,
  101. stretching: true,
  102. bannedwords: true
  103. };
  104.  
  105. const CONFIGURABLE_COMMAND_LEVELS = {
  106. off: false,
  107. disable: false,
  108. 'false': false,
  109. on: true,
  110. enable: true,
  111. 'true': true
  112. };
  113.  
  114. for (let i in Config.groups) {
  115. if (i !== ' ') CONFIGURABLE_COMMAND_LEVELS[i] = i;
  116. }
  117.  
  118. exports.commands = {
  119. /**
  120. * Help commands
  121. *
  122. * These commands are here to provide information about the bot.
  123. */
  124.  
  125. credits: 'about',
  126. about: function (arg, user, room) {
  127. var text = (room === user || user.hasRank(room.id, '#')) ? '' : '/pm ' + user.id + ', ';
  128. text += 'Still Configuring this bot.';
  129. this.say(room, text);
  130. },
  131.  
  132.  
  133.  
  134. git: function (arg, user, room) {
  135. var text = (room === user || user.isExcepted()) ? '' : '/pm ' + user.id + ', ';
  136. text += '**Pokemon Showdown Bot** source code: ' + Config.fork;
  137. this.say(room, text);
  138. },
  139. help: 'guide',
  140. guide: function (arg, user, room) {
  141. var text = (room === user || user.hasRank(room.id, '#')) ? '' : '/pm ' + user.id + ', ';
  142. if (Config.botguide) {
  143. text += 'A guide on how to use this bot can be found here: ' + Config.botguide;
  144. } else {
  145. text += 'There is no guide for this bot. PM the owner with any questions.';
  146. }
  147. this.say(room, text);
  148. },
  149.  
  150. /**
  151. * Dev commands
  152. *
  153. * These commands are here for highly ranked users (or the creator) to use
  154. * to perform arbitrary actions that can't be done through any other commands
  155. * or to help with upkeep of the bot.
  156. */
  157.  
  158. reload: function (arg, user, room) {
  159. //if (!user.isExcepted()) return false;
  160. try {
  161. this.uncacheTree('./commands.js');
  162. Commands = require('./commands.js').commands;
  163. this.say(room, 'Commands reloaded.');
  164. } catch (e) {
  165. error('failed to reload: ' + e.stack);
  166. }
  167. },
  168. custom: function (arg, user, room) {
  169. //if (!user.isExcepted()) return false;
  170. // Custom commands can be executed in an arbitrary room using the syntax
  171. // ".custom [room] command", e.g., to do !data pikachu in the room lobby,
  172. // the command would be ".custom [lobby] !data pikachu". However, using
  173. // "[" and "]" in the custom command to be executed can mess this up, so
  174. // be careful with them.
  175. if (arg.indexOf('[') !== 0 || arg.indexOf(']') < 0) {
  176. return this.say(room, arg);
  177. }
  178. var tarRoomid = arg.slice(1, arg.indexOf(']'));
  179. var tarRoom = Rooms.get(tarRoomid);
  180. if (!tarRoom) return this.say(room, Users.self.name + ' is not in room ' + tarRoomid + '!');
  181. arg = arg.substr(arg.indexOf(']') + 1).trim();
  182. this.say(tarRoom, arg);
  183. },
  184.  
  185. uptime: function (arg, user, room) {
  186. var text = ((room === user || user.isExcepted()) ? '' : '/pm ' + user.id + ', ') + '**Uptime:** ';
  187. var divisors = [52, 7, 24, 60, 60];
  188. var units = ['week', 'day', 'hour', 'minute', 'second'];
  189. var buffer = [];
  190. var uptime = ~~(process.uptime());
  191. do {
  192. let divisor = divisors.pop();
  193. let unit = uptime % divisor;
  194. buffer.push(unit > 1 ? unit + ' ' + units.pop() + 's' : unit + ' ' + units.pop());
  195. uptime = ~~(uptime / divisor);
  196. } while (uptime);
  197.  
  198. switch (buffer.length) {
  199. case 5:
  200. text += buffer[4] + ', ';
  201. /* falls through */
  202. case 4:
  203. text += buffer[3] + ', ';
  204. /* falls through */
  205. case 3:
  206. text += buffer[2] + ', ' + buffer[1] + ', and ' + buffer[0];
  207. break;
  208. case 2:
  209. text += buffer[1] + ' and ' + buffer[0];
  210. break;
  211. case 1:
  212. text += buffer[0];
  213. break;
  214. }
  215.  
  216. this.say(room, text);
  217. },
  218.  
  219.  
  220. /**
  221. * General commands
  222. *
  223. * Add custom commands here.
  224. */
  225.  
  226. tell: 'say',
  227. say: function (arg, user, room) {
  228. if (room === user || !user.canUse('say', room.id)) return false;
  229. this.say(room, stripCommands(arg) + ' (' + user.name + ' said this)');
  230. },
  231.  
  232. '8ball': function (arg, user, room) {
  233. if (room === user) return false;
  234. var text = user.canUse('8ball', room.id) ? '' : '/pm ' + user.id + ', ';
  235. var rand = ~~(21 * Math.random());
  236.  
  237. switch (rand) {
  238. case 0:
  239. text += "Signs point to yes.";
  240. break;
  241. case 1:
  242. text += "Yes.";
  243. break;
  244. case 2:
  245. text += "Reply hazy, try again.";
  246. break;
  247. case 3:
  248. text += "Without a doubt.";
  249. break;
  250. case 4:
  251. text += "My sources say no.";
  252. break;
  253. case 5:
  254. text += "As I see it, yes.";
  255. break;
  256. case 6:
  257. text += "You may rely on it.";
  258. break;
  259. case 7:
  260. text += "Concentrate and ask again.";
  261. break;
  262. case 8:
  263. text += "Outlook not so good.";
  264. break;
  265. case 9:
  266. text += "It is decidedly so.";
  267. break;
  268. case 10:
  269. text += "Better not tell you now.";
  270. break;
  271. case 11:
  272. text += "Very doubtful.";
  273. break;
  274. case 12:
  275. text += "Yes - definitely.";
  276. break;
  277. case 13:
  278. text += "It is certain.";
  279. break;
  280. case 14:
  281. text += "Cannot predict now.";
  282. break;
  283. case 15:
  284. text += "Most likely.";
  285. break;
  286. case 16:
  287. text += "Ask again later.";
  288. break;
  289. case 17:
  290. text += "My reply is no.";
  291. break;
  292. case 18:
  293. text += "Outlook good.";
  294. break;
  295. case 19:
  296. text += "Don't count on it.";
  297. break;
  298. case 20:
  299. text += "What ever. Conbeef is Great :D.";
  300. break;
  301. }
  302.  
  303. this.say(room, text);
  304. },
  305.  
  306.  
  307. /**
  308. * Room specific commands
  309. *
  310. * These commands are used in specific rooms on the Smogon server.
  311. */
  312.  
  313. //my commands
  314.  
  315. 'setalt': function(arg, user, room) {
  316. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  317. var text = "";
  318. switch(arg){
  319.  
  320. default:
  321. text += "No rank specified.";
  322. return this.say(room, text);
  323.  
  324. case "+":
  325. requiredAlt = '+';
  326. text += "Rank required is now set to **+** ";
  327. return this.say(room, text);
  328.  
  329. case "%":
  330. requiredAlt = '%';
  331. text += "Rank required is now set to **%** ";
  332. return this.say(room, text);
  333.  
  334. case "@":
  335. requiredAlt = '@';
  336. text += "Rank required is now set to **@** ";
  337. return this.say(room, text);
  338.  
  339. case "&":
  340. requiredAlt = '&';
  341. text += "Rank required is now set to **&** ";
  342. return this.say(room, text);
  343.  
  344. case "#":
  345. requiredAlt = '#';
  346. text += "Rank required is now set to **#** ";
  347. return this.say(room, text);
  348.  
  349. }
  350. },
  351.  
  352.  
  353. //Trivia Commands
  354. trivia: function(arg, user, room){
  355. if (room === user) return false;
  356. var text = '';
  357. if (game !="none"){
  358. return this.say( room,"Cannot start a game of trivia because a scripted game is running. Do .endgame!")
  359. }
  360. if(triviaON){this.say( room, '**ERROR**: A game of trivia is going on another room and hence it cannot be started here'); return false;}
  361. triviaON = true;
  362. triviaRoom = room.id;
  363. triviaA = '';
  364. triviaPoints = [];
  365. this.say( room, 'Hosting a game of **trivia**. Answer the questions using -ta or -triviaanswer. First to get 10 points wins.');
  366. triviaTimer = setInterval( function() {
  367. if(triviaA){this.say(room, '**BEEP** TIMES UP!! ' + triviaA);}
  368. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  369. triviaQ = triviaQuestions[TQN];
  370. triviaA = triviaQuestions[TQN+ 1];
  371. this.say( room, '**Question**: ' + triviaQ);
  372. }.bind(this), 15000);
  373.  
  374. },
  375. triviapoints: function(arg, user, room){
  376. var text = user.canUse('8ball', room.id) ? '' : '/pm ' + user.id + ', ';
  377. if(!anagramON) return false;
  378. var text = '**Triviapoints so far**: '
  379. for (var i = 0; i < triviaPoints.length; i++){
  380. text += '' + triviaPoints[i] + ': ';
  381. text += triviaPoints[i + 1] + ' Pokepoints, ';
  382. i++
  383. }
  384. this.say(room, text);
  385. },
  386. ta: 'triviaanswer',
  387. triviaanswer: function(arg, user, room){
  388. if(room.id !== triviaRoom) return false;
  389. if (game != "none") return false;
  390. if (!arg) return false;
  391. arg = (arg);
  392. var theuser = (user.name);
  393. if(arg == triviaA){
  394. if (triviaPoints.indexOf(theuser) > -1){
  395. triviaA = '';
  396. triviaPoints[triviaPoints.indexOf(theuser) + 1] += 1;
  397. if (triviaPoints[triviaPoints.indexOf(theuser) + 1] >= 10) {
  398. clearInterval(triviaTimer);
  399. this.say( room, '**Congrats to ' + user.name + ' for winning Trivia!**');
  400. this.say(room,'/pm '+ user.name + ' ,**Congratulations** on winning the game of trivia.')
  401. this.say(room,'/msg lustrousash,' + user.name + ' have been awarded **2 Points** for winning trivia')
  402. triviaON = false;
  403. return false;
  404. }
  405. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoints!');
  406. } else {
  407. triviaA = '';
  408. triviaPoints[triviaPoints.length] = theuser;
  409. triviaPoints[triviaPoints.length] = 1;
  410. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoint!');
  411. }
  412. }
  413. },
  414. triviaend: function(arg, user, room){
  415. if (game != "none") return false;
  416. if(room.id !== triviaRoom)return false;
  417. if(!triviaON) return false;
  418. //if (room === user || !user.hasRank(room.id, '#@+%')) return false;
  419. clearInterval(triviaTimer);
  420. this.say(room, 'The game of trivia has been ended.');
  421. triviaON = false;
  422. },
  423.  
  424. /**
  425. * PMRaid Commands
  426. *
  427. * Commands that are also legit cancer.
  428. */
  429. cr: 'checkroom',
  430. checkroom: function(arg, user, room) {
  431. this.say(room,"room id = "+ room.id + " |" + " serverid = "+ Config.serverid + " | " + "export server = "+ Config.server)
  432. },
  433.  
  434. /*
  435. 'lennyraid': function(arg, user, room) {
  436. //if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  437. var theuser = user.name;
  438. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  439. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  440. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  441. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  442. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  443. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  444. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  445. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  446. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  447. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  448.  
  449.  
  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 + ", ( ͡° ͜ʖ ͡°)");
  456. this.say(room, "/pm " + arg + ", ( ͡° ͜ʖ ͡°)");
  457. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  458.  
  459.  
  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 + ", ( ͡° ͜ʖ ͡°)");
  466. this.say(room, "/pm " + arg + ", Sorry " + arg + " But " + theuser + " Made me do this...");
  467. },
  468. */
  469.  
  470.  
  471.  
  472.  
  473. 'randpoke': function (arg, user, room) {
  474. if (room === user) return false;
  475. var text = user.canUse('randpoke', room.id) ? '' : '/pm ' + user.id + ', ';
  476.  
  477. switch (arg){
  478.  
  479. case "gen1":
  480. var rand = Math.round(Math.random() * (151 - 1) + 1);
  481. text += "!dt"+" "+rand;
  482. break;
  483.  
  484. case "gen2":
  485. var rand = Math.round(Math.floor(Math.random() * (251 -152) + 152));
  486. text += "!dt"+" "+rand;
  487. break;
  488.  
  489. case "gen3":
  490. var rand = Math.round(Math.floor(Math.random() * (386 - 252) + 252));
  491. text += "!dt"+" "+rand;
  492. break;
  493.  
  494. case "gen4":
  495. var rand = Math.round(Math.floor(Math.random() * (493 - 387) + 387));
  496. text += "!dt"+" "+rand;
  497. break;
  498.  
  499. case "gen5":
  500. var rand = Math.round(Math.floor(Math.random() * (649 - 494) + 494));
  501. text += "!dt"+" "+rand;
  502. break;
  503.  
  504. case "gen6":
  505. var rand = Math.round(Math.floor(Math.random() * (721 - 650) + 650));
  506. text += "!dt"+" "+rand;
  507. break;
  508.  
  509. default:
  510. var rand = ~~(721 * Math.random());
  511. text += "!dt"+" "+rand;
  512. break;
  513.  
  514. }
  515. this.say(room, text);
  516. },
  517.  
  518. 'custsay': function (arg, user, room) {
  519. if (room === user) return false;
  520. //arg = toId(arg)
  521. var text = user.canUse('custsay', room.id) ? '' : '/pm ' + user.id + ', ';
  522. text += arg;
  523. this.say(room, text);
  524. },
  525.  
  526.  
  527. 'rps': function (arg, user, room) {
  528. var playerschoice = arg.toUpperCase();
  529. var choices = ["Rock","Paper","Scissors"];
  530.  
  531. if (playerschoice == "ROCK"){
  532. playerschoice = "Rock";
  533. }
  534.  
  535.  
  536. if (playerschoice == "PAPER"){
  537. playerschoice = "Paper";
  538. }
  539.  
  540.  
  541. if (playerschoice == "SCISSORS"){
  542. playerschoice = "Scissors";
  543. }
  544.  
  545. switch(playerschoice){
  546.  
  547. case "Rock":
  548.  
  549. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  550. this.say(room,user.name + ", I pick "+ botchoice);
  551.  
  552. if (botchoice == "Rock" ){
  553. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  554. break;
  555. }
  556.  
  557. if (botchoice == "Paper" ){
  558. return this.say(room,"Sorry " + user.name + ", Paper beats Rock. Want to play again? (¬‿¬)");
  559. break;
  560. }
  561.  
  562.  
  563. if (botchoice == "Scissors" ){
  564. return this.say(room,user.name + ", You win. Want to play again? ");
  565. break;
  566. }
  567.  
  568.  
  569.  
  570. case "Paper":
  571.  
  572. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  573. this.say(room,user.name + ", I pick "+ botchoice);
  574.  
  575. if (botchoice == "Paper" ){
  576. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  577. break;
  578. }
  579.  
  580. if (botchoice == "Scissors" ){
  581. return this.say(room,"Sorry " + user.name + ", Scissors beats Paper. Want to play again? (¬‿¬)");
  582. break;
  583. }
  584.  
  585.  
  586. if (botchoice == "Rock" ){
  587. return this.say(room,user.name + ", You win. Want to play again? ");
  588. break;
  589. }
  590.  
  591.  
  592. case "Scissors":
  593.  
  594. var botchoice = choices[Math.round(Math.random()*(choices.length-1))];
  595. this.say(room,user.name + ", I pick "+ botchoice);
  596.  
  597. if (botchoice == "Scissors" ){
  598. return this.say(room,user.name + ", It was a tie. Want to play again? ");
  599. break;
  600. }
  601.  
  602. if (botchoice == "Rock" ){
  603. return this.say(room,"Sorry " + user.name + ", Rock beats Scissors. Want to play again? (¬‿¬)");
  604. break;
  605. }
  606.  
  607.  
  608. if (botchoice == "Paper" ){
  609. return this.say(room,user.name + ", You win. Want to play again? ");
  610. break;
  611. }
  612.  
  613.  
  614. }
  615.  
  616. },
  617.  
  618. ///////////////////////////////////////////Scripted Game Setup//////////////////////////////////////////////////////////////
  619. signups: 'signup',
  620. 'signup': function (arg, user, room) {
  621. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  622. var text = "";
  623. var gametomake = arg.toLowerCase();
  624.  
  625. if (triviaON){
  626. text += "**That game cannot be created, because there is a game of Trivia running. Do .triviaend**"
  627. return this.say(room, text);
  628. }
  629.  
  630. if (gametomake == "bj" || gametomake == "black jack"){
  631. gametomake = "blackjack";
  632. }
  633.  
  634. if (gametomake == "amb"){
  635. gametomake = "ambush";
  636. }
  637.  
  638. if (gametomake == "old" || gametomake == "rod" || gametomake == "old rod" || gametomake == "or"){
  639. gametomake = "oldrod";
  640. }
  641.  
  642. if (gametomake == "tt" || gametomake == "team trivia" || gametomake == "t trivia"){
  643. gametomake = "ttrivia";
  644. }
  645.  
  646. if (gametomake == "8's" || gametomake == "eights" || gametomake == "eight's"){
  647. gametomake = "8s";
  648. }
  649.  
  650. if (game == "none"){
  651.  
  652. switch(gametomake){
  653.  
  654. default:
  655. text += "**That is not a scripted game. Please check spelling**"
  656. return this.say(room, text);
  657. break;
  658.  
  659. case "blackjack":
  660. game = "blackjack";
  661. requiredPlayers = 1;
  662. maxPlayers = 14;
  663. dealerstotal = 0;
  664. currentplayer = 0;
  665. numofaces = 0;
  666. started = false;
  667. joinusers = [];
  668. joinusersid = [];
  669. playerdata = [];
  670. cards = ["A","A","A","A",2,2,2,2,3,3,3,3,4,4,4,4,
  671. 5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,
  672. 10,10,10,10,"J","J","J","J","Q","Q","Q","Q","K","K","K","K"];
  673. text = "";
  674. text += "**Blackjack was created! Do .joingame to join and .startgame to start!**";
  675. return this.say(room, text);
  676. break;
  677.  
  678. case "ambush":
  679. game = "ambush";
  680. requiredPlayers = 2;
  681. maxPlayers = 9999;
  682. joinusers = [];
  683. joinusersid = [];
  684. playerdata = [];
  685. text = "";
  686. text += "**Ambush was created! Do .joingame to join and .startgame to start!**";
  687. return this.say(room, text);
  688. break;
  689.  
  690. case "oldrod":
  691. game = "oldrod";
  692. requiredPlayers = 2;
  693. maxPlayers = 9999;
  694. dealerstotal = 1;
  695. joinusers = [];
  696. joinusersid = [];
  697. safeusers = [];
  698. playerdata = [];
  699. rounds = 1;
  700. text = "";
  701. text += "**Old Rod was created! Do .joingame to join and .startgame to start!**";
  702. return this.say(room, text);
  703. break;
  704.  
  705. case "ttrivia":
  706. game = "ttrivia";
  707. requiredPlayers = 1;
  708. maxPlayers = 9999;
  709. joinusers = [];
  710. joinusersid = [];
  711. playerdata = [];
  712. teamOne = [];
  713. teamTwo = [];
  714. teamOnePoints = 0;
  715. teamTwoPoints = 0;
  716. text = "";
  717. text += "**Team Trivia was created! Do .joingame to join and .startgame to start!**";
  718. return this.say(room, text);
  719. break;
  720.  
  721. case "8s":
  722. game = "8s";
  723. requiredPlayers = 2;
  724. maxPlayers = 16;
  725. joinusers = [];
  726. joinusersid = [];
  727. playerdata = [];
  728. text = "";
  729. text += "**8's was created! Do .joingame to join and .startgame to start!**";
  730. return this.say(room, text);
  731. break;
  732.  
  733. }
  734. }else{
  735. text += "**A scripted game was already made. Please do .endgame to end the game.**";
  736. return this.say(room, text);
  737. text = "";
  738. }
  739.  
  740. },
  741.  
  742. end: 'endgame',
  743. 'endgame': function (arg, user, room) {
  744. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  745. var text = "";
  746.  
  747. switch(game){
  748.  
  749. case "none":
  750. text += "**There is no game currently running.**";
  751. return this.say(room, text);
  752. text = "";
  753. break;
  754.  
  755. case "blackjack":
  756. game = "none";
  757. started = false;
  758. requiredPlayers = 0;
  759. text += "**Blackjack has ended.**";
  760. return this.say(room, text);
  761. break;
  762.  
  763. case "ambush":
  764. game = "none";
  765. started = false;
  766. requiredPlayers = 0;
  767. clearInterval(active);
  768. text += "**Ambush has ended.**";
  769. return this.say(room, text);
  770. break;
  771.  
  772. case "oldrod":
  773. game = "none";
  774. started = false;
  775. requiredPlayers = 0;
  776. clearInterval(active);
  777. clearTimeout(active);
  778. text += "**Old Rod has ended.**";
  779. return this.say(room, text);
  780. break;
  781.  
  782. case "ttrivia":
  783. game = "none";
  784. clearInterval(triviaTimer);
  785. started = false;
  786. triviaON = false;
  787. requiredPlayers = 0;
  788. text += "**Team Trivia has ended.**";
  789. return this.say(room, text);
  790. break;
  791.  
  792. case "8s":
  793. game = "none";
  794. started = false;
  795. requiredPlayers = 0;
  796. text += "**8s has ended.**";
  797. return this.say(room, text);
  798. break;
  799.  
  800. }
  801.  
  802. },
  803.  
  804. start: 'startgame',
  805. 'startgame': function (arg, user, room) {
  806. if (room === user || !user.hasRank(room.id, requiredAlt)) return false;
  807. var text = "";
  808. if (started == false){
  809. if (game != "none"){
  810. if (joinusers.length >= requiredPlayers){
  811.  
  812. if (game == "blackjack"){
  813. started = true;
  814. text = "";
  815. text += "**The game of Blackjack has started!**";
  816. this.say(room, text);
  817. text = "";
  818.  
  819. var starttimer = setTimeout(function(){
  820.  
  821.  
  822. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  823. var rand = (Math.round(Math.random()*(cards.length-1)));
  824. var choosencard = cards[rand];
  825. var actualcard = choosencard;
  826. cards.splice(rand,1);
  827.  
  828.  
  829. switch(choosencard){
  830. case "A":
  831. numofaces += 1;
  832. choosencard = 11;
  833. actualcard += "(11)";
  834. break;
  835.  
  836. case "J":
  837. choosencard = 10;
  838. actualcard += "(10)";
  839. break;
  840.  
  841. case "Q":
  842. choosencard = 10;
  843. actualcard += "(10)";
  844. break;
  845.  
  846. case "K":
  847. choosencard = 10;
  848. actualcard += "(10)";
  849. break;
  850. }
  851.  
  852. playerdata[currentplayer] = choosencard;
  853. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  854. this.say(room, text);
  855. text = "";
  856.  
  857. text += joinusers[currentplayer] + " .hit or .stay";
  858. this.say(room, text);
  859. text = "";
  860. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  861. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  862. var rand = (Math.round(Math.random()*(cards.length-1)));
  863. var choosencard = cards[rand];
  864. var actualcard = choosencard;
  865. cards.splice(rand,1);
  866.  
  867. if (playerdata[currentplayer] >= 11){
  868.  
  869. switch(choosencard){
  870. case "A":
  871. choosencard = 1;
  872. actualcard += "(1)";
  873. break;
  874.  
  875. case "J":
  876. choosencard = 10;
  877. actualcard += "(10)";
  878. break;
  879.  
  880. case "Q":
  881. choosencard = 10;
  882. actualcard += "(10)";
  883. break;
  884.  
  885. case "K":
  886. choosencard = 10;
  887. actualcard += "(10)";
  888. break;
  889. }
  890. }
  891.  
  892.  
  893. if (playerdata[currentplayer] < 11){
  894.  
  895. switch(choosencard){
  896. case "A":
  897. numofaces += 1;
  898. choosencard = 11;
  899. actualcard += "(11)";
  900. break;
  901.  
  902. case "J":
  903. choosencard = 10;
  904. actualcard += "(10)";
  905. break;
  906.  
  907. case "Q":
  908. choosencard = 10;
  909. actualcard += "(10)";
  910. break;
  911.  
  912. case "K":
  913. choosencard = 10;
  914. actualcard += "(10)";
  915. break;
  916. }
  917. }
  918.  
  919.  
  920. playerdata[currentplayer] += choosencard;
  921.  
  922. if (playerdata[currentplayer] > 21){
  923. if (numofaces > 0){
  924. playerdata[currentplayer] -= 10;
  925. numofaces -= 1
  926. }}
  927.  
  928. text = "";
  929. text += "You got a "+actualcard;
  930. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  931. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  932. text = "";
  933. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  934. }.bind(this), 4000);
  935. }
  936.  
  937. if (game == "ambush"){
  938. var i;
  939. for(i=0;i < joinusers.length; i+=1){
  940. playerdata[i] = 2;
  941. }
  942. started = true;
  943. text = "";
  944. text += "**The game of Ambush has started! (do .fire [user] when I say FIRE!)**";
  945. this.say(room, text);
  946. text = "";
  947.  
  948. var starttimer = setTimeout(function(){
  949. for(i = 0; i < joinusers.length; i +=1){
  950. if (i == joinusers.length-1){
  951. text += joinusers[i]+"! Get ready!";
  952. }
  953. if (i == joinusers.length - 2){
  954. text += joinusers[i]+" and ";
  955. }
  956. if (i != joinusers.length -1 && i != playerdata.length - 2){
  957. text += joinusers[i]+",";
  958. }
  959. }
  960. text = "**"+text+"**";
  961. this.say(room, text);
  962. text = "";
  963.  
  964. checked = true;
  965. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  966. var firetimer = setTimeout(function(){
  967. text = "**FIRE!**";
  968. this.say(room, text);
  969. checked = false;
  970. text = "";;
  971. }.bind(this), delaytime);
  972. active = setInterval(function(){
  973. turnspassed +=1
  974. if (turnspassed < 3){
  975. var starttimer = setTimeout(function(){
  976. for(i = 0; i < joinusers.length; i +=1){
  977. if (i == joinusers.length-1){
  978. text += joinusers[i]+"! Get ready!";
  979. }
  980. if (i == joinusers.length - 2){
  981. text += joinusers[i]+" and ";
  982. }
  983. if (i != joinusers.length -1 && i != playerdata.length - 2){
  984. text += joinusers[i]+",";
  985. }
  986. }
  987. text = "**"+text+"**";
  988. this.say(room, text);
  989. text = "";
  990.  
  991. checked = true;
  992. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  993. var firetimer = setTimeout(function(){
  994. text = "**FIRE!**";
  995. this.say(room, text);
  996. checked = false;
  997. text = "";
  998. active;
  999.  
  1000. }.bind(this), delaytime);
  1001.  
  1002. }.bind(this), 4000);
  1003. }else{
  1004.  
  1005. text = "A Greninja came out of no where and use water shuriken on everyone. RIP!!! **The game has ended due to inactivity**";
  1006. this.say(room, text);
  1007. text = "";
  1008. clearInterval(active);
  1009. game = "none";
  1010. started = false;
  1011. requiredPlayers = 0;
  1012. turnspassed = 0;
  1013.  
  1014. }
  1015. }.bind(this), 20000);
  1016.  
  1017. }.bind(this), 4000);
  1018. }
  1019.  
  1020.  
  1021. if (game == "ttrivia"){
  1022.  
  1023. started= true;
  1024. shuffle(joinusers);
  1025. triviaON = true;
  1026. triviaRoom = room.id;
  1027. triviaA = '';
  1028. triviaPoints = [];
  1029. var turn = 1;
  1030. var textone = "";
  1031. var texttwo = "";
  1032. var i;
  1033.  
  1034. for(i = 0; i < joinusers.length; i+=1){
  1035.  
  1036. if (turn == 1){
  1037. teamOne[teamOne.length] = joinusers[i]
  1038. //joinusers.splice(i,1);
  1039. }
  1040.  
  1041. if (turn == -1){
  1042. teamTwo[teamTwo.length] = joinusers[i]
  1043. //joinusers.splice(i,1);
  1044. }
  1045.  
  1046. turn = turn * -1
  1047. }
  1048.  
  1049. for(i = 0; i < teamOne.length; i +=1){
  1050.  
  1051. if (i == teamOne.length - 1){
  1052. textone += teamOne[i] + "!"
  1053. }
  1054.  
  1055. if (i == teamOne.length - 2){
  1056. textone += teamOne[i] +" and "
  1057. }
  1058.  
  1059. if (i != teamOne.length - 1 && i != teamOne.length - 2){
  1060. textone += teamOne[i] + ","
  1061. }
  1062.  
  1063. }
  1064.  
  1065. for(i = 0; i < teamTwo.length; i +=1){
  1066.  
  1067. if (i == teamTwo.length - 1){
  1068. texttwo += teamTwo[i]+"!"
  1069. }
  1070.  
  1071. if (i == teamTwo.length - 2){
  1072. texttwo += teamTwo[i] +" and "
  1073. }
  1074.  
  1075. if (i != teamTwo.length - 1 && i != teamTwo.length - 2){
  1076. texttwo += teamTwo[i]+","
  1077. }
  1078.  
  1079. }
  1080.  
  1081. this.say( room, 'Hosting a game of **Team Trivia**. Answer the questions using -tta or -teamtriviaanswer. First to get 10 points wins.');
  1082.  
  1083. this.say( room, "Team Ash: "+textone);
  1084. this.say( room, "Team Conbeef: "+texttwo);
  1085.  
  1086. triviaTimer = setInterval( function() {
  1087. if(triviaA){this.say(room, '**BEEP** TIMES UP!! ' + triviaA);}
  1088. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  1089. triviaQ = triviaQuestions[TQN];
  1090. triviaA = triviaQuestions[TQN+ 1];
  1091. this.say( room, '**Question**: ' + triviaQ);
  1092. }.bind(this), 15000);
  1093.  
  1094. }
  1095.  
  1096.  
  1097. if (game == "oldrod"){
  1098.  
  1099. started= true;
  1100.  
  1101. text = "";
  1102. text += "**The game of Old Rod has started! (do .reel when the fish bite!(! appears when there's a bite))**";
  1103. this.say(room, text);
  1104. text = "";
  1105.  
  1106. var i;
  1107. for(i = 0; i < joinusers.length; i += 1){
  1108. playerdata[i] = 0;
  1109. safeusers[i] = 1;
  1110. }
  1111.  
  1112. var starttimer = setTimeout(function(){
  1113.  
  1114. for(i = 0; i < joinusers.length; i +=1){
  1115.  
  1116. if (i == joinusers.length-1){
  1117. text += joinusers[i]+"! Get ready to fish!";
  1118. }
  1119.  
  1120. if (i == joinusers.length - 2){
  1121. text += joinusers[i]+" and ";
  1122. }
  1123.  
  1124. if (i != joinusers.length -1 && i != playerdata.length - 2){
  1125. text += joinusers[i]+",";
  1126. }
  1127.  
  1128. }
  1129. text = "**"+text+"**";
  1130. this.say(room,"Round "+rounds+"!"+ text);
  1131. text = "";
  1132.  
  1133. checked = true;
  1134. dealerstotal = 0;
  1135. var times = 0;
  1136. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","not even a nibble.","!","!","!"];
  1137. var reeltimer = setTimeout(function(){
  1138.  
  1139. active = setInterval(function(){
  1140.  
  1141. times += 1;
  1142.  
  1143. if (times < 2){
  1144. this.say(room, "**...**");
  1145. active;
  1146. }
  1147.  
  1148. if (times >= 3){
  1149.  
  1150. var rand = (Math.round(Math.random()*(randpull.length-1)));
  1151. var pick = randpull[rand];
  1152.  
  1153. if (pick == "..."){
  1154. this.say(room, "**...**");
  1155. randpull.splice(0,4)
  1156. }
  1157.  
  1158. if (pick == "!"){
  1159. this.say(room, "**!**");
  1160. clearInterval(active);
  1161. checked = false;
  1162.  
  1163. active = setTimeout(function(){
  1164. game = "none";
  1165. started = false;
  1166. requiredPlayers = 0;
  1167. clearInterval(active);
  1168. text = "";
  1169. text += "The Rod has broken. **Game ended due to inactivity.**";
  1170. return this.say(room, text);
  1171. }.bind(this), 60000);
  1172.  
  1173. }
  1174.  
  1175. if (pick == "not even a nibble."){
  1176. this.say(room, "**not even a nibble.**");
  1177. clearInterval(active);
  1178. if (rounds < 10){
  1179. rounds += 1;
  1180.  
  1181.  
  1182.  
  1183. var starttimerr = setTimeout(function(){
  1184.  
  1185.  
  1186. for(i = 0; i < joinusers.length; i +=1){
  1187.  
  1188. if (i == joinusers.length-1){
  1189. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  1190. }
  1191.  
  1192. if (i == joinusers.length - 2){
  1193. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  1194. }
  1195.  
  1196. if (i != joinusers.length -1 && i != playerdata.length - 2){
  1197. text += joinusers[i]+"("+playerdata[i]+")"+",";
  1198. }
  1199.  
  1200. }
  1201. text = "**"+text+"**";
  1202. this.say(room,"Round "+rounds+"!"+ text);
  1203. text = "";
  1204.  
  1205. checked = true;
  1206. dealerstotal = 0;
  1207. var times = 0;
  1208. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","!","!","!","!","!"];
  1209. var reeltimer = setTimeout(function(){
  1210.  
  1211. active = setInterval(function(){
  1212.  
  1213. times += 1;
  1214.  
  1215. if (times < 2){
  1216. this.say(room, "**...**");
  1217. active;
  1218. }
  1219.  
  1220. if (times >= 3){
  1221.  
  1222. var rand = (Math.round(Math.random()*(randpull.length-1)));
  1223. var pick = randpull[rand];
  1224.  
  1225. if (pick == "..."){
  1226. this.say(room, "**...**");
  1227. randpull.splice(0,4)
  1228. }
  1229.  
  1230. if (pick == "!"){
  1231. this.say(room, "**!**");
  1232. clearInterval(active);
  1233. checked = false;
  1234.  
  1235. active = setTimeout(function(){
  1236. game = "none";
  1237. started = false;
  1238. requiredPlayers = 0;
  1239. clearInterval(active);
  1240. text = "";
  1241. text += "The Rod has broken. **Game ended due to inactivity.**";
  1242. return this.say(room, text);
  1243. }.bind(this), 60000);
  1244.  
  1245. }
  1246.  
  1247. }
  1248.  
  1249. }.bind(this), 1500);
  1250.  
  1251. }.bind(this), 4000);
  1252.  
  1253. }.bind(this), 2000);
  1254.  
  1255.  
  1256.  
  1257. }
  1258.  
  1259.  
  1260. }
  1261. }
  1262.  
  1263. }.bind(this), 1500);
  1264.  
  1265. }.bind(this), 4000);
  1266.  
  1267. }.bind(this), 2000);
  1268.  
  1269. }
  1270.  
  1271. if (game == "8s"){
  1272.  
  1273. started= true;
  1274. shuffle(joinusers);
  1275. var turn = 1;
  1276. var textone = "";
  1277. var texttwo = "";
  1278. var i;
  1279.  
  1280. for(i = 0; i < joinusers.length; i+=1){
  1281.  
  1282. if (turn == 1){
  1283. teamOne[teamOne.length] = joinusers[i]
  1284. //joinusers.splice(i,1);
  1285. }
  1286.  
  1287. if (turn == -1){
  1288. teamTwo[teamTwo.length] = joinusers[i]
  1289. //joinusers.splice(i,1);
  1290. }
  1291.  
  1292. turn = turn * -1
  1293. }
  1294.  
  1295. for(i = 0; i < teamOne.length; i +=1){
  1296.  
  1297. if (i == teamOne.length - 1){
  1298. textone += teamOne[i] + "!"
  1299. }
  1300.  
  1301. if (i == teamOne.length - 2){
  1302. textone += teamOne[i] +" and "
  1303. }
  1304.  
  1305. if (i != teamOne.length - 1 && i != teamOne.length - 2){
  1306. textone += teamOne[i] + ","
  1307. }
  1308.  
  1309. }
  1310.  
  1311. for(i = 0; i < teamTwo.length; i +=1){
  1312.  
  1313. if (i == teamTwo.length - 1){
  1314. texttwo += teamTwo[i]+"!"
  1315. }
  1316.  
  1317. if (i == teamTwo.length - 2){
  1318. texttwo += teamTwo[i] +" and "
  1319. }
  1320.  
  1321. if (i != teamTwo.length - 1 && i != teamTwo.length - 2){
  1322. texttwo += teamTwo[i]+","
  1323. }
  1324.  
  1325. }
  1326.  
  1327. var randd = ~~(teamOne.length * Math.random());
  1328. safeusers[safeusers.length] = teamOne[randd];
  1329.  
  1330. randd = ~~(teamTwo.length * Math.random());
  1331. safeusers[safeusers.length] = teamTwo[randd];
  1332.  
  1333. this.say( room, "**Team red:** "+textone+" **The Team captian is** "+safeusers[0]+"**.**");
  1334. this.say( room, "**Team blue:** "+texttwo+" **The Team captian is** "+safeusers[1]+"**.**");
  1335. this.say( room, "**Do .randcapt or choosecapt [user] to change the team captian.**");
  1336.  
  1337. }
  1338.  
  1339.  
  1340. }else{
  1341. text = "";
  1342. text += "**This game requires at least** "+requiredPlayers+" **player(s).**";
  1343. return this.say(room, text);
  1344. }
  1345. }else{
  1346. text = "";
  1347. text += "**No scripted game was created to start.**";
  1348. return this.say(room, text);
  1349. }
  1350. }
  1351. },
  1352.  
  1353. join: 'joingame',
  1354. 'joingame': function (arg, user, room) {
  1355. if (room === user) return false;
  1356. var text = "";
  1357. var checkjoin;
  1358. var i;
  1359. if (started == true) return false;
  1360. if (game == "none") return false;
  1361. if (joinusers.length < maxPlayers){
  1362. for(i = 0; i < joinusers.length; i++){
  1363. checkjoin = joinusersid[i]
  1364. if (checkjoin == user.id){
  1365. text += user.name+" has already joined!"
  1366. return this.say(room, text);
  1367. text = "";
  1368. }
  1369. }
  1370. joinusers[joinusers.length] = user.name;
  1371. joinusersid[joinusersid.length] = user.id;
  1372. text += user.name + " has joined!";
  1373. this.say(room, text);
  1374. text = ""
  1375. }else{
  1376. for(i = 0; i < joinusers.length; i++){
  1377. checkjoin = joinusersid[i]
  1378. if (checkjoin == user.id){
  1379. text += user.name+" has already joined!"
  1380. return this.say(room, text);
  1381. text = "";
  1382. }
  1383. }
  1384. text += "Sorry "+user.name+". The maximum amount of players has been reached."
  1385. return this.say(room, text);
  1386. }
  1387. },
  1388.  
  1389.  
  1390. leave: 'leavegame',
  1391. 'leavegame': function (arg, user, room) {
  1392. if (room === user) return false;
  1393. var text = "";
  1394. var checkjoin;
  1395. var i;
  1396. if (started == true) return false;
  1397. if (game == "none") return false;
  1398.  
  1399. for(i = 0; i < joinusers.length; i++){
  1400. checkjoin = joinusersid[i]
  1401. if (checkjoin == user.id){
  1402. joinusers.splice(i,1);
  1403. joinusersid.splice(i,1);
  1404. text += user.name+" has left the game."
  1405. return this.say(room, text);
  1406. text = "";
  1407. break;
  1408. }}
  1409. },
  1410.  
  1411. ///////////////////////////////////////////Scripted Game Setup//////////////////////////////////////////////////////////////
  1412.  
  1413. //////////////Black Jack///////////////////
  1414.  
  1415. 'hit': function (arg, user, room) {
  1416. if (room === user) return false;
  1417. var text = "";
  1418. if (user.name == joinusers[currentplayer] || user.id == joinusersid[currentplayer]){
  1419. if (game == "blackjack"){
  1420. if (started == true) {
  1421. /////////////////////////////////////////////////////////////////////////////////////////////////////////////HIT
  1422. var rand = (Math.round(Math.random()*(cards.length-1)));
  1423. var choosencard = cards[rand];
  1424. var actualcard = choosencard;
  1425. cards.splice(rand,1);
  1426.  
  1427. if (playerdata[currentplayer] >= 11){
  1428.  
  1429. switch(choosencard){
  1430. case "A":
  1431. choosencard = 1;
  1432. actualcard += "(1)";
  1433. break;
  1434.  
  1435. case "J":
  1436. choosencard = 10;
  1437. actualcard += "(10)";
  1438. break;
  1439.  
  1440. case "Q":
  1441. choosencard = 10;
  1442. actualcard += "(10)";
  1443. break;
  1444.  
  1445. case "K":
  1446. choosencard = 10;
  1447. actualcard += "(10)";
  1448. break;
  1449. }
  1450. }
  1451.  
  1452.  
  1453. if (playerdata[currentplayer] < 11){
  1454.  
  1455. switch(choosencard){
  1456. case "A":
  1457. numofaces += 1;
  1458. choosencard = 11;
  1459. actualcard += "(11)";
  1460. break;
  1461.  
  1462. case "J":
  1463. choosencard = 10;
  1464. actualcard += "(10)";
  1465. break;
  1466.  
  1467. case "Q":
  1468. choosencard = 10;
  1469. actualcard += "(10)";
  1470. break;
  1471.  
  1472. case "K":
  1473. choosencard = 10;
  1474. actualcard += "(10)";
  1475. break;
  1476. }
  1477. }
  1478.  
  1479.  
  1480. playerdata[currentplayer] += choosencard;
  1481.  
  1482. if (playerdata[currentplayer] > 21){
  1483. if (numofaces > 0){
  1484. playerdata[currentplayer] -= 10;
  1485. numofaces -= 1
  1486. }}
  1487. text += "You got a "+actualcard;
  1488. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1489. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1490. text = "";
  1491. /////////////////////////////////////////////////////////////////////////////////////////////////////////////HIT
  1492.  
  1493.  
  1494. if (playerdata[currentplayer] > 21){
  1495. if (numofaces <= 0){
  1496. text = "";
  1497. text += joinusers[currentplayer] + " has busted with " + playerdata[currentplayer] + "!";
  1498. this.say(room, text);
  1499. text = "";
  1500. currentplayer += 1;
  1501.  
  1502. if (currentplayer == joinusers.length){
  1503. text = ""
  1504. text += "**Everyone has finished. Its the dealers turn. Calculating......**"
  1505. this.say(room, text)
  1506. text = "";
  1507. }
  1508.  
  1509. if (currentplayer < joinusers.length){
  1510.  
  1511. var hittimer = setTimeout(function(){
  1512. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  1513. var rand = (Math.round(Math.random()*(cards.length-1)));
  1514. var choosencard = cards[rand];
  1515. var actualcard = choosencard;
  1516. cards.splice(rand,1);
  1517.  
  1518.  
  1519. switch(choosencard){
  1520. case "A":
  1521. numofaces += 1;
  1522. choosencard = 11;
  1523. actualcard += "(11)";
  1524. break;
  1525.  
  1526. case "J":
  1527. choosencard = 10;
  1528. actualcard += "(10)";
  1529. break;
  1530.  
  1531. case "Q":
  1532. choosencard = 10;
  1533. actualcard += "(10)";
  1534. break;
  1535.  
  1536. case "K":
  1537. choosencard = 10;
  1538. actualcard += "(10)";
  1539. break;
  1540. }
  1541.  
  1542. playerdata[currentplayer] = choosencard;
  1543. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  1544. this.say(room, text);
  1545. text = "";
  1546.  
  1547. text += joinusers[currentplayer] + " .hit or .stay";
  1548. this.say(room, text);
  1549. text = "";
  1550. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  1551. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1552. var rand = (Math.round(Math.random()*(cards.length-1)));
  1553. var choosencard = cards[rand];
  1554. var actualcard = choosencard;
  1555. cards.splice(rand,1);
  1556.  
  1557. if (playerdata[currentplayer] >= 11){
  1558.  
  1559. switch(choosencard){
  1560. case "A":
  1561. choosencard = 1;
  1562. actualcard += "(1)";
  1563. break;
  1564.  
  1565. case "J":
  1566. choosencard = 10;
  1567. actualcard += "(10)";
  1568. break;
  1569.  
  1570. case "Q":
  1571. choosencard = 10;
  1572. actualcard += "(10)";
  1573. break;
  1574.  
  1575. case "K":
  1576. choosencard = 10;
  1577. actualcard += "(10)";
  1578. break;
  1579. }
  1580. }
  1581.  
  1582.  
  1583. if (playerdata[currentplayer] < 11){
  1584.  
  1585. switch(choosencard){
  1586. case "A":
  1587. numofaces += 1;
  1588. choosencard = 11;
  1589. actualcard += "(11)";
  1590. break;
  1591.  
  1592. case "J":
  1593. choosencard = 10;
  1594. actualcard += "(10)";
  1595. break;
  1596.  
  1597. case "Q":
  1598. choosencard = 10;
  1599. actualcard += "(10)";
  1600. break;
  1601.  
  1602. case "K":
  1603. choosencard = 10;
  1604. actualcard += "(10)";
  1605. break;
  1606. }
  1607. }
  1608.  
  1609.  
  1610. playerdata[currentplayer] += choosencard;
  1611.  
  1612. if (playerdata[currentplayer] > 21){
  1613. if (numofaces > 0){
  1614. playerdata[currentplayer] -= 10;
  1615. numofaces -= 1
  1616. }}
  1617.  
  1618. text = "";
  1619. text += "You got a "+actualcard;
  1620. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1621. this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1622. text = "";
  1623. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1624. }.bind(this), 3000);
  1625. }
  1626. else{// if currentplayer is greater than or equal to the length of users
  1627. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1628. if (currentplayer == joinusers.length){
  1629. var i;
  1630. for(i=0; i < 5; i += 1){
  1631.  
  1632. if (dealerstotal <= 14){
  1633.  
  1634. var rand = ~~(cards.length * Math.random());
  1635. var choosencard = cards[rand];
  1636. var actualcard = choosencard;
  1637. cards.splice(rand,1);
  1638.  
  1639. if (dealerstotal >= 11){
  1640.  
  1641. switch(choosencard){
  1642. case "A":
  1643. choosencard = 1;
  1644. actualcard += "(1)";
  1645. break;
  1646.  
  1647. case "J":
  1648. choosencard = 10;
  1649. actualcard += "(10)";
  1650. break;
  1651.  
  1652. case "Q":
  1653. choosencard = 10;
  1654. actualcard += "(10)";
  1655. break;
  1656.  
  1657. case "K":
  1658. choosencard = 10;
  1659. actualcard += "(10)";
  1660. break;
  1661. }
  1662. }
  1663.  
  1664.  
  1665. if (dealerstotal < 11){
  1666.  
  1667. switch(choosencard){
  1668. case "A":
  1669. numofaces += 1;
  1670. choosencard = 11;
  1671. actualcard += "(11)";
  1672. break;
  1673.  
  1674. case "J":
  1675. choosencard = 10;
  1676. actualcard += "(10)";
  1677. break;
  1678.  
  1679. case "Q":
  1680. choosencard = 10;
  1681. actualcard += "(10)";
  1682. break;
  1683.  
  1684. case "K":
  1685. choosencard = 10;
  1686. actualcard += "(10)";
  1687. break;
  1688. }
  1689. }
  1690.  
  1691.  
  1692. dealerstotal += choosencard;
  1693.  
  1694. if (dealerstotal > 21){
  1695. if (numofaces > 0){
  1696. dealerstotal -= 10;
  1697. numofaces -= 1
  1698. }}
  1699. }else{
  1700. break;
  1701. }
  1702. }
  1703.  
  1704.  
  1705. if (dealerstotal > 14 && dealerstotal <= 21){
  1706. var mytimer = setTimeout(function(){
  1707. text += "The dealer has got the total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  1708. this.say(room, text);
  1709. text = "";
  1710. }.bind(this), 3000);
  1711.  
  1712.  
  1713. var mytimer = setTimeout(function(){
  1714. var i;
  1715. var counter = 0;
  1716. var winners = [];
  1717. text += "Congratulations to our winner(s) "
  1718. for(i = 0; i < joinusers.length; i++){
  1719. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  1720. winners[winners.length] = joinusers[i];
  1721. counter += 1
  1722. }}
  1723.  
  1724. if (winners.length > 0){
  1725. var i;
  1726. for(i = 0;i < winners.length; i += 1){
  1727. if (i != winners.length-1){
  1728. text += winners[i]+","
  1729. }else{
  1730. text += winners[i]
  1731. }
  1732. }
  1733.  
  1734. this.say(room, text+"!");
  1735. game = "none";
  1736. started = false;
  1737. }
  1738. if (counter <=0){
  1739.  
  1740. this.say(room, "**Sorry there are no winners :C**");
  1741. game = "none";
  1742. started = false;
  1743. }
  1744.  
  1745. }.bind(this), 6000);
  1746. }
  1747.  
  1748.  
  1749. if (dealerstotal > 21){
  1750. var mytimer = setTimeout(function(){
  1751. text += "The dealer has busted with a total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  1752. this.say(room, text);
  1753. text = "";
  1754. dealerstotal = 0;
  1755. }.bind(this), 3000);
  1756.  
  1757.  
  1758. var mytimer = setTimeout(function(){
  1759. var i;
  1760. var counter = 0;
  1761. var winners = [];
  1762. text += "Congratulations to our winner(s) "
  1763. for(i = 0; i < joinusers.length; i++){
  1764. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  1765. winners[winners.length] = joinusers[i];
  1766. counter += 1
  1767. }}
  1768.  
  1769. if (winners.length > 0){
  1770. var i;
  1771. for(i = 0;i < winners.length; i += 1){
  1772. if (i != winners.length-1){
  1773. text += winners[i]+","
  1774. }else{
  1775. text += winners[i]
  1776. }
  1777. }
  1778.  
  1779. this.say(room, text+"!");
  1780. game = "none";
  1781. started = false;
  1782. }
  1783.  
  1784. if (counter <=0){
  1785.  
  1786. this.say(room, "**Sorry there are no winners :C**");
  1787. game = "none";
  1788. started = false;
  1789. }
  1790. }.bind(this), 6000);
  1791. }}
  1792. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1793. }
  1794.  
  1795. }}
  1796. }}}
  1797.  
  1798. },
  1799.  
  1800. 'stay': function (arg, user, room) {
  1801. if (room === user) return false;
  1802. var text = "";
  1803. var delay = 2000;
  1804. if (user.name == joinusers[currentplayer] || user.id == joinusersid[currentplayer]){
  1805. if (game == "blackjack"){
  1806. if (started == true) {
  1807.  
  1808. if (playerdata[currentplayer] == 21){
  1809. text += joinusers[currentplayer]+ " has got Blackjack."
  1810. this.say(room, text);
  1811. text = "";
  1812. }
  1813.  
  1814.  
  1815. currentplayer += 1;
  1816.  
  1817. if (currentplayer == joinusers.length){
  1818. text = ""
  1819. text += "**Everyone has finished. Its the dealers turn. Calculating......**"
  1820. this.say(room, text);
  1821. text = "";
  1822. }
  1823.  
  1824.  
  1825. if (currentplayer < joinusers.length){
  1826.  
  1827. var staytimer = setTimeout(function(){
  1828. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player/
  1829. var rand = (Math.round(Math.random()*(cards.length-1)));
  1830. var choosencard = cards[rand];
  1831. var actualcard = choosencard;
  1832. cards.splice(rand,1);
  1833.  
  1834.  
  1835. switch(choosencard){
  1836. case "A":
  1837. numofaces += 1;
  1838. choosencard = 11;
  1839. actualcard += "(11)";
  1840. break;
  1841.  
  1842. case "J":
  1843. choosencard = 10;
  1844. actualcard += "(10)";
  1845. break;
  1846.  
  1847. case "Q":
  1848. choosencard = 10;
  1849. actualcard += "(10)";
  1850. break;
  1851.  
  1852. case "K":
  1853. choosencard = 10;
  1854. actualcard += "(10)";
  1855. break;
  1856. }
  1857.  
  1858. playerdata[currentplayer] = choosencard;
  1859. text += joinusers[currentplayer] + "'s top card is "+actualcard;
  1860. this.say(room, text);
  1861. text = "";
  1862.  
  1863. text += joinusers[currentplayer] + " .hit or .stay";
  1864. this.say(room, text);
  1865. text = "";
  1866. /////////////////////////////////////////////////////////////////////Draws Random Card For First Player
  1867. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1868. var rand = (Math.round(Math.random()*(cards.length-1)));
  1869. var choosencard = cards[rand];
  1870. var actualcard = choosencard;
  1871. cards.splice(rand,1);
  1872.  
  1873. if (playerdata[currentplayer] >= 11){
  1874.  
  1875. switch(choosencard){
  1876. case "A":
  1877. choosencard = 1;
  1878. actualcard += "(1)";
  1879. break;
  1880.  
  1881. case "J":
  1882. choosencard = 10;
  1883. actualcard += "(10)";
  1884. break;
  1885.  
  1886. case "Q":
  1887. choosencard = 10;
  1888. actualcard += "(10)";
  1889. break;
  1890.  
  1891. case "K":
  1892. choosencard = 10;
  1893. actualcard += "(10)";
  1894. break;
  1895. }
  1896. }
  1897.  
  1898.  
  1899. if (playerdata[currentplayer] < 11){
  1900.  
  1901. switch(choosencard){
  1902. case "A":
  1903. numofaces += 1;
  1904. choosencard = 11;
  1905. actualcard += "(11)";
  1906. break;
  1907.  
  1908. case "J":
  1909. choosencard = 10;
  1910. actualcard += "(10)";
  1911. break;
  1912.  
  1913. case "Q":
  1914. choosencard = 10;
  1915. actualcard += "(10)";
  1916. break;
  1917.  
  1918. case "K":
  1919. choosencard = 10;
  1920. actualcard += "(10)";
  1921. break;
  1922. }
  1923. }
  1924.  
  1925.  
  1926. playerdata[currentplayer] += choosencard;
  1927.  
  1928. if (playerdata[currentplayer] > 21){
  1929. if (numofaces > 0){
  1930. playerdata[currentplayer] -= 10;
  1931. numofaces -= 1
  1932. }}
  1933.  
  1934. text = "";
  1935. text += "You got a "+actualcard;
  1936. this.say(room,"/pm " +joinusersid[currentplayer]+","+text);
  1937. return this.say(room,"/pm " +joinusersid[currentplayer]+","+"Your Total = "+playerdata[currentplayer]);
  1938. text = "";
  1939. /////////////////////////////////////////////////////////////////////////////////////PM RANDOM CARD
  1940. }.bind(this), 3000);
  1941. }
  1942. else{ // if currentplayer is greater than or equal to the length of users
  1943.  
  1944. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1945. if (currentplayer == joinusers.length){
  1946. var i;
  1947. for(i=0; i < 5; i += 1){
  1948.  
  1949. if (dealerstotal <= 14){
  1950.  
  1951. var rand = ~~(cards.length * Math.random());
  1952. var choosencard = cards[rand];
  1953. var actualcard = choosencard;
  1954. cards.splice(rand,1);
  1955.  
  1956. if (dealerstotal >= 11){
  1957.  
  1958. switch(choosencard){
  1959. case "A":
  1960. choosencard = 1;
  1961. actualcard += "(1)";
  1962. break;
  1963.  
  1964. case "J":
  1965. choosencard = 10;
  1966. actualcard += "(10)";
  1967. break;
  1968.  
  1969. case "Q":
  1970. choosencard = 10;
  1971. actualcard += "(10)";
  1972. break;
  1973.  
  1974. case "K":
  1975. choosencard = 10;
  1976. actualcard += "(10)";
  1977. break;
  1978. }
  1979. }
  1980.  
  1981.  
  1982. if (dealerstotal < 11){
  1983.  
  1984. switch(choosencard){
  1985. case "A":
  1986. numofaces += 1;
  1987. choosencard = 11;
  1988. actualcard += "(11)";
  1989. break;
  1990.  
  1991. case "J":
  1992. choosencard = 10;
  1993. actualcard += "(10)";
  1994. break;
  1995.  
  1996. case "Q":
  1997. choosencard = 10;
  1998. actualcard += "(10)";
  1999. break;
  2000.  
  2001. case "K":
  2002. choosencard = 10;
  2003. actualcard += "(10)";
  2004. break;
  2005. }
  2006. }
  2007.  
  2008.  
  2009. dealerstotal += choosencard;
  2010.  
  2011. if (dealerstotal > 21){
  2012. if (numofaces > 0){
  2013. dealerstotal -= 10;
  2014. numofaces -= 1
  2015. }}
  2016. }else{
  2017. break;
  2018. }
  2019. }
  2020.  
  2021.  
  2022. if (dealerstotal > 14 && dealerstotal <= 21){
  2023. var mytimer = setTimeout(function(){
  2024. text += "The dealer has got the total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  2025. this.say(room, text);
  2026. text = "";
  2027. }.bind(this), 3000);
  2028.  
  2029.  
  2030. var mytimer = setTimeout(function(){
  2031. var i;
  2032. var counter = 0;
  2033. var winners = [];
  2034. text += "Congratulations to our winner(s) "
  2035. for(i = 0; i < joinusers.length; i++){
  2036. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  2037. winners[winners.length] = joinusers[i];
  2038. counter += 1
  2039. }}
  2040.  
  2041. if (winners.length > 0){
  2042. var i;
  2043. for(i = 0;i < winners.length; i += 1){
  2044. if (i != winners.length-1){
  2045. text += winners[i]+","
  2046. }else{
  2047. text += winners[i]
  2048. }
  2049. }
  2050.  
  2051. this.say(room, text+"!");
  2052. game = "none";
  2053. started = false;
  2054. }
  2055. if (counter <=0){
  2056.  
  2057. this.say(room, "**Sorry there are no winners :C**");
  2058. game = "none";
  2059. started = false;
  2060. }
  2061.  
  2062. }.bind(this), 6000);
  2063. }
  2064.  
  2065.  
  2066. if (dealerstotal > 21){
  2067. var mytimer = setTimeout(function(){
  2068. text += "The dealer has busted with a total of " +"**"+dealerstotal+"**" + ". Calculating winners....";
  2069. this.say(room, text);
  2070. text = "";
  2071. dealerstotal = 0;
  2072. }.bind(this), 3000);
  2073.  
  2074.  
  2075. var mytimer = setTimeout(function(){
  2076. var i;
  2077. var counter = 0;
  2078. var winners = [];
  2079. text += "Congratulations to our winner(s) "
  2080. for(i = 0; i < joinusers.length; i++){
  2081. if (playerdata[i] >= dealerstotal && playerdata[i] <= 21){
  2082. winners[winners.length] = joinusers[i];
  2083. counter += 1
  2084. }}
  2085.  
  2086. if (winners.length > 0){
  2087. var i;
  2088. for(i = 0;i < winners.length; i += 1){
  2089. if (i != winners.length-1){
  2090. text += winners[i]+","
  2091. }else{
  2092. text += winners[i]
  2093. }
  2094. }
  2095.  
  2096. this.say(room, text+"!");
  2097. game = "none";
  2098. started = false;
  2099. }
  2100.  
  2101. if (counter <=0){
  2102.  
  2103. this.say(room, "**Sorry there are no winners :C**");
  2104. game = "none";
  2105. started = false;
  2106. }
  2107. }.bind(this), 6000);
  2108. }}
  2109. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2110.  
  2111. }
  2112.  
  2113. }}}
  2114.  
  2115. },
  2116. //////////////Black Jack///////////////////
  2117. //////////////Ambush///////////////////////
  2118. kill: 'fire',
  2119. 'fire': function (arg, user, room) {
  2120. if (room === user) return false;
  2121. if (game != "ambush") return false;
  2122. if (started == false) return false;
  2123. var text = "";
  2124. var userin = false;
  2125. var i;
  2126. var bullets;
  2127. var playerid;
  2128. for(i = 0; i< joinusers.length; i+=1){
  2129. if (user.name == joinusers[i] || user.id == joinusersid[i]){
  2130. userin = true;
  2131. bullets = playerdata[i];
  2132. playerid = i;
  2133. break;
  2134. }
  2135. }
  2136. if (userin == true){
  2137. if (checked == true){
  2138.  
  2139. if (bullets > 0){
  2140. playerdata[playerid] -= 1;
  2141. }}else{
  2142. var usershotin;
  2143. var usertokill;
  2144. for(i = 0; i< joinusers.length; i+=1){
  2145. if (arg.toLowerCase() == joinusers[i].toLowerCase() || arg.toLowerCase() == joinusersid[i].toLowerCase()){
  2146. usershotin = true;
  2147. usertokill = i;
  2148. break;
  2149. }
  2150. }
  2151. if (usershotin == true){
  2152. if (bullets > 0){
  2153. var safe = false;
  2154. for(i = 0; i < safeusers.length;i += 2){
  2155. if (arg.toLowerCase() == safeusers[i].toLowerCase() || arg.toLowerCase() == safeusers[i+1].toLowerCase()){
  2156. safe = true;
  2157. }}
  2158. clearInterval(active);
  2159. turnspassed = 0;
  2160. if (safe == false){
  2161. joinusers.splice(usertokill,1);
  2162. joinusersid.splice(usertokill,1);
  2163. safeusers[safeusers.length] = user.name;
  2164. safeusers[safeusers.length] = user.id;
  2165. text += "/pm " + arg+",Sorry you lost. Better luck next time. ( ͡° ͜ʖ ͡°)";
  2166. this.say(room, text);
  2167. text = "";
  2168. }
  2169. }else{return false;}
  2170.  
  2171. if (joinusers.length <= 1){
  2172. clearInterval(active);
  2173. text += "Congratulations to our winner "+joinusers[0]+"!";
  2174. this.say(room, text);
  2175. text = "";
  2176. game = "none";
  2177. started = false;
  2178. requiredPlayers = 0;
  2179. }
  2180. else{
  2181. var i;
  2182. for(i=0;i < joinusers.length; i+=1){
  2183. playerdata[i] = 2;
  2184. }
  2185.  
  2186. clearTimeout(starttimer);
  2187. starttimer = setTimeout(function(){
  2188. for(i = 0; i < joinusers.length; i +=1){
  2189. if (i == joinusers.length-1){
  2190. text += joinusers[i]+"! Get ready!";
  2191. }
  2192. if (i == joinusers.length - 2){
  2193. text += joinusers[i]+" and ";
  2194. }
  2195. if (i != joinusers.length -1 && i != joinusers.length - 2){
  2196. text += joinusers[i]+",";
  2197. }
  2198. }
  2199. text = "**"+text+"**";
  2200. this.say(room, text);
  2201. text = "";
  2202.  
  2203. checked = true;
  2204. safeusers = [];
  2205. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  2206. clearTimeout(firetimer);
  2207. firetimer = setTimeout(function(){
  2208. text = "**FIRE!**";
  2209. this.say(room, text);
  2210. checked = false;
  2211. text = "";;
  2212. }.bind(this), delaytime);
  2213.  
  2214.  
  2215. active = setInterval(function(){
  2216. turnspassed +=1
  2217. if (turnspassed < 3){
  2218. text = "";
  2219. var starttimer = setTimeout(function(){
  2220. for(i = 0; i < joinusers.length; i +=1){
  2221. if (i == joinusers.length-1){
  2222. text += joinusers[i]+"! Get ready!";
  2223. }
  2224. if (i == joinusers.length - 2){
  2225. text += joinusers[i]+" and ";
  2226. }
  2227. if (i != joinusers.length -1 && i != joinusers.length - 2){
  2228. text += joinusers[i]+",";
  2229. }
  2230. }
  2231. text = "**"+text+"**";
  2232. this.say(room, text);
  2233. text = "";
  2234.  
  2235.  
  2236.  
  2237. checked = true;
  2238. safeusers = [];
  2239. var delaytime = Math.round(Math.floor(Math.random() * (13000 -7000) + 7000));
  2240. var firetimer = setTimeout(function(){
  2241. text = "**FIRE!**";
  2242. this.say(room, text);
  2243. checked = false;
  2244. text = "";
  2245. //clearInterval(active);
  2246. active;
  2247.  
  2248. }.bind(this), delaytime);
  2249.  
  2250. }.bind(this), 4000);
  2251. }else{
  2252.  
  2253. text = "A Greninja came out of no where and use water shuriken on everyone. RIP!!! **The game has ended due to inactivity**";
  2254. this.say(room, text);
  2255. text = "";
  2256. clearInterval(active);
  2257. game = "none";
  2258. started = false;
  2259. requiredPlayers = 0;
  2260. turnspassed = 0;
  2261.  
  2262. }
  2263. }.bind(this), 20000);
  2264.  
  2265. }.bind(this), 4000);
  2266. }
  2267. }else{
  2268. return false;
  2269. }
  2270. }
  2271. }
  2272. },
  2273. //////////////Ambush///////////////////////
  2274. //////////////Team Trivia/////////////////
  2275. tta: 'teamtriviaanswer',
  2276. teamtriviaanswer: function(arg, user, room){
  2277. if(room.id !== triviaRoom) return false;
  2278. if (game !== "ttrivia") return false;
  2279. if (started != true) return false;
  2280. if (!arg) return false;
  2281. arg = (arg);
  2282. var i;
  2283. var gotteam = false;
  2284. var theuser;
  2285.  
  2286. for(i = 0 ;i < teamOne.length;i+=1){
  2287. if (gotteam == true){break;}
  2288. if(user.name == teamOne[i]){
  2289. theuser = "Team Ash";
  2290. gotteam = true;
  2291. break;
  2292. }
  2293. }
  2294.  
  2295. for(i = 0 ;i < teamTwo.length;i+=1){
  2296. if (gotteam == true){break;}
  2297. if(user.name == teamTwo[i]){
  2298. theuser = "Team Conbeef";
  2299. gotteam = true;
  2300. break;
  2301. }
  2302. }
  2303.  
  2304.  
  2305. if(arg == triviaA){
  2306. if (triviaPoints.indexOf(theuser) > -1){
  2307. triviaA = '';
  2308. triviaPoints[triviaPoints.indexOf(theuser) + 1] += 1;
  2309. if (triviaPoints[triviaPoints.indexOf(theuser) + 1] >= 10) {
  2310. clearInterval(triviaTimer);
  2311. this.say( room, '**Congrats to ' + theuser + ' for winning Trivia!**');
  2312. this.say(room,'/pm '+ user.name + ' ,**Congratulations** on winning the game of Team Trivia.')
  2313. //this.say(room,'/msg lustrousash,' + user.name + ' have been awarded **2 Points** for winning trivia')
  2314. triviaON = false;
  2315. game = "none";
  2316. started = false;
  2317. requiredPlayers = 0;
  2318. return false;
  2319. }
  2320. this.say(room,'**' + user.name + '** got the right answer,' +"**"+theuser+"**"+ ' has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoints!');
  2321. } else {
  2322. triviaA = '';
  2323. triviaPoints[triviaPoints.length] = theuser;
  2324. triviaPoints[triviaPoints.length] = 1;
  2325. this.say(room,'**' + user.name + '** got the right answer,' +"**"+theuser+"**"+ ' has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoint!');
  2326. }
  2327. }
  2328. },
  2329. ////////////////Team Trivia///////////////
  2330. ////////////////Old Rod//////////////////
  2331. pull: 'reel',
  2332. 'reel': function (arg, user, room) {
  2333. if (room === user) return false;
  2334. if (game != "oldrod") return false;
  2335. if (started == false) return false;
  2336. if (dealerstotal == 1) return false;
  2337. var text = "";
  2338. var userin = false;
  2339. var i;
  2340. var playerid;
  2341. for(i = 0; i< joinusers.length; i+=1){
  2342. if (user.name == joinusers[i] || user.id == joinusersid[i]){
  2343. userin = true;
  2344. playerid = i;
  2345. break;
  2346. }
  2347. }
  2348.  
  2349. if (userin == false){return false;}else{
  2350. if (checked == true){
  2351. if (playerdata[playerid] != 0){
  2352. if (playerdata[playerid] >= 30){
  2353. safeusers[i] = 0;
  2354. return playerdata[playerid] -= 30;
  2355. }else{
  2356. safeusers[playerid] = 0;
  2357. playerdata[playerid] = 0;
  2358. }
  2359. }
  2360. }else{
  2361.  
  2362.  
  2363. if (safeusers[playerid] == 1){
  2364. dealerstotal = 1;
  2365. checked = true;
  2366. var randd = Math.round((Math.random()*(waterpoke.length-1-0)+0)/2)*2;
  2367. var chosenpoke = waterpoke[randd]
  2368. var addpoints = waterpoke[randd+1]
  2369.  
  2370. playerdata[playerid] += addpoints;
  2371. text = joinusers[playerid] + " caught a "+chosenpoke+"(" +addpoints+").";
  2372. this.say(room, text);
  2373. text = "";
  2374.  
  2375. }
  2376.  
  2377. rounds += 1;
  2378. clearTimeout(active);
  2379. for(i = 0; i < joinusers.length; i +=1){
  2380. safeusers[i] = 1;
  2381. }
  2382.  
  2383. if (rounds != 10){
  2384.  
  2385.  
  2386. var starttimer = setTimeout(function(){
  2387.  
  2388. for(i = 0; i < joinusers.length; i +=1){
  2389.  
  2390. if (i == joinusers.length-1){
  2391. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  2392. }
  2393.  
  2394. if (i == joinusers.length - 2){
  2395. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  2396. }
  2397.  
  2398. if (i != joinusers.length -1 && i != playerdata.length - 2){
  2399. text += joinusers[i]+"("+playerdata[i]+")"+",";
  2400. }
  2401.  
  2402. }
  2403. text = "**"+text+"**";
  2404. this.say(room,"Round "+rounds+"!"+ text);
  2405. text = "";
  2406.  
  2407. checked = true;
  2408. dealerstotal = 0;
  2409. var times = 0;
  2410. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","not even a nibble.","!","!","!"];
  2411. var reeltimer = setTimeout(function(){
  2412.  
  2413. active = setInterval(function(){
  2414.  
  2415. times += 1;
  2416.  
  2417. if (times < 2){
  2418. this.say(room, "**...**");
  2419. active;
  2420. }
  2421.  
  2422. if (times >= 3){
  2423.  
  2424. var rand = (Math.round(Math.random()*(randpull.length-1)));
  2425. var pick = randpull[rand];
  2426.  
  2427. if (pick == "..."){
  2428. this.say(room, "**...**");
  2429. randpull.splice(0,4)
  2430. }
  2431.  
  2432. if (pick == "!"){
  2433. this.say(room, "**!**");
  2434. clearInterval(active);
  2435. checked = false;
  2436.  
  2437. active = setTimeout(function(){
  2438. game = "none";
  2439. started = false;
  2440. requiredPlayers = 0;
  2441. clearInterval(active);
  2442. text = "";
  2443. text += "The Rod has broken. **Game ended due to inactivity.**";
  2444. return this.say(room, text);
  2445. }.bind(this), 60000);
  2446.  
  2447. }
  2448.  
  2449. if (pick == "not even a nibble."){
  2450. this.say(room, "**not even a nibble.**");
  2451.  
  2452. rounds += 1;
  2453. clearTimeout(active);
  2454. for(i = 0; i < joinusers.length; i +=1){
  2455. safeusers[i] = 1;
  2456. }
  2457.  
  2458. if (rounds < 10){
  2459.  
  2460.  
  2461. var starttimerr = setTimeout(function(){
  2462.  
  2463.  
  2464. for(i = 0; i < joinusers.length; i +=1){
  2465.  
  2466. if (i == joinusers.length-1){
  2467. text += joinusers[i]+"("+playerdata[i]+")"+"! Get ready to fish!";
  2468. }
  2469.  
  2470. if (i == joinusers.length - 2){
  2471. text += joinusers[i]+"("+playerdata[i]+")"+" and ";
  2472. }
  2473.  
  2474. if (i != joinusers.length -1 && i != playerdata.length - 2){
  2475. text += joinusers[i]+"("+playerdata[i]+")"+",";
  2476. }
  2477.  
  2478. }
  2479. text = "**"+text+"**";
  2480. this.say(room,"Round "+rounds+"!"+ text);
  2481. text = "";
  2482.  
  2483. checked = true;
  2484. dealerstotal = 0;
  2485. var times = 0;
  2486. var randpull = ["...","...","...","...","...","...","...","...","...","...","...","...","!","!","!","!","!"];
  2487. var reeltimer = setTimeout(function(){
  2488.  
  2489. active = setInterval(function(){
  2490.  
  2491. times += 1;
  2492.  
  2493. if (times < 2){
  2494. this.say(room, "**...**");
  2495. active;
  2496. }
  2497.  
  2498. if (times >= 3){
  2499.  
  2500. var rand = (Math.round(Math.random()*(randpull.length-1)));
  2501. var pick = randpull[rand];
  2502.  
  2503. if (pick == "..."){
  2504. this.say(room, "**...**");
  2505. randpull.splice(0,4)
  2506. }
  2507.  
  2508. if (pick == "!"){
  2509. this.say(room, "**!**");
  2510. clearInterval(active);
  2511. checked = false;
  2512.  
  2513. active = setTimeout(function(){
  2514. game = "none";
  2515. started = false;
  2516. requiredPlayers = 0;
  2517. clearInterval(active);
  2518. text = "";
  2519. text += "The Rod has broken. **Game ended due to inactivity.**";
  2520. return this.say(room, text);
  2521. }.bind(this), 60000);
  2522.  
  2523. }
  2524.  
  2525. }
  2526.  
  2527. }.bind(this), 1500);
  2528.  
  2529. }.bind(this), 4000);
  2530.  
  2531. }.bind(this), 2000);
  2532.  
  2533.  
  2534.  
  2535. }else{
  2536. var maxtotal = 0;
  2537. var winners = [];
  2538.  
  2539. for(i = 0;i < joinusers.length; i+= 1){
  2540.  
  2541. if (maxtotal < playerdata[i]){
  2542. maxtotal = playerdata[i];
  2543. winners = [];
  2544. }
  2545.  
  2546. if (maxtotal == playerdata[i]){
  2547. winners[winners.length] = joinusers[i]
  2548. }
  2549.  
  2550. }
  2551.  
  2552. if (winners.length > 0){
  2553. var i;
  2554. for(i = 0;i < winners.length; i += 1){
  2555. if (i != winners.length-1){
  2556. text += winners[i]+","
  2557. }else{
  2558. text += winners[i]
  2559. }
  2560. }
  2561.  
  2562. this.say(room,"Congrats to our winner(s) "+ text+"!");
  2563. game = "none";
  2564. started = false;
  2565. }else{
  2566.  
  2567. this.say(room,"Sorry there are no winners. :c");
  2568. game = "none";
  2569. started = false;
  2570.  
  2571. }
  2572. }
  2573. }
  2574. }
  2575.  
  2576.  
  2577.  
  2578. }.bind(this), 1500);
  2579.  
  2580. }.bind(this), 4000);
  2581.  
  2582. }.bind(this), 2000);
  2583.  
  2584.  
  2585. }else{
  2586.  
  2587. var maxtotal = 0;
  2588. var winners = [];
  2589.  
  2590. for(i = 0;i < joinusers.length; i+= 1){
  2591.  
  2592. if (maxtotal < playerdata[i]){
  2593. maxtotal = playerdata[i];
  2594. winners = [];
  2595. }
  2596.  
  2597. if (maxtotal == playerdata[i]){
  2598. winners[winners.length] = joinusers[i]
  2599. }
  2600.  
  2601. }
  2602.  
  2603. if (winners.length > 0){
  2604. var i;
  2605. for(i = 0;i < winners.length; i += 1){
  2606. if (i != winners.length-1){
  2607. text += winners[i]+","
  2608. }else{
  2609. text += winners[i]
  2610. }
  2611. }
  2612.  
  2613. this.say(room,"Congrats to our winner(s) "+ text+"!");
  2614. game = "none";
  2615. started = false;
  2616. }else{
  2617.  
  2618. this.say(room,"Sorry there are no winners. :c");
  2619. game = "none";
  2620. started = false;
  2621.  
  2622. }}
  2623.  
  2624. }}
  2625. },
  2626. /////////////////////////////////////////////////OLD ROD/////////////////////////////////////
  2627. };
Add Comment
Please, Sign In to add comment