This commit is contained in:
Flummi 2023-07-12 18:38:42 +02:00
parent efd32e69e7
commit f234fe0a08
Signed by: Flummi
GPG Key ID: AA2AEF822A6F4817
4 changed files with 36 additions and 2 deletions

6
package-lock.json generated
View File

@ -12,9 +12,15 @@
],
"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",

View File

@ -13,6 +13,7 @@
"author": "Flummi",
"license": "ISC",
"dependencies": {
"@xpressit/winning-poker-hand-rank": "^0.1.6",
"cuffeo": "^1.2.2"
}
}

View File

@ -35,7 +35,7 @@ export default new class handranker {
p = this.#ranks.readUInt32LE(p * 4);
return {
handType: p >> 12,
//handType: p >> 12,
handRank: p & 0x00000fff,
value: p,
handName: this.handtypes[p >> 12]

View File

@ -1,5 +1,6 @@
import cuffeo from 'cuffeo';
import handranker from './inc/handranker.mjs';
import { rankHands } from '@xpressit/winning-poker-hand-rank';
import helper from './inc/helper.mjs';
const cfg = helper.config;
@ -47,6 +48,32 @@ bot.on("message", async e => {
await e.write(`PRIVMSG ${e.user.nick} ${command}`);
}
}
if(e.message.startsWith(".cards ")) {
let cards = [];
try {
cards = JSON.parse(e.message.slice(7));
} catch(err) {
return e.reply('das ist kein Array du Pflaumennase');
}
const all = cards;
const hand = cards.slice(0, 2);
const board = cards.slice(2);
let oldrank;
let newrank;
try {
oldrank = rankHands('texas', board, [hand])[0];
newrank = handranker.evalHand(all);
} catch(err) {
return e.reply(JSON.stringify(err));
}
e.reply('old: ' + JSON.stringify(oldrank));
e.reply('new: ' + JSON.stringify(newrank));
return;
}
if(e.message.match(new RegExp(`^${e.self.me.nickname}: Your bank account`))) {
env.bank = +e.message.match(/is: (\d+) \(/)[1];
}
@ -149,7 +176,7 @@ bot.on("message", async e => {
return e.reply(['huan!', 'f']);
if(env.winchance < 6500) {
if(helper.rand(5) === 1 && env.callamount < (helper.rand(6,10) * 10)) { // bad hand, call anyway
if(helper.rand(5) === 1 && env.callamount < (helper.rand(2, 6) * 10)) { // bad hand, call anyway
action = 'c';
}
else { // bad hand, fold