Exemple #1
0
 private void OnRockTurnEnd()
 {
     if (SingletonEndTurn)
     {
         return;
     }
     SingletonEndTurn = true;
     HoldBack(3000);
     Notify("Job's Done!");
     ActionRocking = null;
     TurnReady     = false;
     HearthrockRobot.RockEnd();
     InputManager.Get().DoEndTurnButton();
     //
     OnRocking = false;
 }
Exemple #2
0
        private void OnRockAI()
        {
            if (OnRocking)
            {
                return;
            }
            OnRocking = true;


            try
            {
                if (ActionRocking != null && ActionRocking.step == -1)
                {
                    ActionRocking = null;
                }
                if (ActionRocking != null)
                {
                    try
                    {
                        OnAction(ActionRocking);
                    }
                    catch
                    {
                        ActionRocking = null;
                    }
                    return;
                }

                // ActionRocking = should be null;

                HoldBack(250);
                if (EndTurnButton.Get().HasNoMorePlays())
                {
                    OnRockTurnEnd();
                    return;
                }

                RockAction action = HearthrockRobot.RockIt();

                if (action.type == HEARTHROCK_ACTIONTYPE.PLAY)
                {
                    SingletonEndTurn = false;
                    Notify("Play: " + action.card1.GetEntity().GetName() + "=>" + action.card1.GetEntity().GetCardId());
                    ActionRocking = action;
                }
                else if (action.type == HEARTHROCK_ACTIONTYPE.ATTACK)
                {
                    SingletonEndTurn = false;
                    Notify("Attack: " + action.card1.GetEntity().GetName() + " > " + action.card2.GetEntity().GetName());
                    ActionRocking = action;
                }
                else
                {
                    OnRockTurnEnd();
                }
            }
            catch (Exception e)
            {
                Log("OnRockAI ex " + e.ToString());
            }
            finally
            {
                OnRocking = false;
            }
        }
Exemple #3
0
        private void OnAction(RockAction action)
        {
            System.Random r = new System.Random();

            HoldBack(r.Next(500, 1000));
            if (action.step == 0)
            {
                int delay = r.Next(400, 600);
                HoldBack(delay);

                /*
                 * Spell spell = action.card1.GetBattlecrySpell();
                 * if (spell != null)
                 * {
                 * }
                 * else
                 * {
                 *  Notify("No Spell ");
                 * }
                 */

                //bool x = GameState.Get().HasResponse(action.card1.GetEntity());
                HearthstoneClickCard(action.card1);
                action.step = 1;
            }
            else if (action.step == 1)
            {
                int delay = r.Next(300, 600);
                if (action.type == HEARTHROCK_ACTIONTYPE.ATTACK)
                {
                    delay += 400;
                }
                HoldBack(delay);
                if (action.type == HEARTHROCK_ACTIONTYPE.PLAY)
                {
                    InputManager input_mgr = InputManager.Get();
                    input_mgr.DropHeldCard();
                    //MethodInfo dynMethod = input_mgr.GetType().GetMethod("DropHeldCard", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { }, null);
                    //dynMethod.Invoke(input_mgr, new object[] { });
                    HoldBack(500);
                    action.step = 2;
                    if (action.card1.GetEntity().HasBattlecry() || action.card1.GetEntity().IsSpell())
                    {
                        if (GameState.Get().IsInTargetMode())
                        {
                            List <Card> randomCardList;
                            if (action.card1.GetEntity().HasBattlecry())
                            {
                                randomCardList = HearthrockRobot.getMyValidOptionTargetList();
                                if (randomCardList.Count == 0)
                                {
                                    randomCardList = HearthrockRobot.getOpponentPlayerValidOptionTargetList();
                                }
                            }
                            else
                            {
                                randomCardList = HearthrockRobot.getOpponentPlayerValidOptionTargetList();
                            }
                            string message = "targetList is : ";
                            foreach (Card card in randomCardList)
                            {
                                message += card.GetEntity().GetName() + " ";
                            }
                            Log(message);
                            if (randomCardList.Count > 0)
                            {
                                Random rnd   = new Random();
                                int    index = rnd.Next(0, randomCardList.Count);
                                HandleClickOnCardInBattlefield(randomCardList[index].GetEntity());
                            }
                        }
                    }
                }
                else if (action.type == HEARTHROCK_ACTIONTYPE.ATTACK)
                {
                    HearthstoneClickCard(action.card2);
                    action.step = -1;
                }
            }
            else if (action.step == 2)
            {
                action.step = -1;
                return;
            }
        }