-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.js
39 lines (37 loc) · 1.31 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Tools that all components might want to use
*/
//Shuffle an array of cards to not always get the same cards
module.exports = {
shuffleArray: function shuffleArray(o) {
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
},
//Select a random card from the booster to set as the "playing" for the bot.
setActivity: function setActivity(booster, client) {
var randcard = Math.floor(Math.random() * booster.length);
client.user.setActivity(booster[randcard].toString(), { type: 'PLAYING'});
},
log: function log(event) {
console.log("[" + new Date() + "] " + event);
},
setActivityCard: function (cardname, client) {
client.user.setActivity(cardname, { type: 'PLAYING'});
},
rollDice: function (max) {
return Math.floor(Math.random() * max +1);
},
setPatreonText: function (text) {
// 1 of every 6 should include paypal link
if(Math.floor(Math.random() * 5) == 0) {
return "paypal.me/yunra";
} else {
return text;
}
},
removeCardtypeFromList: function (array, cardType) {
return array.filter(function(element){
return !element.type_line.includes(cardType);
});
}
};