Compare commits
No commits in common. "27cca680bcca2aadbf6e2caaf33bdaed2bdc8373" and "37091884854e7b8966a420b9731bf01fca5668fb" have entirely different histories.
27cca680bc
...
3709188485
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
node_modules
|
||||
config.json
|
35
package-lock.json
generated
35
package-lock.json
generated
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"name": "schmirc",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "schmirc",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@xpressit/winning-poker-hand-rank": "^0.1.6",
|
||||
"cuffeo": "^1.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@xpressit/winning-poker-hand-rank": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@xpressit/winning-poker-hand-rank/-/winning-poker-hand-rank-0.1.6.tgz",
|
||||
"integrity": "sha512-l7b8GAKOT6k79qKF/SesCgQLvCjHZkhihf5QhgcL9w3hiya2JeCVyg07TVayoyO8PzDq56MH+yKk5rcbDMYScw=="
|
||||
},
|
||||
"node_modules/cuffeo": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/cuffeo/-/cuffeo-1.2.2.tgz",
|
||||
"integrity": "sha512-Pd2AL/Zp5RCAbaSbT7rLUOyxSEVCFovihaIaje7uYzpQMzIwPbFapQ/mn2d2iz+Tbkjs9LF+FD5JzAvANh9Wzw==",
|
||||
"dependencies": {
|
||||
"flumm-fetch": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/flumm-fetch": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz",
|
||||
"integrity": "sha512-pZ5U0hheCSW43vfGZQMunr03U7rUOX+iy2y13Tu4nc3iRL+E/Qfeo5nZ2B2JMYKOGIx1A1anUYOz+ulyhouyjg=="
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
15
package.json
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"name": "schmirc",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node ./src/index.mjs"
|
||||
},
|
||||
"author": "Flummi",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@xpressit/winning-poker-hand-rank": "^0.1.6",
|
||||
"cuffeo": "^1.2.2"
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
export default new class handranker {
|
||||
constructor() {
|
||||
return this;
|
||||
};
|
||||
|
||||
};
|
125
src/index.mjs
125
src/index.mjs
|
@ -1,125 +0,0 @@
|
|||
import cuffeo from 'cuffeo';
|
||||
import { rankHands } from '@xpressit/winning-poker-hand-rank';
|
||||
import cfg from '../config.json' assert { type: 'json' };
|
||||
|
||||
const bot = await new cuffeo(cfg.clients);
|
||||
|
||||
const g_cards = { "♠": "S", "♣": "C", "♦": "D", "♥": "H" };
|
||||
|
||||
const stripColors = msg => msg.replace(/\x03\d{0,2}(,\d{0,2}|\x02\x02)?/g, '');
|
||||
|
||||
const parseCards = msg => {
|
||||
const output = [];
|
||||
for(const c of stripColors(msg).match(/(\w+)([♠♣️♦♥️️])/g)) {
|
||||
if(c.length === 3)
|
||||
output.push(`T${g_cards[c[2]]}`);
|
||||
else
|
||||
output.push(`${c[0]}${g_cards[c[1]]}`);
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
let hand = false;
|
||||
let board = false;
|
||||
let winchance = false;
|
||||
let called = false;
|
||||
let joined = false;
|
||||
let callphase = true;
|
||||
let callamount = 0;
|
||||
let pot = 0;
|
||||
|
||||
bot.on("message", e => {
|
||||
if(e.message === ".pj" || e.message === "pj" && !hand && !joined) {
|
||||
joined = true;
|
||||
return e.reply("pj");
|
||||
}
|
||||
if(e.message === ".pl" && !hand)
|
||||
return e.reply("pl");
|
||||
if(e.message === ".bb" && !hand)
|
||||
return e.reply("bb");
|
||||
if(e.message === ".bl" && !hand)
|
||||
return e.reply("bank loan");
|
||||
if(e.message === ".s" && hand)
|
||||
return e.reply("s");
|
||||
|
||||
if(e.user.nick !== 'hirc' || !hand)
|
||||
return;
|
||||
|
||||
if(e.message.match(/(small|big) blind/)) {
|
||||
callamount = +e.message.match(/pays (\d+) \(/)[1];
|
||||
callphase = true;
|
||||
pot += callamount;
|
||||
console.log(`callphase: ${callphase ? 'yes': 'no'}; callamount: ${callamount}; potsize: ${pot}; winchance: ${winchance}`);
|
||||
}
|
||||
if(e.message.match(/raises the pot/)) {
|
||||
callamount = +e.message.match(/pot by (\d+)/)[1];
|
||||
callphase = true;
|
||||
pot += callamount;
|
||||
console.log(`callphase: ${callphase ? 'yes': 'no'}; callamount: ${callamount}; potsize: ${pot}; winchance: ${winchance}`);
|
||||
}
|
||||
if(e.message.match(/calls \d+\./)) {
|
||||
callamount = +e.message.match(/calls (\d+)\./)[1];
|
||||
pot += callamount;
|
||||
console.log(`callphase: ${callphase ? 'yes': 'no'}; callamount: ${callamount}; potsize: ${pot}; winchance: ${winchance}`);
|
||||
}
|
||||
if(e.message.match(/check/)) {
|
||||
callphase = false;
|
||||
console.log(`callphase: ${callphase ? 'yes': 'no'}; callamount: ${callamount}; potsize: ${pot}; winchance: ${winchance}`);
|
||||
}
|
||||
|
||||
if(e.message.startsWith("Current player: schmirc") && hand) {
|
||||
if(!winchance)
|
||||
return e.reply('c');
|
||||
|
||||
if(winchance >= 55 && callamount) {
|
||||
if((~~(Math.random() * 2)) === 1) {
|
||||
return e.reply(`r ${callamount + (~~(Math.random() * 2 + 2) * 10)}`)
|
||||
}
|
||||
else {
|
||||
return e.reply('c');
|
||||
}
|
||||
}
|
||||
|
||||
if(e.message.match(/to call/)) {
|
||||
if(winchance >= 30) {
|
||||
if(called)
|
||||
return e.reply('c');
|
||||
else {
|
||||
called = true;
|
||||
return e.reply( (~~(Math.random() * 2)) === 1 ? 'c' : 'f' );
|
||||
}
|
||||
}
|
||||
else {
|
||||
return e.reply(((~~Math.random() * 5) === 1) ? 'f' : 'c');
|
||||
}
|
||||
}
|
||||
|
||||
return e.reply('c');
|
||||
}
|
||||
if(e.message.match(/Game ended/) || e.message.match(/wins the pot/)) {
|
||||
//e.reply(`my hand: ${hand.join(', ')} (${winchance}%)`);
|
||||
hand = false;
|
||||
board = false;
|
||||
winchance = false;
|
||||
called = false;
|
||||
joined = false;
|
||||
pot = 0;
|
||||
callphase = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(e.message.match(/^(Flop|Turn|River)/) && e.user.nick === 'hirc') {
|
||||
board = parseCards(e.message);
|
||||
|
||||
console.log(board, hand);
|
||||
|
||||
const rank = rankHands('texas', board, [hand])[0];
|
||||
winchance = (9999 - rank.rank) / 100;
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("notice", msg => {
|
||||
if(msg.match(/^Your hand/)) {
|
||||
hand = parseCards(msg);
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user