Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var status;
- // These are the maps available for JQ.
- var maps = [100000000,101000000,102000000,103000000];
- var points = [1,2,3,4];
- // This array gets pushed with a chosen map's name
- var selections = [];
- // Return map id
- var returnMap = 910000000;
- var choosing = null;
- var playList = false;
- function start() {
- status = -1;
- var getJQ = cm.getPlayer().getJQ();
- if (getJQ == null) {
- // cm.sendSimple("Hey, #e#h ##n! I'm the JQ manager. What do you want to do?\r\n" +
- // "\t\t\t\t\t#L100##bPlaylist\t\t#L101#Random#k\r\n\r\n\r\n\t\t\t\t#lForget the special modes! I want vanilla!\r\n" + sendMaps());
- cm.sendSimple("Which JQ would you like to attempt? You currently have #b"+cm.getPlayer().getJQPoints()+"#k JQ points.\r\n\r\n#b#L101#Random JQ\r\n#L100#Start a playlist\r\n" + sendMaps());
- } else {
- var notFinished = !getJQ.checkFinished();
- if (notFinished) {
- if (cm.getParty() != null)
- cm.warpParty(maps[getJQ.getNextMap()]);
- else
- cm.warp(maps[getJQ.getNextMap()]);
- }
- cm.print(getJQ.getCurrentMap());
- cm.getPlayer().yellowMessage("You have gained " +
- points[getJQ.getCurrentMap()] + " JQ points!");
- cm.getPlayer().gainJQPoints(points[getJQ.getCurrentMap()]);
- getJQ.advanceStage();
- cm.dispose();
- }
- }
- function action(m,t,s) {
- if (m != 1) {
- cm.dispose();
- return;
- }
- status++;
- if (status == 0) {
- // Playlist
- if (s == 102) {
- cm.dispose();
- } else if (s == 100 || playList) {
- playList = true;
- text = "These are your currently selected maps:\r\n\t\t#b" + sendMapNames(false).join(", ") + "\r\n\r\n";
- text += "#kWhat maps do you wish to add to your playlist?\r\n" + sendMaps();
- text += "#e\r\n#L501#Clear current selections\r\n";
- text += "#L1000#Delete a selection\r\n";
- text += "#L1001#Shuffle playlist\r\n"
- text += "#L500#Start the JQ!";
- cm.sendSimple(text);
- } else {
- selections.push(s == 101 ? Math.floor(Math.random() * maps.length) : s);
- text = s == 101 ? "You have been given a #d#erandom map#n#k to play on." : "You have selected " +
- "#e#d#m" + maps[s] + "##k#n as your current map.";
- cm.sendSimple(text + "\r\n\r\n\t\t#L500#Enter JQ\t\t#L502#View Rankings");
- }
- } else if (status == 1) {
- if (s == 500) {
- if (selections.length > 0) {
- if (cm.getParty() != null)
- cm.warpParty(maps[selections[0]]);
- else
- cm.warp(maps[selections[0]]);
- cm.startJumpQuest(selections, returnMap);
- cm.dispose();
- } else {
- cm.sendOk("You cannot start a JQ when you have no maps chosen!");
- cm.dispose();
- }
- } else if (s==1001) {
- cm.sendNext("Your list has been shuffled!");
- shuffle();
- status = -1;
- } else if (s == 1000) {
- if (selections.length == 0) {
- cm.sendNext("You currently have no selected maps!")
- status = -1;
- } else {
- cm.sendSimple("What maps do you wish to delete from your playlist?\r\n\r\n#b" +
- sendMapNames(true));
- }
- } else if (s == 502) {
- cm.sendOk("\t\t\t\t\t\t\t#eRankings for #b#m"+maps[selections[0]]+"##k#n\r\n\r\n" + cm.getRankings(maps[selections[0]]));
- cm.dispose();
- } else if (s == 501) {
- cm.sendNext("Your current playlist has been cleared.");
- selections = [];
- status = -1;
- } else if (playList) {
- cm.sendNext("You've chosen #b#m " + maps[s] + "##k as a JQ map.");
- selections.push(s);
- status = -1;
- }
- } else if (status == 2) {
- cm.sendNext("You have removed #b#m" + maps[s] + "##k from your playlist.");
- selections.splice(selections.indexOf(s), 1);
- status = -1;
- }
- }
- function sendMaps() {
- text = "";
- for (x = 0; x < maps.length; x++) {
- if (selections.indexOf(x) < 0)
- text += "#L"+x+"##m"+maps[x]+"# ("+points[x]+" "+(points[x]== 1 ? "point" : "points")+")\r\n";
- }
- return text;
- }
- function sendMapNames(deletion) {
- var mapNames = [];
- var text = "";
- for (var x = 0; x < selections.length; x++) {
- if (!deletion)
- mapNames.push("#m"+maps[selections[x]]+"#");
- else
- text += "#L"+selections[x]+"##m"+maps[selections[x]]+"#\r\n";
- }
- return deletion ? text : mapNames;
- }
- function shuffle() {
- var currentIndex = selections.length, temporaryValue, randomIndex ;
- // While there remain elements to shuffle...
- while (0 !== currentIndex) {
- // Pick a remaining element...
- randomIndex = Math.floor(Math.random() * currentIndex);
- currentIndex -= 1;
- // And swap it with the current element.
- temporaryValue = selections[currentIndex];
- selections[currentIndex] = selections[randomIndex];
- selections[randomIndex] = temporaryValue;
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement