forked from rosehay22/Jack-the-Black-Frog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
181 lines (163 loc) · 6.42 KB
/
index.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Qconst Discord = require("discord.js");
const bot = new Discord.Client();
const token = "NTc4NTc4Mjc2MTUxMzI4NzY4.XN1p_Q.Wqwy-6sdjZvbkd1nONSao-ShcuA"
var draw1;
var draw2;
var players = [];
var credits = [];
var cardNums = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"];
var royals = ["Jack", "Queen", "King"];
var card3 = Math.floor(Math.random() * 13);
var game = false;
var total = 0;
var c3f = ["10", "Jack", "Queen", "King"];
bot.on("ready", async() => {
console.log(`${bot.user.username} is online!`);
bot.user.setActivity("?help for help", {
type: 'Playing'
});
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?help") {
msg.channel.send("---Help Menu---");
msg.channel.send("?credits - shows balance");
msg.channel.send("?blackjack - play blackjack (what did you expect?)")
msg.channel.send("?whom - shows the authors");
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?whom") {
msg.channel.send("2019 Programmed and tested by Hayden Rose and David Kleyman");
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?blackjack" && game == false) {
msg.channel.send("Starting new game");
if (!players.includes(msg.author.id)) {
console.log("adding new user! " + msg.author.id);
players.push(msg.author.id);
credits.push(200);
}
credits[players.indexOf(msg.author.id)] -= 50;
draw1 = Math.floor(Math.random() * 13);
draw2 = Math.floor(Math.random() * 13);
if (draw1 > 10) {}
console.log("New Game by " + msg.author.id);
console.log(draw1);
console.log(draw2);
game = true;
total = 0;
msg.channel.send("--Commands--");
msg.channel.send("?hit - draws new card to add to total");
msg.channel.send("?stay - keeps current cards for final amount");
if (draw1 > 9 && draw2 > 9) {
if (draw2 = 10) {
total = 1 + draw1 + draw2;
} else if (draw = 11) {
total = draw1 + draw2;
} else {
total = draw1 + draw2 - 1;
}
if (draw2 = 10) {
total += 1;
} else {
total -= 1;
}
msg.channel.send("You pulled a " + royals[(draw2) - 10] + " and a " + royals[(draw1) - 10] + " for a total of 20");
} else if (draw1 > 9) {
if (draw1 = 10) {
total = 1 + draw1 + draw2;
} else if (draw1 = 11) {
total = draw1 + draw2;
} else {
total = draw1 + draw2 - 1
}
msg.channel.send("You pulled a " + cardNums[draw2] + " and a " + royals[(draw1) - 10] + " for a total of " + total);
} else if (draw2 > 9) {
if (draw2 = 10) {
total = 1 + draw1 + draw2;
} else if (draw2 = 11) {
total = draw1 + draw2;
} else {
total = draw1 + draw2 - 1
}
msg.channel.send("You pulled a " + royals[(draw2) - 10] + " and a " + cardNums[draw1] + " for a total of " + total);
} else {
total = 2 + draw1 + draw2;
msg.channel.send("You pulled a " + cardNums[draw2] + " and a " + cardNums[draw1] + " for a total of " + total);
}
} else {
msg.channel.send("There is already a game in progress!");
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?hit" && game == true) {
card3 = Math.floor(Math.random() * 13);
if (card3 >= 10) {
card3 = 10;
c3f[Math.floor(Math.random() * 3)];
msg.channel.send("You pulled a " + c3f[Math.floor(Math.random() * 3)] + " and had " + total);
total += card3;
} else {
msg.channel.send("You pulled a " + cardNums[card3] + " and had a total of " + total);
total = total + 1 + card3
}
msg.channel.send("Your new Total is " + total);
if (total > 21) {
msg.channel.send("Bust!");
game = false;
}
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?stay" && game == true) {
var dealerTotal = Math.floor(Math.random() * 6) + 17;
msg.channel.send("You stood at a final total of " + total);
msg.channel.send("The dealer stood with a total of " + dealerTotal);
if (total <= dealerTotal && dealerTotal <= 21) {
msg.channel.send("You Lose");
} else {
msg.channel.send("You Win!");
credits[players.indexOf(msg.author.id)] += 100;
}
game = false;
msg.channel.send("You now have " + credits[players.indexOf(msg.author.id)] + " credits");
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?credits" && players.includes(msg.author.id)) {
msg.channel.send("You currently have " + credits[players.indexOf(msg.author.id)] + "credits!");
} else {
msg.channel.send("You have not setup an account, use ?blackjack to start a game and setup your account!");
}
}
});
bot.on('message', msg => {
if (msg.author.id != bot.user.id) {
if (msg.content == "?shop" && players.includes(msg.author.id)) {
msg.channel.send("---Shop---");
msg.channel.send("Basic Rank - 500 Credits");
msg.channel.send("Cool Kid - 750 Credits");
msg.channel.send("Epic Gamer - 1000 Credits");
msg.channel.send("Overlord - 2000 credits");
msg.channel.send("----------");
} else {
msg.channel.send("You have not setup an account, use ?blackjack to start a game to setup your account!");
}
}
});
bot.login(token);
process.on('exit', code => {
console.log(`Whoa! Exit code ${code}, cleaning up...`);
});