/// <summary> /// <para>Initializes an instance of the <see cref="ConsoleFiveGameDrawClient"/> class.</para> /// </summary> public ConsoleFiveGameDrawClient(IRulesInterpreter client) : base(client) // pass null to the base class but fix it later { }
/// <summary> /// <para>Initializes an instance of the <see cref="SimpleFiveCardStrategy"/> class.</para> /// </summary> /// <param name="client">The client which uses the strategy. It is used to determine the automated player hand. /// </param> public SimpleFiveCardStrategy(IRulesInterpreter client) { this.client = client; }
/// <summary> /// Creates a new instance of the ConsoleClientHelper /// </summary> /// <param name="client">The client which this helper helps.</param> public ConsoleClientHelper(IRulesInterpreter client) { this.client = client; }
/// <summary> /// <para>Initializes an instance of the <see cref="AiClientHelper"/> class.</para> /// </summary> /// <param name="client">The client which this helper helps. /// </param> /// <param name="helper">The concrete helper which is used for unimportant I/O</param> public AiClientHelper(IClientHelper helper, IRulesInterpreter client) : base(helper) { this.client = client; }
/// <summary> /// <para>Initializes an instance of the <see cref="ConsoleTexasHoldemClient"/> class.</para> /// </summary> /// <param name="privateCardCount">The number of cards to print as player cards. The rest are printed as community cards /// </param> /// <param name="interpreter">The interpreter which provide game rules interpretation</param> public ConsoleTexasHoldemClient(IRulesInterpreter interpreter, int privateCardCount) : base(interpreter) { this.privateCardCount = privateCardCount; }
/// <summary> /// <para>Initializes an instance of the <see cref="ConsoleTexasHoldemClient"/> class.</para> /// </summary> /// <param name="interpreter">The interpreter which provide game rules interpretation</param> public ConsoleTexasHoldemClient(IRulesInterpreter interpreter) : this(interpreter, 2) { } // 2 is the default "hole" cards of texas hold'em
private int privateCardsCount;// texas hold'em has 2 private "hole" cards /// <summary> /// <para>Initializes an instance of the <see cref="TexasHoldemGuiClient"/> class.</para> /// </summary> /// <param name="initialName">The initial user name which is the login name of the player /// </param> /// <param name="client">The client which runs the game, it is used to get the player hands /// </param> public TexasHoldemGuiClient(string initialName, IRulesInterpreter client, int privateCardsCount) : base(initialName, client) { this.privateCardsCount = privateCardsCount; }
/// <summary> /// <para>Initializes an instance of the <see cref="TexasHoldemGuiClient"/> class.</para> /// </summary> /// <param name="initialName">The initial user name which is the login name of the player /// </param> /// <param name="client">The client which runs the game, it is used to get the player hands /// </param> public TexasHoldemGuiClient(IRulesInterpreter client, int privateCardsCount) : base(client) { this.privateCardsCount = privateCardsCount; }
/// <summary> /// <para>Initializes an instance of the <see cref="FiveCardDrawGuiClient"/> class.</para> /// </summary> /// <param name="initialName">The initial user name which is the login name of the player /// </param> /// <param name="client">The client which runs the game, it is used to get the player hands /// </param> public FiveCardDrawGuiClient(IRulesInterpreter client) : base(client) { }
/// <summary> /// <para>Initializes an instance of the <see cref="FiveCardDrawGuiClient"/> class.</para> /// </summary> /// <param name="initialName">The initial user name which is the login name of the player /// </param> /// <param name="client">The client which runs the game, it is used to get the player hands /// </param> public FiveCardDrawGuiClient(string initialName, IRulesInterpreter client) : base(initialName, client) { }
/// <summary> /// <para>Initializes an instance of the <see cref="AiFiveCardDrawClient"/> class.</para> /// </summary> /// <param name="helper">The concrete helper which is used for unimportant I/O</param> /// <param name="interpreter">The rules interpreter which is used by the automated client</param> public AiFiveCardDrawClient(IFiveCardClientHelper helper, IRulesInterpreter interpreter) : base(helper, interpreter) { this.fiveCardHelper = helper; }
/// <summary> /// The console application entry class /// </summary> /// <param name="args"> /// The command line arguments. /// </param> static void Main(string[] args) { try { // print the command line usage if the arguments do not match if (args.Length < 2) { Console.WriteLine("Usage: <server address | Game Mode> <port>"); Console.WriteLine("server address: ip or dns"); Console.WriteLine("Game Mode: texas,five,seven,omaha"); Console.WriteLine("port: the port in which the server runs"); } else { int port = -1; string serverIp = string.Empty; ServerGame game = ServerGame.FiveCardDraw; port = int.Parse(args[1]); // test to see if the game mode is recognized if (args[0] == "texas") { game = ServerGame.TexasHoldem; } else if (args[0] == "five") { game = ServerGame.FiveCardDraw; } else if (args[0] == "seven") { game = ServerGame.SevenCardStud; } else if (args[0] == "omaha") { game = ServerGame.OmahaHoldem; } else // assume the argument is an ip or dns { serverIp = args[0]; } // found a match to the game if (serverIp == string.Empty) { BaseEngine server = null; WcfEngineHost binaryHelper = new WcfEngineHost(); switch (game) { case ServerGame.FiveCardDraw: server = new FiveGameDrawServer(binaryHelper); break; case ServerGame.TexasHoldem: server = new TexasHoldemServer(binaryHelper); break; case ServerGame.SevenCardStud: server = new SevenCardStudServer(binaryHelper); break; case ServerGame.OmahaHoldem: server = new OmahaHoldemServer(binaryHelper); break; } System.Threading.ManualResetEvent waitHandle = new System.Threading.ManualResetEvent(false); binaryHelper.Initialize(server, game, port, waitHandle); // initialize the server and run until the game is over server.Initialize(); Console.WriteLine("Press enter to stop the registration"); Console.ReadLine(); waitHandle.Set(); server.Run(); waitHandle.Close(); } else { // if the arguments count is higher than 2 assume the process started will be played by an AI engine. bool useAi = args.Length > 2; // this is the base client which will hold the connected game ClientHelperBridge clientBridge = new ClientHelperBridge(); RulesInterpreterBridge rulesBridge = new RulesInterpreterBridge(); BaseWcfClient client = new BaseWcfClient(clientBridge); clientBridge.ClientHelper = new ConsoleClientHelper(rulesBridge); ServerDetails result = client.Initialize(serverIp, port); // check the result of the connection if (result.CanConnect) { IClientHelper outerClient = null; if (useAi) { switch (result.Game) { case ServerGame.FiveCardDraw: outerClient = new FiveGameDrawClient(new AiFiveCardDrawClient(new ConsoleFiveGameDrawClient(rulesBridge), rulesBridge)); break; case ServerGame.OmahaHoldem: outerClient = new OmahaHoldemClient(new AiClientHelper(new ConsoleTexasHoldemClient(rulesBridge, 4), rulesBridge)); break; case ServerGame.SevenCardStud: outerClient = new GameClient <SevenCardStudGame>(new AiClientHelper(new ConsoleClientHelper(rulesBridge), rulesBridge)); break; case ServerGame.TexasHoldem: outerClient = new GameClient <TexasHoldem>(new AiClientHelper(new ConsoleTexasHoldemClient(rulesBridge), rulesBridge)); break; } } else { switch (result.Game) { case ServerGame.FiveCardDraw: outerClient = new FiveGameDrawClient(new ConsoleFiveGameDrawClient(rulesBridge)); break; case ServerGame.OmahaHoldem: outerClient = new OmahaHoldemClient(new ConsoleTexasHoldemClient(rulesBridge, 4)); break; case ServerGame.SevenCardStud: outerClient = new GameClient <SevenCardStudGame>(new ConsoleClientHelper(rulesBridge)); break; case ServerGame.TexasHoldem: outerClient = new GameClient <TexasHoldem>(new ConsoleTexasHoldemClient(rulesBridge)); break; } } IRulesInterpreter interpreter = (IRulesInterpreter)outerClient; rulesBridge.Interpreter = interpreter; if (result.Game == ServerGame.FiveCardDraw) { clientBridge.FiveCardHelper = (IFiveCardClientHelper)outerClient; } else { clientBridge.ClientHelper = outerClient; } client.Connect(); // run until the game is over client.Run(); client.Disconnect(); } else { Console.WriteLine("Game is in progress. Server refused connection"); } } } } catch (Exception e) { // an error occured. print an unfriendly message Console.WriteLine("Uh oh, I did bad"); // when a debugger is attached, break it so you can learn of the error. if (System.Diagnostics.Debugger.IsAttached) { Console.WriteLine(e.Message); System.Diagnostics.Debugger.Break(); } } }
/// <summary> /// <para>Initializes an instance of the <see cref="BetterLimitStrategy"/> class.</para> /// </summary> /// <param name="preparedLimit">The amount of money which marks the lower limit for the strategy. /// </param> /// <param name="client">The ownining client /// </param> public BetterLimitStrategy(int preparedLimit, IRulesInterpreter client) { this.preparedLimit = preparedLimit; this.client = client; }