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