diff --git a/bot2022.db/000082.log b/bot2022.db/000082.log new file mode 100644 index 0000000..17c922f Binary files /dev/null and b/bot2022.db/000082.log differ diff --git a/bot2022.db/000083.ldb b/bot2022.db/000083.ldb new file mode 100644 index 0000000..9c5aa61 Binary files /dev/null and b/bot2022.db/000083.ldb differ diff --git a/bot2022.db/000399.log b/bot2022.db/000399.log deleted file mode 100644 index eb9ef6c..0000000 Binary files a/bot2022.db/000399.log and /dev/null differ diff --git a/bot2022.db/000401.ldb b/bot2022.db/000401.ldb deleted file mode 100644 index e6abd38..0000000 Binary files a/bot2022.db/000401.ldb and /dev/null differ diff --git a/bot2022.db/CURRENT b/bot2022.db/CURRENT index 0884887..e73ded3 100644 --- a/bot2022.db/CURRENT +++ b/bot2022.db/CURRENT @@ -1 +1 @@ -MANIFEST-000386 +MANIFEST-000080 diff --git a/bot2022.db/LOG b/bot2022.db/LOG index 7b3b493..3c6ce1f 100644 --- a/bot2022.db/LOG +++ b/bot2022.db/LOG @@ -1,47 +1,13 @@ -2022/01/13-21:24:02.528757 7f68c0c86700 Recovering log #384 -2022/01/13-21:24:02.541876 7f68c0c86700 Level-0 table #387: started -2022/01/13-21:24:02.582419 7f68c0c86700 Level-0 table #387: 29147 bytes OK -2022/01/13-21:24:02.592320 7f68c0c86700 Delete type=0 #384 -2022/01/13-21:24:02.593583 7f68c0c86700 Delete type=3 #382 -2022/01/13-22:59:42.183462 7f68a37fe700 Compacting 1@0 + 1@1 files -2022/01/13-22:59:42.201472 7f68a37fe700 Generated table #389@0: 113 keys, 7871 bytes -2022/01/13-22:59:42.201511 7f68a37fe700 Compacted 1@0 + 1@1 files => 7871 bytes -2022/01/13-22:59:42.204516 7f68a37fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/13-22:59:42.204748 7f68a37fe700 Delete type=2 #385 -2022/01/13-22:59:42.204914 7f68a37fe700 Delete type=2 #387 -2022/01/14-10:58:56.588572 7f68a37fe700 Level-0 table #391: started -2022/01/14-10:58:56.779373 7f68a37fe700 Level-0 table #391: 421500 bytes OK -2022/01/14-10:58:56.806257 7f68a37fe700 Delete type=0 #388 -2022/01/14-14:10:03.261091 7f68a37fe700 Compacting 1@0 + 1@1 files -2022/01/14-14:10:03.302932 7f68a37fe700 Generated table #392@0: 135 keys, 9948 bytes -2022/01/14-14:10:03.302953 7f68a37fe700 Compacted 1@0 + 1@1 files => 9948 bytes -2022/01/14-14:10:03.306403 7f68a37fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/14-14:10:03.306839 7f68a37fe700 Delete type=2 #391 -2022/01/14-14:10:03.308757 7f68a37fe700 Delete type=2 #389 -2022/01/15-00:33:21.126357 7f68a37fe700 Level-0 table #394: started -2022/01/15-00:33:21.230438 7f68a37fe700 Level-0 table #394: 415933 bytes OK -2022/01/15-00:33:21.238870 7f68a37fe700 Delete type=0 #390 -2022/01/15-03:04:03.667912 7f68a37fe700 Compacting 1@0 + 1@1 files -2022/01/15-03:04:03.756490 7f68a37fe700 Generated table #395@0: 147 keys, 11442 bytes -2022/01/15-03:04:03.756517 7f68a37fe700 Compacted 1@0 + 1@1 files => 11442 bytes -2022/01/15-03:04:03.783080 7f68a37fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/15-03:04:03.783421 7f68a37fe700 Delete type=2 #394 -2022/01/15-03:04:03.784455 7f68a37fe700 Delete type=2 #392 -2022/01/15-14:23:03.305012 7f68a37fe700 Level-0 table #397: started -2022/01/15-14:23:03.429225 7f68a37fe700 Level-0 table #397: 415900 bytes OK -2022/01/15-14:23:03.435599 7f68a37fe700 Delete type=0 #393 -2022/01/15-18:10:04.413621 7f68a37fe700 Compacting 1@0 + 1@1 files -2022/01/15-18:10:04.430980 7f68a37fe700 Generated table #398@0: 163 keys, 13251 bytes -2022/01/15-18:10:04.431011 7f68a37fe700 Compacted 1@0 + 1@1 files => 13251 bytes -2022/01/15-18:10:04.476243 7f68a37fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/15-18:10:04.476482 7f68a37fe700 Delete type=2 #395 -2022/01/15-18:10:04.476944 7f68a37fe700 Delete type=2 #397 -2022/01/16-04:14:07.311026 7f68a37fe700 Level-0 table #400: started -2022/01/16-04:14:07.361543 7f68a37fe700 Level-0 table #400: 416810 bytes OK -2022/01/16-04:14:07.365780 7f68a37fe700 Delete type=0 #396 -2022/01/16-06:54:43.512802 7f68a37fe700 Compacting 1@0 + 1@1 files -2022/01/16-06:54:43.595202 7f68a37fe700 Generated table #401@0: 177 keys, 14527 bytes -2022/01/16-06:54:43.595227 7f68a37fe700 Compacted 1@0 + 1@1 files => 14527 bytes -2022/01/16-06:54:43.614608 7f68a37fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/16-06:54:43.615190 7f68a37fe700 Delete type=2 #400 -2022/01/16-06:54:43.615725 7f68a37fe700 Delete type=2 #398 +2022/01/16-13:05:00.304 5390 Recovering log #79 +2022/01/16-13:05:00.305 5390 Level-0 table #81: started +2022/01/16-13:05:00.306 5390 Level-0 table #81: 5033 bytes OK +2022/01/16-13:05:00.311 5390 Delete type=0 #79 +2022/01/16-13:05:00.311 5390 Delete type=3 #77 +2022/01/16-14:50:51.373 3240 Compacting 3@0 + 1@1 files +2022/01/16-14:50:51.382 3240 Generated table #83@0: 540 keys, 15703 bytes +2022/01/16-14:50:51.382 3240 Compacted 3@0 + 1@1 files => 15703 bytes +2022/01/16-14:50:51.384 3240 compacted to: files[ 0 1 0 0 0 0 0 ] +2022/01/16-14:50:51.385 3240 Delete type=2 #69 +2022/01/16-14:50:51.385 3240 Delete type=2 #71 +2022/01/16-14:50:51.386 3240 Delete type=2 #78 +2022/01/16-14:50:51.388 3240 Delete type=2 #81 diff --git a/bot2022.db/LOG.old b/bot2022.db/LOG.old index e37c184..2f68a5f 100644 --- a/bot2022.db/LOG.old +++ b/bot2022.db/LOG.old @@ -1,12 +1,5 @@ -2022/01/13-20:28:19.599602 7fce8bfff700 Recovering log #380 -2022/01/13-20:28:19.619863 7fce8bfff700 Level-0 table #383: started -2022/01/13-20:28:19.644721 7fce8bfff700 Level-0 table #383: 34245 bytes OK -2022/01/13-20:28:19.659675 7fce8bfff700 Delete type=3 #376 -2022/01/13-20:28:19.659731 7fce8bfff700 Delete type=0 #380 -2022/01/13-21:23:01.795818 7fce8a7fc700 Compacting 2@0 + 1@1 files -2022/01/13-21:23:01.855301 7fce8a7fc700 Generated table #385@0: 106 keys, 7830 bytes -2022/01/13-21:23:01.855331 7fce8a7fc700 Compacted 2@0 + 1@1 files => 7830 bytes -2022/01/13-21:23:01.866354 7fce8a7fc700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/01/13-21:23:01.866927 7fce8a7fc700 Delete type=2 #381 -2022/01/13-21:23:01.867414 7fce8a7fc700 Delete type=2 #379 -2022/01/13-21:23:01.871859 7fce8a7fc700 Delete type=2 #383 +2022/01/16-12:54:34.247 8028 Recovering log #76 +2022/01/16-12:54:34.247 8028 Level-0 table #78: started +2022/01/16-12:54:34.249 8028 Level-0 table #78: 1215 bytes OK +2022/01/16-12:54:34.254 8028 Delete type=0 #76 +2022/01/16-12:54:34.255 8028 Delete type=3 #75 diff --git a/bot2022.db/MANIFEST-000080 b/bot2022.db/MANIFEST-000080 new file mode 100644 index 0000000..dc9ed8d Binary files /dev/null and b/bot2022.db/MANIFEST-000080 differ diff --git a/bot2022.db/MANIFEST-000386 b/bot2022.db/MANIFEST-000386 deleted file mode 100644 index 10244e0..0000000 Binary files a/bot2022.db/MANIFEST-000386 and /dev/null differ diff --git a/src/Commands.js b/src/Commands.js index 551de40..e074320 100644 --- a/src/Commands.js +++ b/src/Commands.js @@ -26,297 +26,326 @@ module.exports = (bot) => { var locations = ["sleep", "outside", "inside", "shop"] function underline(text) { - var result = ""; - for(var i = 0; i < text.length; i++) { - result += text[i]+"̲"; - } - return result; - } + var result = ""; + for(var i = 0; i < text.length; i++) { + result += text[i]+"̲"; + } + return result; + } - function listOff(arr) { - if(arr.length === 0) return "(none)"; - var map = {}; - map.__proto__.inc = function(key) { - if(key.indexOf("(") !== -1) - key = key.substr(0, key.indexOf("(") - 1); - if(typeof(this[key]) === "undefined") { - this[key] = 1; - } else { - this[key]++; - } - } - for(var i = 0; i < arr.length; i++) { - map.inc(arr[i]); - } - var count = 0; - for(var j in map) { - if(map.hasOwnProperty(j)) ++count; - } - var result = ""; - var i = 0; - for(var j in map) { - if(!map.hasOwnProperty(j)) continue; - if(i && i !== count - 1) result += ", "; - if(i && i === count - 1) result += " and "; - result += "◍"+j+" x"+map[j]; - ++i; - } - return result; - } + function listOff(arr) { + if(arr.length === 0) return "(none)"; + var map = {}; + map.__proto__.inc = function(key) { + if(key.indexOf("(") !== -1) + key = key.substr(0, key.indexOf("(") - 1); + if(typeof(this[key]) === "undefined") { + this[key] = 1; + } else { + this[key]++; + } + } + for(var i = 0; i < arr.length; i++) { + map.inc(arr[i]); + } + var count = 0; + for(var j in map) { + if(map.hasOwnProperty(j)) ++count; + } + var result = ""; + var i = 0; + for(var j in map) { + if(!map.hasOwnProperty(j)) continue; + if(i && i !== count - 1) result += ", "; + if(i && i === count - 1) result += " and "; + result += "◍"+j+" x"+map[j]; + ++i; + } + return result; + } - function listArray(arr) { - var result = ""; - for(var i = 0; i < arr.length; i++) { - if(i && i !== arr.length - 1) result += ", "; - if(i && i === arr.length - 1) result += ", and "; - result += arr[i]; - } - return result; - } + function listArray(arr) { + var result = ""; + for(var i = 0; i < arr.length; i++) { + if(i && i !== arr.length - 1) result += ", "; + if(i && i === arr.length - 1) result += ", and "; + result += arr[i]; + } + return result; + } - function startupSound() { - MPPClient.client.sendArray([{m: "n", t: Date.now()+MPPClient.client.serverTimeOffset, - n: [{n:"e6",v:0.1},{d:50, n:"c7",v:0.2}]}]); - } + function startupSound() { + MPPClient.client.sendArray([{m: "n", t: Date.now()+MPPClient.client.serverTimeOffset, + n: [{n:"e6",v:0.1},{d:50, n:"c7",v:0.2}]}]); + } - function rando(arr) { - if(!Array.isArray(arr)) arr = Array.from(arguments); - return arr[Math.floor(Math.random() * arr.length)]; - } + function rando(arr) { + if(!Array.isArray(arr)) arr = Array.from(arguments); + return arr[Math.floor(Math.random() * arr.length)]; + } - function magicRando(arr) { - var result = ""; - for(var i = 0; i < 256; i++) { - result = arr[Math.floor(Math.random() * arr.length)]; - if(result.indexOf("(") !== -1) - result = result.substr(0, result.indexOf("(") - 1); - var md5 = crypto.createHash("md5"); - md5.update(result + "intermediaflatulencebuzzergiantroosterface"); - var hash = md5.digest(); - var random = hash.readUInt8(0) / 0xff + 0.5; - if(new Date().getDay() === 4) random += 0.25; - if(random > 1) random = 1; - if(Math.random() < random) { - break; - } - } - return result; - } + function magicRando(arr) { + var result = ""; + for(var i = 0; i < 256; i++) { + result = arr[Math.floor(Math.random() * arr.length)]; + if(result.indexOf("(") !== -1) + result = result.substr(0, result.indexOf("(") - 1); + var md5 = crypto.createHash("md5"); + md5.update(result + "intermediaflatulencebuzzergiantroosterface"); + var hash = md5.digest(); + var random = hash.readUInt8(0) / 0xff + 0.5; + if(new Date().getDay() === 4) random += 0.25; + if(random > 1) random = 1; + if(Math.random() < random) { + break; + } + } + return result; + } - function sanitize(string) { - const map = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - "/": '/', - }; - const reg = /[&<>"'/]/ig; - return string.replace(reg, (match) => (map[match])); - } + function sanitize(string) { + const map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + "/": '/', + }; + const reg = /[&<>"'/]/ig; + return string.replace(reg, (match) => (map[match])); + } - if(0) for(var i = 0; i < fish.length; i++) { - result = fish[i]; - if(result.indexOf("(") !== -1) - result = result.substr(0, result.indexOf("(") - 1); - var md5 = crypto.createHash("md5"); - md5.update(result + "intermediaflatulencebuzzergiantroosterface"); - var hash = md5.digest(); - var random = hash.readUInt8(0) / 0xff + 0.5; - if(random > 1) random = 1; - process.stdout.write(result+": "+random+". "); - } + if(0) for(var i = 0; i < fish.length; i++) { + result = fish[i]; + if(result.indexOf("(") !== -1) + result = result.substr(0, result.indexOf("(") - 1); + var md5 = crypto.createHash("md5"); + md5.update(result + "intermediaflatulencebuzzergiantroosterface"); + var hash = md5.digest(); + var random = hash.readUInt8(0) / 0xff + 0.5; + if(random > 1) random = 1; + process.stdout.write(result+": "+random+". "); + } function kekklefruit_growth() { - var minute = 60 * 1000; - var ms = 1000 + Math.random() * 120 * minute; - setTimeout(function() { - if(Math.random() < 0.5) { - db.getFruits(function(num_fruits) { - db.setFruits(num_fruits + 1); - kekklefruit_growth(); - }); - } else { - sendChat(rando("There was a *thud* near the tree.", "Something thumped nearby.", "Did you hear a sort of whump sound?", "Did you hear a fruit landing on the ground or something?", "*plop* a kekklefruit just falls from the tree onto the ground.")); - db.put("look.outside.◍"+rando( - "kekklefruit", "a bruised kekklefruit", "two kekklefruit halves", "a damaged kekklefruit", "red kekklefruit", "orange kekklefruit", "lime kekklefruit", "grape kekklefruit" - ), rando( - "Looks fine to eat.", "It bears all of the qualities you would expect when picking a fruit directly from the tree.", "A priceless treasure from our beloved kekklefruit tree.", "It has no special markings or engravings, or other signs of molestation.", "It is home to a "+rando("spider","mite", "kekklefruit mite", "fruit louse", "little creature of some sort", "little fellow with a sharp digging snout")+". Bonus!", "The fall doesn't appear to have affected its potency.", "It's beautiful, and bred to give you a fishing boost.", "This had to have come from the tree, right?" - )); - } - }, ms); + var minute = 60 * 1000; + var ms = 1000 + Math.random() * 120 * minute; + setTimeout(function() { + if(Math.random() < 0.5) { + db.getFruits(function(num_fruits) { + db.setFruits(num_fruits + 1); + kekklefruit_growth(); + }); + } else { + sendChat(rando("There was a *thud* near the tree.", "Something thumped nearby.", "Did you hear a sort of whump sound?", "Did you hear a fruit landing on the ground or something?", "*plop* a kekklefruit just falls from the tree onto the ground.")); + db.put("look.outside.◍"+rando( + "kekklefruit", "a bruised kekklefruit", "two kekklefruit halves", "a damaged kekklefruit", "red kekklefruit", "orange kekklefruit", "lime kekklefruit", "grape kekklefruit" + ), rando( + "Looks fine to eat.", "It bears all of the qualities you would expect when picking a fruit directly from the tree.", "A priceless treasure from our beloved kekklefruit tree.", "It has no special markings or engravings, or other signs of molestation.", "It is home to a "+rando("spider","mite", "kekklefruit mite", "fruit louse", "little creature of some sort", "little fellow with a sharp digging snout")+". Bonus!", "The fall doesn't appear to have affected its potency.", "It's beautiful, and bred to give you a fishing boost.", "This had to have come from the tree, right?" + )); + } + }, ms); } kekklefruit_growth(); function rainstorm() { - var minute = 60 * 1000; - var ms = 1000 + Math.random() * 72 * 60 * minute; - setTimeout(function() { - var duration = 6 + Math.random() * 24; - for(var i = 0; i < duration; i++) { - // sendChat("1"); - if(Math.random() > 0.5) { - setTimeout(function() { - db.getFruits(function(num_fruits) { - db.setFruits(num_fruits + 1); - }); - }, 3000 + Math.random() * minute); - } - } - rainstorm(); - }, ms); - } + var minute = 60 * 1000; + var ms = 1000 + Math.random() * 72 * 60 * minute; + setTimeout(function() { + var duration = 6 + Math.random() * 24; + for(var i = 0; i < duration; i++) { + // sendChat("1"); + if(Math.random() > 0.5) { + setTimeout(function() { + db.getFruits(function(num_fruits) { + db.setFruits(num_fruits + 1); + }); + }, 3000 + Math.random() * minute); + } + } + rainstorm(); + }, ms); + } - rainstorm(); + rainstorm(); - function catchSomething(part) { - db.getFish(part._id, function(myfish) { - if(myfish.length > 10 && Math.random() < 0.1) { - catchTrap(part); - } else { - catchFish(part); - } - }); - } + function checkDayJoin(part) { + db.get('join~'+part._id, function(err, lastjoin) { + // check if it's been more than a day + if(lastjoin && (Date.now() - lastjoin) < 864e5) return false; + db.put('join~'+part._id, Date.now()); + return true; + }); + } - function catchFish(part, silent) { - var entry = "Missingno"; - if(Math.random() > 0.005) { - var type = magicRando(fish); - if((new Date().getDay() & 1) && Math.random() < 0.25) type = "Small Bass"; - var size = (["small", "medium-sized", "rather large", "large"])[Math.floor(Math.random()*4)]; - if(size == "large" && Math.random() > 0.975) size = "Golden"; - if(!silent) sendChat("Our good friend " +part.name+" caught a "+size+" "+type + "! ready to /eat or /fish again"); + MPPClient.checkDayJoin = checkDayJoin; - entry = type + " (" + size + ")"; + function catchSomething(part) { + db.getFish(part._id, function(myfish) { + if(myfish.length > 10 && Math.random() < 0.1) { + catchTrap(part); + } else { + catchFish(part); + } + }); + } - if(fish_without_images.indexOf(type) == -1) { - fs.readFile("./password.txt", function(err, data) { - if(err) throw err; - var text = part.name+" caught a "+size+" "+type + "!"; - console.log(type); - // client.sendArray([{m: "admin message", password: new String(data).trim(), - // msg: {"m": "notification", "id":"Fish-caught","targetUser": "room", "target": "#piano", "duration": "7000", "class":"short","html": "
"+sanitize(text)}}]); - }); - } - } else { - // rarer fish - var type = magicRando(newfish || ["error medal"]); - var stuff = ["Special catch!", "Let us all give recognition.", "Ahoy!", "Wow!", "Nice.", "Nice!", "Great!", "Sweet!", "Sweet,", "That's cool,", "Cool!", "Neat...", "Neat!", "Wow,", "Rad.", "Funk yeah!!", "omg", "like whoah,","Great success.","Good news everyone,","I have something importrant to say.","I have something important to say.","This is cool news..","I have something to report:","Good job!","Here's something...","Whoah!!","Oh! Oh! This is a good one.","Check it","Luck!!", "Lucky!", "In luck,","Excellent.","Oh my!","A rarer fish.","Rarer fish...","Rare!","Rare fish!","An uncommon fish!!","This is less common!","Score!","Uncommon fish!", "Uncommon fish caught!","Uncommon get!","Uncommon fish get!"]; - var exclamation = stuff[Math.floor(Math.random() * stuff.length)]; - if(!silent) sendChat(exclamation+" "+part.name+" caught a "+type + "."); + function catchFish(part, silent) { + var entry = "Missingno"; + if(Math.random() > 0.005) { + var type = magicRando(fish); + if((new Date().getDay() & 1) && Math.random() < 0.25) type = "Small Bass"; + var size = (["small", "medium-sized", "rather large", "large"])[Math.floor(Math.random()*4)]; + if(size == "large" && Math.random() > 0.975) size = "Golden"; + if(!silent) sendChat("Our good friend " +part.name+" caught a "+size+" "+type + "! ready to /eat or /fish again"); - entry = type; - } + entry = type + " (" + size + ")"; - db.getFish(part._id, function(myfish) { - myfish.push(entry); - db.putFish(part._id, myfish); + if(fish_without_images.indexOf(type) == -1) { + fs.readFile("./password.txt", function(err, data) { + if(err) throw err; + var text = part.name+" caught a "+size+" "+type + "!"; + console.log(type); + // client.sendArray([{m: "admin message", password: new String(data).trim(), + // msg: {"m": "notification", "id":"Fish-caught","targetUser": "room", "target": "#piano", "duration": "7000", "class":"short","html": "
"+sanitize(text)}}]); + MPPClient.client.sendArray([{ + m: 'custom', + data: { + m: 'notification', + id: 'Fish-caught', + targetUser: 'room', + target: '#piano', + duration: '7000', + class: 'short', + html: '
'+sanitize(text) + }, + target: { + mode: 'subscribed', + global: false + } + }]); + }); + } + } else { + // rarer fish + var type = magicRando(newfish || ["error medal"]); + var stuff = ["Special catch!", "Let us all give recognition.", "Ahoy!", "Wow!", "Nice.", "Nice!", "Great!", "Sweet!", "Sweet,", "That's cool,", "Cool!", "Neat...", "Neat!", "Wow,", "Rad.", "Funk yeah!!", "omg", "like whoah,","Great success.","Good news everyone,","I have something importrant to say.","I have something important to say.","This is cool news..","I have something to report:","Good job!","Here's something...","Whoah!!","Oh! Oh! This is a good one.","Check it","Luck!!", "Lucky!", "In luck,","Excellent.","Oh my!","A rarer fish.","Rarer fish...","Rare!","Rare fish!","An uncommon fish!!","This is less common!","Score!","Uncommon fish!", "Uncommon fish caught!","Uncommon get!","Uncommon fish get!"]; + var exclamation = stuff[Math.floor(Math.random() * stuff.length)]; + if(!silent) sendChat(exclamation+" "+part.name+" caught a "+type + "."); - if(myfish.length > 30 && myfish.length % 5 === 0) { - if(!silent) sendChat("Our friend " +part.name+"'s fish sack grows ever larger."); - } - }); - }; + entry = type; + } - function bonusTry(part) { - var key = "fishing~"+part._id; - var bonus = getBonusById(part._id); - if(bonus > 0) { + db.getFish(part._id, function(myfish) { + myfish.push(entry); + db.putFish(part._id, myfish); + + if(myfish.length > 30 && myfish.length % 5 === 0) { + if(!silent) sendChat("Our friend " +part.name+"'s fish sack grows ever larger."); + } + }); + }; + + function bonusTry(part) { + var key = "fishing~"+part._id; + var bonus = getBonusById(part._id); + if(bonus > 0) { let time = 5000 + Math.random() * 10000 + Math.max((2-bonus) * 10000, 0); - setTimeout(function() { - db.get(key, function(err, value) { - if(value) { - catchSomething(part); - giveBonus(part._id, -0.1); - db.del(key); - } - }); - }, time); - } - } + setTimeout(function() { + db.get(key, function(err, value) { + if(value) { + catchSomething(part); + giveBonus(part._id, -0.1); + db.del(key); + } + }); + }, time); + } + } function catchTrap(part) { - var types = ["Blue Whale", "Giant Squid", "Giant Pacific Octopus", "Giant Oceanic Manta Ray", "Southern Elephant Seal", "Sperm Whale", "Giant Oarfish", "Whale Shark", "Japanese Spider Crab"]; - var type = magicRando(types); - sendChat("Our friend " +part.name+" is getting a bite."); - sendChat("Unfortunate catch! It's a "+type+"...!"); - types = ["boom", "crash", "kaboom", "smash", "kersplash"]; - sendChat(types[Math.floor(Math.random()*types.length)]+"... "+types[Math.floor(Math.random()*types.length)]+"..."); - sendChat("Some of the fish were lost in the disaster..."); + var types = ["Blue Whale", "Giant Squid", "Giant Pacific Octopus", "Giant Oceanic Manta Ray", "Southern Elephant Seal", "Sperm Whale", "Giant Oarfish", "Whale Shark", "Japanese Spider Crab"]; + var type = magicRando(types); + sendChat("Our friend " +part.name+" is getting a bite."); + sendChat("Unfortunate catch! It's a "+type+"...!"); + types = ["boom", "crash", "kaboom", "smash", "kersplash"]; + sendChat(types[Math.floor(Math.random()*types.length)]+"... "+types[Math.floor(Math.random()*types.length)]+"..."); + sendChat("Some of the fish were lost in the disaster..."); - //sendChat("(not really. that part is disabled. just testing)"); + //sendChat("(not really. that part is disabled. just testing)"); - db.getFish(part._id, function(myfish) { - var org = myfish.length; - var keep = Math.floor(org * 0.2); - myfish = myfish.slice(0, keep + 1); - db.putFish(part._id, myfish); - }); - }; + db.getFish(part._id, function(myfish) { + var org = myfish.length; + var keep = Math.floor(org * 0.2); + myfish = myfish.slice(0, keep + 1); + db.putFish(part._id, myfish); + }); + }; - function catchPokemon(part, silent) { - var pok = pokedex[Math.floor(Math.random() * pokedex.length)]; - db.getPokemon(part._id, function(pokemon) { - pokemon.push(pok.name); - var count = pokemon.length; - db.putPokemon(part._id, pokemon); + function catchPokemon(part, silent) { + var pok = pokedex[Math.floor(Math.random() * pokedex.length)]; + db.getPokemon(part._id, function(pokemon) { + pokemon.push(pok.name); + var count = pokemon.length; + db.putPokemon(part._id, pokemon); - var key2 = "name to user id~"+part.name+"~"+Date.now().toString(36); - db.put(key2, part._id); + var key2 = "name to user id~"+part.name+"~"+Date.now().toString(36); + db.put(key2, part._id); - var key2 = "user id to name~"+part._id+"~"+Date.now().toString(36); - db.put(key2, part.name); + var key2 = "user id to name~"+part._id+"~"+Date.now().toString(36); + db.put(key2, part.name); - if(!silent) - sendChat(part.name + " received a " + pok.name.toUpperCase()+" for joining! By my count, "+part.name+" now has "+count+" individual pokemón."); + if(!silent) + sendChat(part.name + " received a " + pok.name.toUpperCase()+" for joining! By my count, "+part.name+" now has "+count+" individual pokemón."); - //sendChat("/hug " + part.name.toLowerCase()); - }); - }; + //sendChat("/hug " + part.name.toLowerCase()); + }); + }; - function findParticipantByName(name) { - if(!name || name.trim() == "") return undefined; - for(var id in MPPClient.client.ppl) { - if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name === name) { - return MPPClient.client.ppl[id]; - } - } - return undefined; - }; + MPPClient.catchPokemon = catchPokemon; - function findParticipantByNameCaseInsensitive(name) { - if(!name || name.trim() == "") return undefined; - var part = findParticipantByName(name); - if(!part) { - name_lc = name.toLowerCase(); + function findParticipantByName(name) { + if(!name || name.trim() == "") return undefined; + for(var id in MPPClient.client.ppl) { + if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name === name) { + return MPPClient.client.ppl[id]; + } + } + return undefined; + }; + + function findParticipantByNameCaseInsensitive(name) { + if(!name || name.trim() == "") return undefined; + var part = findParticipantByName(name); + if(!part) { + name_lc = name.toLowerCase(); for (let p of Object.values(MPPClient.client.ppl)) { if(p.name.toLowerCase() === name_lc) { part = p; } } - } - return part; - }; + } + return part; + }; - function findParticipantByNameFuzzy(name) { - if(!name || name.trim() == "") return undefined; - name = name.toLowerCase(); - var part = findParticipantByNameCaseInsensitive(name); - for(var id in MPPClient.client.ppl) { - if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) === 0) { - part = MPPClient.client.ppl[id]; - break; - } - } - for(var id in MPPClient.client.ppl) { - if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) !== -1) { - part = MPPClient.client.ppl[id]; - break; - } - } + function findParticipantByNameFuzzy(name) { + if(!name || name.trim() == "") return undefined; + name = name.toLowerCase(); + var part = findParticipantByNameCaseInsensitive(name); + for(var id in MPPClient.client.ppl) { + if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) === 0) { + part = MPPClient.client.ppl[id]; + break; + } + } + for(var id in MPPClient.client.ppl) { + if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) !== -1) { + part = MPPClient.client.ppl[id]; + break; + } + } // new if (!part) { @@ -337,45 +366,45 @@ module.exports = (bot) => { } } - return part; - }; + return part; + }; var fishing_bonus_by_id = {}; - function getBonusById(id) { - if(fishing_bonus_by_id.hasOwnProperty(id)) { - return fishing_bonus_by_id[id]; - } else { - return 0; - } - } - function giveBonus(id, bonus) { - bonus += getBonusById(id); - fishing_bonus_by_id[id] = bonus; - } + function getBonusById(id) { + if(fishing_bonus_by_id.hasOwnProperty(id)) { + return fishing_bonus_by_id[id]; + } else { + return 0; + } + } + function giveBonus(id, bonus) { + bonus += getBonusById(id); + fishing_bonus_by_id[id] = bonus; + } - var sandiness_by_id = {}; - function getSandinessById(id) { - if(sandiness_by_id.hasOwnProperty(id)) { - return sandiness_by_id[id]; - } else { - return 0; - } - } - function giveSandiness(id, sandiness) { - sandiness += getSandinessById(id); - sandiness_by_id[id] = sandiness; - } - setInterval(function() { - for(var i in sandiness_by_id) { - if(sandiness_by_id.hasOwnProperty(i)) { - sandiness_by_id[i] = Math.max(sandiness_by_id[i] - 1, 0); - } - } - }, 24*60*60000); + var sandiness_by_id = {}; + function getSandinessById(id) { + if(sandiness_by_id.hasOwnProperty(id)) { + return sandiness_by_id[id]; + } else { + return 0; + } + } + function giveSandiness(id, sandiness) { + sandiness += getSandinessById(id); + sandiness_by_id[id] = sandiness; + } + setInterval(function() { + for(var i in sandiness_by_id) { + if(sandiness_by_id.hasOwnProperty(i)) { + sandiness_by_id[i] = Math.max(sandiness_by_id[i] - 1, 0); + } + } + }, 24*60*60000); - setInterval(function() { - db.put("look.outside.◍Sand", "We don't talk about that."); - }, 6000); + setInterval(function() { + db.put("look.outside.◍Sand", "We don't talk about that."); + }, 6000); function randomizeAllColors() { for (let p of Object.values(MPPClient.client.ppl)) { @@ -497,6 +526,16 @@ module.exports = (bot) => { } }, false); + bot.addCommand(['pokemon', 'pkmn'], 0, msg => { + var part = findParticipantByNameFuzzy(msg.argcat()) || msg.p; + + db.getPokemon(part._id, function(mypkmn) { + var message = ""; + message = "Friend "+part.name+"'s pokemon: "+listOff(mypkmn) + message; + sendChat(message); + }); + }, false); + bot.addCommand('fishing_count', 0, msg => { var count = 0; db.createReadStream({ @@ -781,87 +820,97 @@ module.exports = (bot) => { bot.addCommand(['eat', 'oot'], 0, msg => { db.getFish(msg.p._id, function(myfish) { - if(myfish.length < 1) { - sendChat("Friend " + msg.p.name+": You have no food. /fish to get some."); - return; - } - var idx = -1; - var arg = msg.argcat().trim().toLowerCase(); - for(var i = 0; i < myfish.length; i++) { - if(myfish[i].toLowerCase().indexOf(arg) !== -1) { - idx = i; - break; + db.getPokemon(msg.p._id, function (mypkmn) { + if(myfish.length < 1) { + sendChat("Friend " + msg.p.name+": You have no food. /fish to get some."); + return; } - } - if(idx == -1) { - sendChat("Friend " +msg.p.name+": You don't have a "+arg+" that's edible."); - return; - } - var food = myfish[idx]; - if(food.toLowerCase() == "sand") { - if(getSandinessById(msg.p._id) >= 10) { - sendChat("You can only "+cmd+" about 10 sand per day. Going to have to find something else to do with that sand."); - if(Math.random() < 0.1) { - sendChat("What a terrible night to have a curse."); + var idx = -1; + var arg = msg.argcat().trim().toLowerCase(); + for(var i = 0; i < myfish.length; i++) { + if(myfish[i].toLowerCase().indexOf(arg) !== -1) { + idx = i; + break; } - } else { - // eat sand - sendChat("Our friend "+msg.p.name+" ate of his/her sand."); - giveSandiness(msg.p._id, 1); - myfish.splice(idx, 1); - db.putFish(msg.p._id, myfish); } - return; - } - if(food.indexOf("(") !== -1) - food = food.substr(0, food.indexOf("(") - 1); - myfish.splice(idx, 1); - db.putFish(msg.p._id, myfish); - if(food.indexOf("kek") !== -1) { - sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and got a temporary fishing boost."); - giveBonus(msg.p._id, 1); - bonusTry(msg.p); - return; - } - if(Math.random() < 0.5) { - var tastes = ["fine", "sweet", "sour", "awfully familiar", "interesting", - "icky", "fishy", "fishy", "fine", "colorful", "revolting", "good", - "good", "great", "just fine", "weird", "funny", "odd", "strange", "salty", - "like chicken", "like hamburger", "like dirt", "like a sewer", "like french fries", - "cheesy", "hurty", "hot", "spicy", "a little off", "like the real thing", - "like sunshine", "\"delish\"", "supreme", "like air", "amazing", "blue", - "yellow", "like peanut butter", "delicious", "delicious", "spicy", "like grass", - "like nothing he/she had ever tasted before", "pilly", "sweaty", "like garlic", - "like people food", "salty", "wrong", "good enough for him/her", "like ham", - "like the ones at McDonalds", "like a jellybean", "like snot", "like a penny, ew", - "musical", "... fantastic", "sure enough", "right", "unusual", "a bit off", " indescribable", - "gooey", "sticky", "kawaii", "like you aren't supposed to eat it, for some reason he/she can't describe", - "like home", "like Christmas", "like Halloween", "like a fish", "like he/she expected but better", - "like it made him/her turn a shade of 'turquoise.' Upon looking in a mirror he/she finds it didn't actually do so, though. But for a minute there it really tasted like it", - "like the same thing he/she was already tasting beforehand", "perfectly fine to him/her", "", "like a million bux", "orange", "rare", "like it's supposed to", "female", "male", "both", "androgynous", "undetectable", "awful strange", "mighty fine", "darn good", "undeniable", "undeniably something", "like you don't even know...", "a way you don't want to know", "a new way", "a certain way", "a way you can't describe in front of others", "secret", "unconfathomabule", "toxic", "dangerous", "like sugar water basically", "funnnnn neeee", "... AWKWARD! 🤖", "perfect.", "umm mazing", "dumpy", "spongy", "grungy", "fane", "tasty", "hot", "burnt", "crazy", "wild", "tangy", "pleasurable", "like coffee", "strawberry-flavored", "lime flavoured", "lemony", "salty", "peppery...", "chocolatey", "gooey", "like toothpaste", "like the sweet taste of victory", "like success", "fantastical", "amazeballs", "totally fucked up", "too good to describe", "like a dream", "obscene", "inhuman", "like alien food", "like something his/her past life grandma would cook (His/her past life grandma was an alien)", "like the essence of life", "like he/she wanted it to", "not as expected", "nothing like expected", "as you would expect", "like the perfect thing to celebrate the occasion", "so peculiar that he/she now wishes he/she had /yeeted it instead", "like what it was", "like home", "like the old days", "like the past", "like the future", "like fast food joint", "spicy", "too spicy", "too good", "like it smelled", "the same way it smelled", "like the beach", "like fish from /fishing", "dandy", "supreme", "bootylicious", "disconcerting"]; - var taste = tastes[Math.floor(Math.random()*tastes.length)]; - sendChat("Our friend " + msg.p.name+" ate "+food+". It tasted "+taste+"."); - } else { - function rrggbbrand(){var a = Math.floor(Math.random() * 256).toString(16); return a.length < 2 ? "0"+a : a} - var color = "#"+rrggbbrand()+rrggbbrand()+rrggbbrand(); - // client.sendArray([{m: "admin message", password: "amogus", - // msg: {m: "color", _id: msg.p._id, color: color}}]); - // DiscordClient.client.guilds.cache.get("841331769051578413").roles.cache.forEach(r => { - // if (r.name == msg.p._id) { - // r.edit({ - // color: color - // }); - // } - // }) - - MPPClient.client.sendArray([{ - m: 'setcolor', - _id: msg.p._id, - color: color - }]); - - sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and it made him/her turn "+(new Color(color).getName().toLowerCase())+"."); - } + if (msg.args[0] && !idx) { + for(var i = 0; i < mypkmn.length; i++) { + if(mypkmn[i].toLowerCase().indexOf(arg) !== -1) { + sendChat("My dude, " + msg.p.name+", Pokémon are not food. You can't just eat something that cute!"); + return; + } + } + } + if(idx == -1) { + sendChat("Friend " +msg.p.name+": You don't have a "+arg+" that's edible."); + return; + } + var food = myfish[idx]; + if(food.toLowerCase() == "sand") { + if(getSandinessById(msg.p._id) >= 10) { + sendChat("You can only "+cmd+" about 10 sand per day. Going to have to find something else to do with that sand."); + if(Math.random() < 0.1) { + sendChat("What a terrible night to have a curse."); + } + } else { + // eat sand + sendChat("Our friend "+msg.p.name+" ate of his/her sand."); + giveSandiness(msg.p._id, 1); + myfish.splice(idx, 1); + db.putFish(msg.p._id, myfish); + } + return; + } + if(food.indexOf("(") !== -1) + food = food.substr(0, food.indexOf("(") - 1); + myfish.splice(idx, 1); + db.putFish(msg.p._id, myfish); + if(food.indexOf("kek") !== -1) { + sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and got a temporary fishing boost."); + giveBonus(msg.p._id, 1); + bonusTry(msg.p); + return; + } + if(Math.random() < 0.5) { + var tastes = ["fine", "sweet", "sour", "awfully familiar", "interesting", + "icky", "fishy", "fishy", "fine", "colorful", "revolting", "good", + "good", "great", "just fine", "weird", "funny", "odd", "strange", "salty", + "like chicken", "like hamburger", "like dirt", "like a sewer", "like french fries", + "cheesy", "hurty", "hot", "spicy", "a little off", "like the real thing", + "like sunshine", "\"delish\"", "supreme", "like air", "amazing", "blue", + "yellow", "like peanut butter", "delicious", "delicious", "spicy", "like grass", + "like nothing he/she had ever tasted before", "pilly", "sweaty", "like garlic", + "like people food", "salty", "wrong", "good enough for him/her", "like ham", + "like the ones at McDonalds", "like a jellybean", "like snot", "like a penny, ew", + "musical", "... fantastic", "sure enough", "right", "unusual", "a bit off", " indescribable", + "gooey", "sticky", "kawaii", "like you aren't supposed to eat it, for some reason he/she can't describe", + "like home", "like Christmas", "like Halloween", "like a fish", "like he/she expected but better", + "like it made him/her turn a shade of 'turquoise.' Upon looking in a mirror he/she finds it didn't actually do so, though. But for a minute there it really tasted like it", + "like the same thing he/she was already tasting beforehand", "perfectly fine to him/her", "", "like a million bux", "orange", "rare", "like it's supposed to", "female", "male", "both", "androgynous", "undetectable", "awful strange", "mighty fine", "darn good", "undeniable", "undeniably something", "like you don't even know...", "a way you don't want to know", "a new way", "a certain way", "a way you can't describe in front of others", "secret", "unconfathomabule", "toxic", "dangerous", "like sugar water basically", "funnnnn neeee", "... AWKWARD! 🤖", "perfect.", "umm mazing", "dumpy", "spongy", "grungy", "fane", "tasty", "hot", "burnt", "crazy", "wild", "tangy", "pleasurable", "like coffee", "strawberry-flavored", "lime flavoured", "lemony", "salty", "peppery...", "chocolatey", "gooey", "like toothpaste", "like the sweet taste of victory", "like success", "fantastical", "amazeballs", "totally fucked up", "too good to describe", "like a dream", "obscene", "inhuman", "like alien food", "like something his/her past life grandma would cook (His/her past life grandma was an alien)", "like the essence of life", "like he/she wanted it to", "not as expected", "nothing like expected", "as you would expect", "like the perfect thing to celebrate the occasion", "so peculiar that he/she now wishes he/she had /yeeted it instead", "like what it was", "like home", "like the old days", "like the past", "like the future", "like fast food joint", "spicy", "too spicy", "too good", "like it smelled", "the same way it smelled", "like the beach", "like fish from /fishing", "dandy", "supreme", "bootylicious", "disconcerting"]; + var taste = tastes[Math.floor(Math.random()*tastes.length)]; + sendChat("Our friend " + msg.p.name+" ate "+food+". It tasted "+taste+"."); + } else { + function rrggbbrand(){var a = Math.floor(Math.random() * 256).toString(16); return a.length < 2 ? "0"+a : a} + var color = "#"+rrggbbrand()+rrggbbrand()+rrggbbrand(); + // client.sendArray([{m: "admin message", password: "amogus", + // msg: {m: "color", _id: msg.p._id, color: color}}]); + // DiscordClient.client.guilds.cache.get("841331769051578413").roles.cache.forEach(r => { + // if (r.name == msg.p._id) { + // r.edit({ + // color: color + // }); + // } + // }) + + MPPClient.client.sendArray([{ + m: 'setcolor', + _id: msg.p._id, + color: color + }]); + + sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and it made him/her turn "+(new Color(color).getName().toLowerCase())+"."); + } + }); }); }, false); @@ -1164,34 +1213,33 @@ module.exports = (bot) => { }); setInterval(function() { - db.put("look.outside.◍Sand", "We don't talk about that."); - db.put("look.outside.◍Lawn Mower", "It's a bird! It's a plane! It's a... lawn mower!"); + db.put("look.outside.◍Sand", "We don't talk about that."); - db.put("look.sleep.◍Bed", "*snuggles*"); + db.put("look.sleep.◍Bed", "*snuggles*"); db.put("look.inside.◍Couch", "Let's sit down and have a talk."); - db.put("look.inside.◍Grand Piano", "Sounds very multiplayer."); - }, 6000); + db.put("look.inside.◍Grand Piano", "Maybe you could play a song or two for us."); + }, 6000); var FISHING_CHANCE = 0.02; - setInterval(function() { - var results = []; - db.createReadStream({ - start: "fishing~", - end: "fishing~\xff" - }) - .on("data", function(data) { - if(data.value) results.push(data.key); - }) - .on("end", function() { + setInterval(function() { + var results = []; + db.createReadStream({ + start: "fishing~", + end: "fishing~\xff" + }) + .on("data", function(data) { + if(data.value) results.push(data.key); + }) + .on("end", function() { if(results.length === 0) return; - if(Math.random() > FISHING_CHANCE * results.length) return; - var winner = results[Math.floor(Math.random()*results.length)]; - if(winner.match(/^fishing~[0-9a-f].*$/)) { - db.del(winner); - var user_id = winner.substr(8); - var part; - // DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.forEach(p => { + if(Math.random() > FISHING_CHANCE * results.length) return; + var winner = results[Math.floor(Math.random()*results.length)]; + if(winner.match(/^fishing~[0-9a-f].*$/)) { + db.del(winner); + var user_id = winner.substr(8); + var part; + // DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.forEach(p => { // if (p.user.id === user_id) { // part = p.user; // part.name = p.user.username; @@ -1211,61 +1259,62 @@ module.exports = (bot) => { } } } - } - }); - }, 5000); + } + }); + }, 5000); setInterval(function() { - // return; // stop auto-fishing + // return; // stop auto-fishing + if (new Date().getDay() !== 2) return; var client = MPPClient.client; - if(!client.isConnected()) return; + if(!client.isConnected()) return; - var part = client.ppl[client.participantId]; - if(!part) return; + var part = client.ppl[client.participantId]; + if(!part) return; - var key = "fishing~"+part._id; - db.get(key, function(err, value) { - if(!value) { - sendChat("/fish", true); - } else { - db.getFish(part._id, function(myfish) { - if(!myfish.length) return; - var rand = Math.floor(Math.random()*client.countParticipants()); - var dest; - for(var i in client.ppl) { - if(!client.ppl.hasOwnProperty(i)) continue; - if(i == rand) break; - else dest = client.ppl[i]; - } - if(dest && dest.id !== client.participantId) { - sendChat("/give "+dest.name.split(" ")[0], true); - } - }); - /*if(findParticipantByNameFuzzy("potato")) { - var asdf = findParticipantByNameFuzzy("electrashave") || findParticipantByNameFuzzy("potato") || findParticipantByNameFuzzy("totoro"); - if(asdf) sendChat("/duel "+asdf.name); - }*/ - } + var key = "fishing~"+part._id; + db.get(key, function(err, value) { + if(!value) { + sendChat("/fish", true); + } else { + db.getFish(part._id, function(myfish) { + if(!myfish.length) return; + var rand = Math.floor(Math.random()*client.countParticipants()); + var dest; + for(var i in client.ppl) { + if(!client.ppl.hasOwnProperty(i)) continue; + if(i == rand) break; + else dest = client.ppl[i]; + } + if(dest && dest.id !== client.participantId) { + sendChat("/give "+dest.name.split(" ")[0], true); + } + }); + /*if(findParticipantByNameFuzzy("potato")) { + var asdf = findParticipantByNameFuzzy("electrashave") || findParticipantByNameFuzzy("potato") || findParticipantByNameFuzzy("totoro"); + if(asdf) sendChat("/duel "+asdf.name); + }*/ + } - /*else */ - }); - }, 120000); + /*else */ + }); + }, 120000); - function setTerminalTitle(title) { - process.stdout.write( - String.fromCharCode(27) + "]0;" + title + String.fromCharCode(7) - ); - } + function setTerminalTitle(title) { + process.stdout.write( + String.fromCharCode(27) + "]0;" + title + String.fromCharCode(7) + ); + } - // client.on("count", function(count) { - // if(count > 0) { - // setTerminalTitle("fishing (" + count + ")"); - // } else { - // setTerminalTitle("fishing"); - // } - // }); + // client.on("count", function(count) { + // if(count > 0) { + // setTerminalTitle("fishing (" + count + ")"); + // } else { + // setTerminalTitle("fishing"); + // } + // }); var Pong = function(client, db) { this.client = client; @@ -1295,15 +1344,11 @@ module.exports = (bot) => { } else if(this.part.y > 100) { this.vy = -this.vy; } - //this.vx += Math.random() * 0.5 - 0.25; - //this.vy += Math.random() * 0.5 - 0.25; - // this.client.sendArray([{m: "m", x: this.part.x, y: this.part.y}]); + this.vx += Math.random() * 0.5 - 0.25; + this.vy += Math.random() * 0.5 - 0.25; + this.client.sendArray([{m: "m", x: this.part.x, y: this.part.y}]); }; - - - - var Exchange = function(db) { this.db = db; }; @@ -1551,20 +1596,20 @@ module.exports = (bot) => { db.getLocation(msg.p._id, location => { if (location === 'outside') { if(location === "outside") { - db.getFruits(function(num_fruits) { - if(num_fruits > 0) { - db.setFruits(num_fruits - 1); - db.appendFish(msg.p._id, ["kekklefruit"]); - sendChat("Our friend "+msg.p.name+" picked 1 fruit from the kekklefruit tree and placed it into his/her fish sack."); - } else { - var options = require('./treeMessages.json'); - var message = options[Math.floor(Math.random() * options.length)]; - sendChat(message); - } - }); - } else { - sendChat("You can't interact with the tree from "+location+"."); - } + db.getFruits(function(num_fruits) { + if(num_fruits > 0) { + db.setFruits(num_fruits - 1); + db.appendFish(msg.p._id, ["kekklefruit"]); + sendChat("Our friend "+msg.p.name+" picked 1 fruit from the kekklefruit tree and placed it into his/her fish sack."); + } else { + var options = require('./treeMessages.json'); + var message = options[Math.floor(Math.random() * options.length)]; + sendChat(message); + } + }); + } else { + sendChat("You can't interact with the tree from "+location+"."); + } } }); return; @@ -1633,56 +1678,6 @@ module.exports = (bot) => { } }); - // bot.addCommand(['give'], 0, msg => { - // var thief = msg.p; - // var victim = findParticipantByNameFuzzy(msg.args[0]); - // if (!victim) { - // sendChat("Friend " + thief.name + " missed"); - // return; - // } - // if (victim._id == thief._id) { - // sendChat("Friendly friend " + thief.name + " fudged"); - // return; - // } - // var target_fish = msg.argcat(1); - // db.getFish(thief._id, function (thief_fish) { - // db.getFish(victim._id, function (victim_fish) { - // if (victim_fish.length >= TOO_MANY_FISH) { - // sendChat("Friend " + victim.name + " is carrying too much."); - // return; - // } - // if (thief_fish.length > 0) { - // var idx = -1; - // var arg = target_fish.trim().toLowerCase(); - // for (var i = 0; i < thief_fish.length; i++) { - // if (arg == "" || thief_fish[i].toLowerCase().indexOf(arg) !== -1) { - // idx = i; - // break; - // } - // } - // if (idx == -1) { - // sendChat("Friend " + thief.name + ": You don't have a " + arg + "that you can /give like that."); - // return; - // } - // var thefish = thief_fish[idx]; - // thief_fish.splice(idx, 1); - // victim_fish.push(thefish); - - // sendChat("Our friend" + thief.name + " gave " + victim.name + " his/her " + thefish); - // db.putFish(thief._id, thief_fish); - // db.putFish(victim._id, victim_fish); - // } else { - // sendChat("Friend " + thief.name + ": You don't have the fish to give."); - // } - // }); - // }); - // return; - // }, false); - - // bot.addCommand(['/give_'], 0, msg => { - - // }, true); - bot.addCommand(['bestow'], 0, msg => { var thief = msg.p; var victim = findParticipantByNameFuzzy(msg.args[0]); @@ -1729,9 +1724,13 @@ module.exports = (bot) => { return; }); - // bot.addCommand(['/bestow_'], 0, msg => { - - // }, true); - - + bot.addCommand(['setcolor'], 0, (msg, admin) => { + if (!admin) return; + MPPClient.client.sendArray([{ + m: 'userset', + set: { + color: msg.args[0] + } + }]) + }); } diff --git a/src/MPPClient.js b/src/MPPClient.js index ce4d00b..fabddc1 100644 --- a/src/MPPClient.js +++ b/src/MPPClient.js @@ -47,6 +47,14 @@ module.exports = class MPPClient { // if (role) guildMember.roles.add(role); // }); + + this.client.on('participant added', p => { + let day = true; + if (this.checkDayJoin) { + day = this.checkDayJoin(p); + } + if (this.catchPokemon && day) this.catchPokemon(p, true); + }); } static handleMessage(msg) {