public void TakeAction(IntPtr hPokerTable, Decision decision)
        {
            // Atencion!!! Decision gameState es null!!! no usar!!!!
            // Check that the table still exists
            if (!WindowsAPI.IsWindow(hPokerTable))
            {
                logger.Error( "is no longer a valid window handle. Giving up!" );
                return;
            }

            // First check if the decision has already been executed
            if (!AllowsDecisionExecution(decision))
            {
                logger.Error("decision [" + decision.token + "] is already executed. Giving up!");
                return;
            }

            // make sure this window isn't obscured behind some other window
            logger.Info("is set as exclusive acting table and is beign brought to the front");
            TableWindowController.SetTableExclusiveMode(hPokerTable);
            TableInputSimulator.BringWindowToTop(hPokerTable);

            logger.Debug("sets the next expected action to " + decision.action + ((decision.actionAmmount > 0)? " " + decision.actionAmmount : "" ) );
            GameStateFactory.GetGameState(hPokerTable).setNextExpectedAction( decision );

            switch (decision.action)
            {
                case "fold":
                    Fold(hPokerTable);
                    break;
                case "raise-allin":
                    AllIn(hPokerTable);
                    break;
                case "check":
                    Check(hPokerTable);
                    break;
                case "check-fold":
                    CheckFold(hPokerTable);
                    break;
                case "raise":
                    Raise(hPokerTable, decision.actionAmmount);
                    Thread.Sleep(ConfigReader.ACTION_MODE_CONTROLLER_DELAY);
                    break;
                default:
                    logger.Error( "decision is not supported : " + decision.action );
                    break;
            }

            // First check if the decision has already been executed
            this.StoreDecisionExecution(decision);
        }
Example #2
0
 public void setNextExpectedAction(Decision decision)
 {
     // throw new NotImplementedException();
 }
 private void StoreDecisionExecution(Decision decision)
 {
     bool newDecision = !executedDecisions.Contains(decision.token);
     if (newDecision)
     {
         executedDecisions.AddLast(decision.token);
         while (executedDecisions.Count > DECISION_TOKEN_MEMORY)
         {
             executedDecisions.RemoveFirst();
         }
     }
     else
     {
         logger.Error(decision.token + " was already in the executed decision memory. Something flunky happened!");
     }
 }
 private bool AllowsDecisionExecution(Decision decision)
 {
     return !executedDecisions.Contains(decision.token);
 }
Example #5
0
 public static String Decision2JSON(Decision dec)
 {
     MemoryStream stream1 = new MemoryStream();
     DataContractJsonSerializer ser =
       new DataContractJsonSerializer(typeof(Decision));
     ser.WriteObject(stream1, dec);
     stream1.Position = 0;
     StreamReader sr = new StreamReader(stream1);
     return (new JsonFormatter(sr.ReadToEnd())).Format();
        //return JsonConvert.SerializeObject(dec);
 }
        public void StoreTakenDecision(Decision decision)
        {
            bool newDecision = !IsPreviouslyTakenDecision(decision);
            if (newDecision)
            {
                takenDecisions.AddLast(decision.token);
                pendingExecutionDecisions.AddLast(decision);

                while (takenDecisions.Count > DECISION_TOKEN_MEMORY)
                {
                    takenDecisions.RemoveFirst();
                }
            }
            else
            {
                logger.Error(decision.token + " was already in the requested decision memory. Something flunky happened!");
            }
        }
 public bool IsPreviouslyTakenDecision(Decision decision)
 {
     return takenDecisions.Contains(decision.token);
 }