From f948b2bcaf47b49b5f77579afb44852983c6afc9 Mon Sep 17 00:00:00 2001
From: cyan <>
Date: Tue, 18 May 2010 18:02:38 +0000
Subject: [PATCH] * Plenty of updates

---
 exec/ircbots/poker/poker_commands.js  | 28 +++++++++++++++++++++++++--
 exec/ircbots/poker/poker_functions.js |  9 +++------
 exec/ircbots/poker/pokerbot.js        |  2 +-
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/exec/ircbots/poker/poker_commands.js b/exec/ircbots/poker/poker_commands.js
index d5c878af2b..d4777cc56a 100644
--- a/exec/ircbots/poker/poker_commands.js
+++ b/exec/ircbots/poker/poker_commands.js
@@ -24,7 +24,7 @@ this.Bot_Commands["GO"].command = function (target,onick,ouh,srv,lvl,cmd) {
 		srv.o(target, "No poker game to 'GO' with. Type '" + get_cmd_prefix() + "DEAL' to "
 			+ "start a new one.");
 		return;
-	} else if(poker_games[target].round>0) {
+	} else if(poker_games[target].round>=0) {
 		srv.o(target, "This hand has already started.");
 		return;
 	}
@@ -32,6 +32,7 @@ this.Bot_Commands["GO"].command = function (target,onick,ouh,srv,lvl,cmd) {
 		srv.o(target, "At least two players are necessary to start the game.");
 		return;
 	}
+	poker_games[target].round = 0;
 	poker_init_hand(target);
 	poker_deal_hole_cards(target,srv);
 	poker_prompt_player(target,srv);
@@ -46,10 +47,12 @@ this.Bot_Commands["FOLD"].command = function (target,onick,ouh,srv,lvl,cmd) {
 	} else	if (!poker_games[target].users[onick.toUpperCase()]) {
 		srv.o(target, onick + ", you aren't playing this game.");
 		return;
-	} else if(poker_games[target].round<1) {
+	} else if(poker_games[target].round<0) {
 		srv.o(target, onick + ", the game hasn't started yet.");
 		return;
 	}
+
+	if(!poker_verify_game_status(target,srv,onick)) return;
 	
 	delete poker_games[target].users[onick.toUpperCase()];
 	srv.o(target, onick + " folded their hand.");
@@ -151,3 +154,24 @@ this.Bot_Commands["LIST"].command = function (target,onick,ouh,srv,lvl,cmd) {
 	return;
 }
 
+this.Bot_Commands["SHOW"] = new Bot_Command(0,false,false);
+this.Bot_Commands["SHOW"].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.toUpperCase()]) {
+		srv.o(target, onick + ", you aren't playing this game.");
+		return;
+	}
+	if(poker_games[target].round<0) {
+		srv.o(target, onick + ", the game hasn't started yet.");
+		return;
+	}
+
+	srv.o(target, onick + " shows: "
+		+ poker_show_card(poker_games[target].users[onick.toUpperCase()].cards[0])
+		+ poker_show_card(poker_games[target].users[onick.toUpperCase()].cards[1])
+	);
+}
+
diff --git a/exec/ircbots/poker/poker_functions.js b/exec/ircbots/poker/poker_functions.js
index 48247dbd4a..ff9e56d4f2 100644
--- a/exec/ircbots/poker/poker_functions.js
+++ b/exec/ircbots/poker/poker_functions.js
@@ -76,7 +76,6 @@ function poker_next_turn(target,srv) {
 
 function poker_deal_flop(target,srv) { 
 	var poker_game=poker_games[target];
-	poker_game.round = 2;
 	poker_game.community_cards[0] = poker_game.deck.deal();
 	poker_game.community_cards[1] = poker_game.deck.deal();
 	poker_game.community_cards[2] = poker_game.deck.deal();
@@ -89,7 +88,6 @@ function poker_deal_flop(target,srv) {
 
 function poker_deal_turn(target,srv) {
 	var poker_game=poker_games[target];
-	poker_game.round = 3;
 	poker_game.community_cards[3] = poker_game.deck.deal();
 	srv.o(target, "The Turn: "
 		+ poker_show_card(poker_game.community_cards[0])
@@ -101,7 +99,6 @@ function poker_deal_turn(target,srv) {
 
 function poker_deal_river(target,srv) {
 	var poker_game=poker_games[target];
-	poker_game.round = 4;
 	poker_game.community_cards[4] = poker_game.deck.deal();
 	srv.o(target, "The River: " + 
 		+ poker_show_card(poker_game.community_cards[0])
@@ -113,7 +110,7 @@ function poker_deal_river(target,srv) {
 }
 
 function poker_show_card(card) {
-	return(card.color + "[ " + card.char + " ]");
+	return(card.color + "[ " + card.char + " ] ");
 }
 
 function poker_load_pot(target,srv) {
@@ -129,9 +126,9 @@ function poker_load_pot(target,srv) {
 function poker_prompt_player(target,srv) {
 	var poker=poker_games[target];
 	var turn=poker.users_map[poker.turn];
-	srv.o(turn, "It is your turn. You may CHECK,  CALL, BET, RAISE or FOLD"
+	srv.o(turn, "It is your turn. You may CHECK, CALL, BET, RAISE or FOLD. "
+		+ "Minimum bet: $" + poker.current_bet
 		,"NOTICE");
-	srv.o(turn, "Minimum bet: $" + poker.current_bet, "NOTICE");
 }
 
 function poker_verify_game_status(target,srv,onick) {
diff --git a/exec/ircbots/poker/pokerbot.js b/exec/ircbots/poker/pokerbot.js
index c2f86bd46b..0f07ff3cbb 100644
--- a/exec/ircbots/poker/pokerbot.js
+++ b/exec/ircbots/poker/pokerbot.js
@@ -46,7 +46,7 @@ function Poker_Game()
 	this.sm_blind=5;
 	this.min_bet=this.sm_blind;
 	this.current_bet=this.min_bet;
-	this.round=0;
+	this.round=-1;
 	this.deck=new Deck();
 	this.community_cards=new Array();
 	this.paused=false;
-- 
GitLab