From e5684e0da11e0dcad36b88164b0fea0a444ab458 Mon Sep 17 00:00:00 2001
From: mcmlxxix <>
Date: Thu, 20 May 2010 00:17:42 +0000
Subject: [PATCH] added BUYIN and BALANCE cmds. some more fixes. I still think
 this should be in /xtrn/ but digitalman disagrees. but he's from california.
 what does he know?

---
 exec/ircbots/poker/poker_commands.js  | 39 +++++++++++++++++++++++++--
 exec/ircbots/poker/poker_functions.js |  6 +++--
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/exec/ircbots/poker/poker_commands.js b/exec/ircbots/poker/poker_commands.js
index 4f4924e631..bceb860278 100644
--- a/exec/ircbots/poker/poker_commands.js
+++ b/exec/ircbots/poker/poker_commands.js
@@ -84,14 +84,15 @@ Bot_Commands["BET"].command = function (target,onick,ouh,srv,lvl,cmd) {
 		srv.o(onick,"You don't have that much money! Balance: $" + poker.users[onick].money,"NOTICE");
 		return;
 	}
-	if(cmd[1]<poker.min_bet) {
+	if(cmd[1]<poker.current_bet) {
 		srv.o(onick,"Your bet must meet the minimum! Minimum bet: $" + poker.min_bet,"NOTICE");
 		return;
 	}
 	srv.o(target,onick + " bets $" + cmd[1]);
 	poker.users[onick].money-=Number(cmd[1]);
 	poker.users[onick].bet+=Number(cmd[1]);
-	poker.current_bet=Number(cmd[1]);
+	poker.current_bet+=Number(cmd[1]);
+	srv.o(target,"Current bet: $" + poker.current_bet);
 	srv.o(onick,"Balance: $" + poker.users[onick].money,"NOTICE");
 	poker_next_turn(target,srv);
 	return;
@@ -227,3 +228,37 @@ Bot_Commands["INVITE"].command = function (target,onick,ouh,srv,lvl,cmd) {
 		+ "! /J " + target + " to join.");
 	return;
 }
+
+Bot_Commands["BALANCE"] = new Bot_Command(0,false,false);
+Bot_Commands["BALANCE"].command = function (target,onick,ouh,srv,lvl,cmd) {
+	if (!poker_games[target]) {
+		srv.o(target,"There is no active game.");
+		return;
+	}
+	if(!poker_games[target].users[onick]) {
+		srv.o(target, onick + ", I have no record for you.");
+		return;
+	}
+	srv.o(onick, "Your balance: $" + poker_games[target].users[onick].money,"NOTICE");
+	return;
+}
+
+Bot_Commands["BUYIN"] = new Bot_Command(50,false,false);
+Bot_Commands["BUYIN"].command = function (target,onick,ouh,srv,lvl,cmd) {
+	if (!poker_games[target]) {
+		srv.o(target,"There is no active game.");
+		return;
+	}
+	if(!poker_games[target].users[onick]) {
+		srv.o(target, onick + ", I have no record for you.");
+		return;
+	}
+	if(poker_games[target].users[onick].money>10) {
+		srv.o(target, onick + ", you already have money in the bank.");
+		return;
+	}
+	poker_games[target].users[onick].money=100;
+	srv.o(onick, "Your balance: $" + poker_games[target].users[onick].money,"NOTICE");
+	return;
+}
+
diff --git a/exec/ircbots/poker/poker_functions.js b/exec/ircbots/poker/poker_functions.js
index a4cc1f7da0..993aacb21f 100644
--- a/exec/ircbots/poker/poker_functions.js
+++ b/exec/ircbots/poker/poker_functions.js
@@ -188,11 +188,12 @@ function poker_init_hand(target,srv) {
 	
 	srv.o(target,poker.users_map[poker.dealer] + " is the dealer for this hand.");
 	poker.users[poker.users_map[small_blind]].bet+=poker.sm_blind;
+	poker.users[poker.users_map[small_blind]].money-=poker.sm_blind;
 	srv.o(target,"Small blind: " + poker.users_map[small_blind]  + " $" + poker.sm_blind);
 	poker.users[poker.users_map[large_blind]].bet+=poker.lg_blind;
+	poker.users[poker.users_map[large_blind]].money-=poker.lg_blind;
 	srv.o(target,"Large blind: " + poker.users_map[large_blind]  + " $" + poker.lg_blind);
 	poker.turn=get_next_player(poker,large_blind);
-	poker.min_bet=poker.lg_blind;
 }
 
 function load_scores() {
@@ -256,7 +257,8 @@ function poker_reset_game(target,srv) {
 	}
 	poker.dealer=get_next_player(poker,poker.dealer);
 	poker.round=-1;
-	poker.current_bet=poker.min_bet/2;
+	poker.current_bet=poker.min_bet;
+	poker.community_cards=[];
 	poker.pot=0;
 }
 
-- 
GitLab