Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Panagrams. Do not use yet, the anagram function has to be implemented first.
- panagram: function(target, room, user) {
- if (!this.can('broadcast')) return false;
- if (room.panagram) return this.sendReply('There is already a game of Panagram going on.');
- /******* Start *******/
- /* var pokedex = [];
- for (var i in Tools.data.Pokedex) {
- if (Tools.data.Pokedex[i].num > 0) {
- pokedex.push(i); // This is pushing the index value...
- }
- }
- var poke = pokedex[Math.floor(Math.random() * pokedex.length)]; // This I believe is picking a number, not a name.
- */
- /******* End *******/
- /* This whole thing could be replaced with
- var poke = Tools.data.Pokedex[Math.floor(Math.random() * Tools.data.Pokedex.length)]; ? This picks a name, not a number.
- This is assuming Tools.data.Pokedex is an array of the pokemon names.
- As it seems you are caching the pokedex which doesn't need to be done.
- It causes the for loop to run 719 times.
- If you're going to cache the pokedex, then use pokedex instead of Tool.data.Pokedex in later code (which will reduce processing).
- */
- var panagram = this.anagram(poke);
- //^^^^^^^ Following my understanding, this is rearranging numbers, not a pokemon when name using your method.
- var mixedup = panagram[Math.floor(Math.random() * panagram.length)];
- // Doesn't anagram already mix it up? So why the extra mixup?
- /***** The rest looks fine *******/
- this.add('|html|<div class = "infobox"><center><b>A game of Panagram has been started!</b><br/>' +
- 'The scrambled word is <b>' + mixedup + '</b><br/>' +
- '<font size = 1>Type in <b>/guessp or /guesspoke [pokemon]</b> to guess the pokemon!');
- room.panagram = {};
- room.panagram.guessed = [];
- room.panagram.chances = 2;
- room.panagram.answer = toId(poke);
- },
- guesspoke: 'guessp',
- guessp: function(target, room, user, cmd) {
- if (!room.panagram) return this.sendReply('There is no game of Panagram going on in this room.');
- if (room.panagram[user.userid]) return this.sendReply("You've already guessed once!");
- if (!target) return this.sendReply("The proper syntax is /guessp [pokemon]");
- if (!Tools.data.Pokedex[toId(target)]) return this.sendReply("'" + target + "' is not a valid pokemon.");
- if (Tools.data.Pokedex[toId(target)].num < 1) return this.sendReply(Tools.data.Pokedex[toId(target)] + ' is either an illegal or a CAP Pokemon. These Pokemon are not used in Panagrams.');
- if (room.panagram.guessed.indexOf(toId(target)) > -1) return this.sendReply("That Pokemon has already been guessed!");
- if (room.panagram.answer == toId(target)) {
- this.add('|html|<b>' + user.name + '</b> guessed <b>' + Tools.data.Pokedex[toId(target)].species + '</b>, which was the correct answer! Congratulations!');
- delete room.panagram;
- } else {
- if (room.panagram.chances > 0) {
- this.add('|html|<b>' + user.name + '</b> guessed <b>' + Tools.data.Pokedex[toId(target)].species + '</b>, but was not the correct answer...');
- room.panagram[user.userid] = toId(target);
- room.panagram.guessed.push(toId(target));
- room.panagram.chances--;
- } else {
- this.add('|html|<b>' + user.name + '</b> guessed <b>' + Tools.data.Pokedex[toId(target)].species + '</b>, but was not the correct answer. You have failed to guess the Pokemon, which was <b>' + Tools.data.Pokedex[room.panagram.answer].species + '</b>');
- delete room.panagram;
- }
- }
- },
- panagramend: 'endpanagram',
- endpanagram: function(target, room, user) {
- if (!room.panagram) return this.sendReply('There is no panagram game going on in this room yet.');
- this.add("|html|<b>The game of Panagram has been ended.</b>");
- delete room.panagram;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement