public void Reaction(GameState state, GameAction reaction) { }
/// <summary>Tries to parse an action.</summary> /// <param name="str"> /// The string repersenting an action. /// </param> /// <param name="action"> /// The actual action. /// </param> /// <returns> /// True, if the parsing succeeded, otherwise false. /// </returns> /// <remarks> /// A action is always represented by two characters: /// The first represents the action height and can be any number 2-9. /// T, J, Q, K, A are 10, Jack, Queen, King and Ace respectively. /// /// The second character represents the suit and can be d, c, h or s. /// For Diamonds, Clubs, Hearts and Spades respectively. /// </remarks> public static bool TryParse(string str, out GameAction action) { action = GameAction.Check; if (String.IsNullOrEmpty(str)) { return true; } var splitted = str.Split(' '); GameActionType tp; if (splitted.Length < 3 && Enum.TryParse<GameActionType>(splitted[0], out tp)) { if(tp != GameActionType.raise && (splitted.Length == 1 || splitted[1] == "0")) { action = new GameAction() { m_Value = (int)tp }; return true; } int amount; if (Int32.TryParse(splitted[1], out amount)) { action = Raise(amount); return true; } } return false; }