2008-12-23 17:24:31 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2008 by Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of pokerth_console. *
|
|
|
|
|
* pokerth_console is free software: you can redistribute it and/or *
|
|
|
|
|
* modify it under the terms of the GNU Affero General Public License *
|
|
|
|
|
* as published by the Free Software Foundation, either version 3 of *
|
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* pokerth_console is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the *
|
|
|
|
|
* GNU Affero General Public License along with pokerth_console. *
|
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
2008-12-23 14:24:37 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2008-12-23 17:24:31 +00:00
|
|
|
using pokerth_lib;
|
2008-12-23 14:24:37 +00:00
|
|
|
|
|
|
|
|
namespace pokerth_console
|
|
|
|
|
{
|
2008-12-23 17:24:31 +00:00
|
|
|
class ConsoleCallback : pokerth_lib.ICallback
|
2008-12-23 14:24:37 +00:00
|
|
|
{
|
|
|
|
|
public void InitDone()
|
|
|
|
|
{
|
2008-12-25 21:12:59 +00:00
|
|
|
Console.WriteLine("Connection established.");
|
|
|
|
|
Console.WriteLine("Retrieving list of games...");
|
2008-12-23 14:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void JoinedGame(string name)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Successfully joined game \"{0}\".", name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GameStarted(List<string> players)
|
|
|
|
|
{
|
|
|
|
|
string outPlayers = "";
|
|
|
|
|
foreach (string s in players)
|
|
|
|
|
{
|
|
|
|
|
if (outPlayers.Length != 0)
|
|
|
|
|
outPlayers += ", ";
|
|
|
|
|
outPlayers += s;
|
|
|
|
|
}
|
2008-12-23 23:29:18 +00:00
|
|
|
Console.WriteLine("Game was started. Players: {0}.", outPlayers);
|
2008-12-23 14:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void HandStarted(int[] cards)
|
2008-12-23 14:24:37 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("\nNew hand. Your cards: {0}, {1}.",
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]));
|
2008-12-23 14:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void SmallBlind(string name, uint blind)
|
2008-12-23 22:30:02 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("{0} posts small blind (${1}).", name, blind);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BigBlind(string name, uint blind)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("{0} posts big blind (${1}).", name, blind);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void MyTurn(Hand.State state, uint highestSet, uint minimumRaise, uint money)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\n--> {0}: Your turn. Highest set: ${1}. Minimum raise: ${2}. Cash: ${3}.",
|
|
|
|
|
Log.StateToString(state), highestSet, minimumRaise, money);
|
2008-12-25 21:12:59 +00:00
|
|
|
Console.WriteLine("Enter: (f)old, (c)heck, ca(l)l, (b)et<num>, (r)aise<num>, (a)ll in");
|
2008-12-23 22:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayersTurn(Hand.State state, string player)
|
|
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("\n{0}: {1}'s turn.",
|
2008-12-23 22:30:02 +00:00
|
|
|
Log.StateToString(state),
|
|
|
|
|
player);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void ActionDone(string name, Hand.Action action, uint curBet)
|
2008-12-23 22:30:02 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("{0} {1}.", name, Log.ActionToString(action, curBet));
|
2008-12-23 22:30:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-27 09:37:53 +00:00
|
|
|
public void ActionRejected()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Your action was rejected by the server.");
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void ShowFlopCards(int[] cards)
|
2008-12-23 23:29:18 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("\n--- Flop --- [{0}, {1}, {2}]",
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]),
|
|
|
|
|
Log.CardToString(cards[2]));
|
2008-12-23 23:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void ShowTurnCards(int[] cards)
|
2008-12-23 23:29:18 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("\n--- Turn --- [{0}, {1}, {2}, {3}]",
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]),
|
|
|
|
|
Log.CardToString(cards[2]),
|
|
|
|
|
Log.CardToString(cards[3]));
|
2008-12-23 23:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-24 23:22:23 +00:00
|
|
|
public void ShowRiverCards(int[] cards)
|
2008-12-23 23:29:18 +00:00
|
|
|
{
|
2008-12-24 23:22:23 +00:00
|
|
|
Console.WriteLine("\n--- River --- [{0}, {1}, {2}, {3}, {4}]",
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]),
|
|
|
|
|
Log.CardToString(cards[2]),
|
|
|
|
|
Log.CardToString(cards[3]),
|
|
|
|
|
Log.CardToString(cards[4]));
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-25 21:12:59 +00:00
|
|
|
public void AllInState()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(); // simply print a newline
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowCards(string name, int[] cards)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("{0} shows [{1}, {2}].",
|
|
|
|
|
name,
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]));
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-25 16:46:38 +00:00
|
|
|
public void EndOfHandShowCards(string name, int[] cards, int cardsValue, bool allIn)
|
2008-12-24 23:22:23 +00:00
|
|
|
{
|
2008-12-25 21:12:59 +00:00
|
|
|
Console.WriteLine("{0} {1} [{2}, {3}] - {4}.",
|
2008-12-25 16:46:38 +00:00
|
|
|
name,
|
|
|
|
|
allIn ? "has" : "shows",
|
|
|
|
|
Log.CardToString(cards[0]),
|
|
|
|
|
Log.CardToString(cards[1]),
|
|
|
|
|
Log.CardsValueToString(cardsValue));
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-25 21:12:59 +00:00
|
|
|
public void HandResult()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-26 18:27:48 +00:00
|
|
|
public void PlayerWinsHand(string name, uint moneyWon)
|
2008-12-25 16:46:38 +00:00
|
|
|
{
|
|
|
|
|
Console.WriteLine("{0} wins ${1}.", name, moneyWon);
|
2008-12-23 23:29:18 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 18:27:48 +00:00
|
|
|
public void PlayerWinsGame(string name)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\n{0} wins the game.", name);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-26 23:05:45 +00:00
|
|
|
public void RemovedFromGame()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("You have left the game.");
|
|
|
|
|
System.Environment.Exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-26 20:01:25 +00:00
|
|
|
public void ChatText(string name, string message)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("{0}: {1}",
|
|
|
|
|
name,
|
|
|
|
|
message);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-23 14:24:37 +00:00
|
|
|
public void Error(string message)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Error: " + message);
|
2008-12-25 21:12:59 +00:00
|
|
|
Console.WriteLine("Hint: Try using a different nickname.");
|
|
|
|
|
System.Environment.Exit(1);
|
2008-12-23 14:24:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|