public void Act(GameAction action) { Actions.Add(action); switch (action.ActionType) { case GameActionType.call: break; case GameActionType.check: break; case GameActionType.fold: Pot = 0; break; case GameActionType.raise: Stack -= action.Amount; Pot += action.Amount; break; } }
/// <summary>Tries to parse an action.</summary> /// <param name="str"> /// The string representing an action. /// </param> /// <param name="action"> /// The actual action. /// </param> /// <returns> /// True, if the parsing succeeded, otherwise false. /// </returns> 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], true, out tp)) { if (tp != GameActionType.raise && (splitted.Length == 1 || splitted[1] == "0")) { action = new GameAction() { m_Value = (ushort)tp }; return true; } int amount; if (Int32.TryParse(splitted[1], out amount)) { action = Raise(amount < 0 ? 0 : amount); return true; } } return false; }