debug shmebug
This commit is contained in:
parent
20c07af542
commit
efd32e69e7
|
@ -1,4 +1,5 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import { bot } from '../index.mjs';
|
||||
|
||||
let _config;
|
||||
try {
|
||||
|
@ -39,4 +40,9 @@ export default new class {
|
|||
output.push(c.length === 3 ? `T${this.suits[c[2]]}` : `${c[0]}${this.suits[c[1]]}`);
|
||||
return output;
|
||||
};
|
||||
|
||||
async sendMsg(msg) {
|
||||
return (await bot.clients.filter(async c => (await c).name == this.config.getFull().clients[0].network)[0])
|
||||
.client.sendmsg("normal", this.config.get('channel'), msg);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,10 +3,10 @@ import handranker from './inc/handranker.mjs';
|
|||
import helper from './inc/helper.mjs';
|
||||
|
||||
const cfg = helper.config;
|
||||
const bot = await new cuffeo(cfg.getFull().clients);
|
||||
export const bot = await new cuffeo(cfg.getFull().clients);
|
||||
|
||||
const env = {
|
||||
gamestate: 'preflop', // [preflop,flop,turn,river]
|
||||
export const env = {
|
||||
gamestate: 'notstarted, ' + (cfg.get('autojoin') ? 'autojoin' : 'no autojoin'), // [notstarted,preflop,flop,turn,river]
|
||||
hand: false,
|
||||
board: false,
|
||||
winchance: false,
|
||||
|
@ -31,8 +31,8 @@ bot.on("message", async e => {
|
|||
if(e.message === `.${e.self.me.nickname} help`) {
|
||||
await e.write(`PRIVMSG ${e.user.nick} I always say hirc schmirc, available commands are:`);
|
||||
const commands = [
|
||||
' .pj -- poker join',
|
||||
' .pl -- poker leave',
|
||||
' .pj -- poker join (activates autojoin)',
|
||||
' .pl -- poker leave (deactivates autojoin)',
|
||||
' .bb -- bank balance',
|
||||
' .bl -- bank loan',
|
||||
' .d -- deal',
|
||||
|
@ -80,6 +80,9 @@ bot.on("message", async e => {
|
|||
return e.reply("f");
|
||||
if(e.message === ".d" && !env.hand)
|
||||
return e.reply("d");
|
||||
if(e.message === ".env" && cfg.get('debug')) {
|
||||
e.reply(JSON.stringify(env));
|
||||
}
|
||||
|
||||
if(e.user.nick !== cfg.get('pokerbot') || !env.hand)
|
||||
return;
|
||||
|
@ -108,7 +111,12 @@ bot.on("message", async e => {
|
|||
if(e.message.endsWith('blind).')) { // blinds
|
||||
env.callamount = +e.message.match(/pays (\d+) \(/)[1];
|
||||
env.pot += env.callamount;
|
||||
|
||||
const oldstate = env.gamestate;
|
||||
env.gamestate = 'preflop';
|
||||
if(cfg.get('debug') && oldstate !== env.gamestate)
|
||||
e.reply(`${oldstate} -> ${env.gamestate}`);
|
||||
|
||||
if(e.message.includes(e.self.me.nickname)) {
|
||||
env.bank -= env.callamount;
|
||||
if(cfg.get('debug'))
|
||||
|
@ -116,6 +124,15 @@ bot.on("message", async e => {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// bot is broke :(
|
||||
if(e.message.includes('You don\'t have enough money')) {
|
||||
e.reply(['fugggggg', 'f']);
|
||||
if(env.bank < 100) {
|
||||
e.reply('bank loan');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// bot's turn
|
||||
if(e.message.match(new RegExp(`Current player: ${e.self.me.nickname}( |$)`))) {
|
||||
|
@ -127,6 +144,9 @@ bot.on("message", async e => {
|
|||
|
||||
if(e.message.endsWith('to call)')) { // callphase
|
||||
env.callamount = +e.message.match(/\((\d+) to call\)/)[1];
|
||||
|
||||
if(env.callamount > env.bank) // not enough money lol
|
||||
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
|
||||
|
@ -178,8 +198,8 @@ bot.on("message", async e => {
|
|||
const oldstate = env.gamestate;
|
||||
env.gamestate = e.message.match(/(\w+): /)[1].toLowerCase();
|
||||
|
||||
//if(cfg.get('debug'))
|
||||
// e.reply(`${oldstate} -> ${env.gamestate}`);
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`${oldstate} -> ${env.gamestate}`);
|
||||
|
||||
const rank = handranker.evalHand([...env.board, ...env.hand]);
|
||||
env.winchance = rank.value;
|
||||
|
@ -200,7 +220,11 @@ bot.on("message", async e => {
|
|||
e.reply(`bank: ${env.bank}`);
|
||||
}
|
||||
|
||||
env.gamestate = 'preflop';
|
||||
const oldstate = env.gamestate;
|
||||
env.gamestate = 'notstarted, ' + (cfg.get('autojoin') ? 'autojoin' : 'no autojoin');
|
||||
if(cfg.get('debug'))
|
||||
e.reply(`${oldstate} -> ${env.gamestate}`);
|
||||
|
||||
env.hand = false;
|
||||
env.board = false;
|
||||
env.winchance = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user