Esempio n. 1
0
        public void AddAction(EActionType type, Action action)
        {
            switch (type)
            {
            case EActionType.UPDATE:
                _onUpdate.Add(action);
                m_UpdateCount = _onUpdate.Count;
                break;

            case EActionType.LATE_UPDATE:
                _onLateUpdate.Add(action);
                m_LateUpdateCount = _onLateUpdate.Count;
                break;

            case EActionType.FIXED_UPDATE:
                _onFixedUpdate.Add(action);
                m_FixedUpdateCount = _onFixedUpdate.Count;
                break;

            case EActionType.Destory:
                _onDestory.Add(action);
                break;

            case EActionType.ON_PAUSE_FALSE:
                _onPauseFalse.Add(action);
                break;

            case EActionType.ON_PAUSE_TRUE:
                _onPauseTrue.Add(action);
                break;
            }
        }
Esempio n. 2
0
        public void SeeAction(EStage stage, int playerDoingAction, EActionType action, int amount)
        {
            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunSeeAction(stage, playerDoingAction, action, amount); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunSeeAction(stage, playerDoingAction, action, amount);
            }
        }
Esempio n. 3
0
        public void StartAction(int actionID)
        {
            CameraActionBase tmpCameraAction = CameraActionBaseManager.instance.Find(actionID);

            if (null == tmpCameraAction)
            {
                Logger.LogError($"找不到相机动作ID -> {actionID}");
                return;
            }

            mActionType  = (EActionType)tmpCameraAction.type;
            mTotalTime   = tmpCameraAction.time * 0.001f;
            mIsRunning   = mTotalTime > 0f;
            mRunningTime = 0f;

            if ((mActionType & EActionType.CloseUp) == EActionType.CloseUp)
            {
                SetData_Closeup(tmpCameraAction.closeup);
            }

            if ((mActionType & EActionType.Shake) == EActionType.Shake)
            {
                SetData_Shake(tmpCameraAction.shake);
            }

            if ((mActionType & EActionType.Lighteness) == EActionType.Lighteness)
            {
                SetData_Lighteness(tmpCameraAction.Lighteness);
            }
        }
Esempio n. 4
0
        public void Init()
        {
            m_iActionID       = -1;
            m_iMatchID        = -1;
            m_iMatchSplitID   = -1;
            m_iRegisterID     = -1;
            m_iShirtNo        = string.Empty;
            m_iActive         = -1;
            m_iTeamPos        = -1;
            m_strName         = "";
            m_strActionCode   = "";
            m_strActionKey    = "";
            m_strActionXml    = "";
            m_bActionComplete = false;

            m_emActionType = EActionType.emUnKnow;

            m_strActionDetail  = "";    //ActionDetai1 + ActionDetail2 或者ActionDetail1 + ActionDetail3
            m_strActionDetail1 = "";    //射门类型  0:Other Action, 1: Action Shot,2:Centre Shot,3: Extra Player Shot,4:5m Shot,5: Penalty Shot,6:Counter Shot,7:free throw
            m_strActionDetail2 = "";    //射门结果  1:Goal, 2:Saved, 3:Missed, 4:Post, 5:block shot;
            m_strActionDetail3 = "";    //其他动作  7: Assist, 8:Steals,  9:Turnover, 10:Blocked, 11:Spin Won, 12:Spin Lost,
                                        //13: 20C, 14:20F, 15: Penalty, 16:EX-S, 17: EX-N, 18:Time Out , 20: Corner Throw

            m_strActionDes        = ""; //动作描述 ActionDetailDes1 + ActionDetailDes2 或者ActionDetail3
            m_strActionDetailDes1 = ""; //射门类型
            m_strActionDetailDes2 = ""; //射门结果
            m_strActionDetailDes3 = ""; //其他动作
        }
Esempio n. 5
0
 public RequestBase(IPlayerModel player, EActionType actionType)
 {
     Id     = Guid.NewGuid();
     Player = player;
     Owner  = Player;
     Action = actionType;
 }
Esempio n. 6
0
        /// <summary>
        /// Reposts renewal to all children controls
        /// </summary>
        public override void RepostRenewToAllChildren(object aControl, EActionType aAction)
        {
            if (aControl != null)
            {
                if (aControl is IAdaptableContainer)
                {
                    if ((aControl as IAdaptableContainer).InheritedDataSource == true)
                    {
                        if ((aControl as IAdaptableContainer).Adaptor != null)
                        {
                            (aControl as IAdaptableContainer).Adaptor.SendAdaptorMessage(null, aAction);
                        }
                    }
                }
            }

            if (aControl is Gtk.Container)
            {
                foreach (Gtk.Widget wg in (aControl as Gtk.Container).Children)
                {
                    if (wg != null)
                    {
                        RepostRenewToAllChildren(wg, aAction);
                    }
                }
            }
        }
Esempio n. 7
0
        public void Init()
        {
            m_iActionID       = -1;
            m_iMatchID        = -1;
            m_iMatchSplitID   = -1;
            m_strActionKey    = "";
            m_iRegisterID     = -1;
            m_iActive         = -1;
            m_iShirtNo        = string.Empty;
            m_iTeamPos        = -1;
            m_strName         = "";
            m_strActionCode   = "";
            m_strActionXml    = "";
            m_bActionComplete = false;

            m_emActionType = EActionType.emUnKnow;

            m_strActionDetail  = "";    //ActionDetai1 + ActionDetail2 或者ActionDetail1 + ActionDetail3
            m_strActionDetail1 = "";    //射门类型  0:Other Action, 1: Shot,2:PenaltyShot,3: Free Click Shot
            m_strActionDetail2 = "";    //射门结果  1:Goal, 2:Block(OnGoal), 3:Crossbar(OnGoal), 4:NoGoal;
            m_strActionDetail3 = "";    //其他动作  4: Own Goal, 5:Yellow Card,  6:2nd Yellow Card, 7:Red Card, 8:ConerClick, 9:Offside,
                                        //10: Foul Committed, 11:Foul Suffered,
            m_strActionDetail4    = "";
            m_strActionDes        = ""; //动作描述 ActionDetailDes1 + ActionDetailDes2 或者ActionDetail3
            m_strActionDetailDes1 = ""; //射门类型
            m_strActionDetailDes2 = ""; //射门结果
            m_strActionDetailDes3 = ""; //其他动作
        }
Esempio n. 8
0
    // Use this for initialization
    void Awake()
    {
        if (null == PrefActionScrollView)
        {
            Log.Error("not found prefab action scroll view");
            return;
        }

        Array actionTypeArray = Enum.GetValues(typeof(EActionType));
        int   NUM_VIEW        = (int)EActionType.MAX;

        _viewArray = new ActionScrollView[NUM_VIEW];
        for (int i = 0; i < NUM_VIEW; ++i)
        {
            GameObject o = Instantiate(PrefActionScrollView);
            o.transform.SetParent(transform, false);

            ActionScrollView view = o.GetComponent <ActionScrollView>();
            EActionType      val  = (EActionType)actionTypeArray.GetValue(i);
            view.Set(val);

            view.Hide();
            _viewArray[i] = view;
        }
    }
Esempio n. 9
0
    private string getActionDoResultDescription(EActionType actionType, bool isSuccessed)
    {
        switch (actionType)
        {
        case EActionType.PARTTIME:
            if (isSuccessed)
            {
                return(Def.ACTION_PARTTIME_DOING_SUCCESS_DESC);
            }
            else
            {
                return(Def.ACTION_PARTTIME_DOING_FAIL_DESC);
            }

        case EActionType.LESSON:
            if (isSuccessed)
            {
                return(Def.ACTION_LESSON_DOING_SUCCESS_DESC);
            }
            else
            {
                return(Def.ACTION_LESSON_DOING_FAIL_DESC);
            }

        default:
            return(null);
        }
    }
Esempio n. 10
0
 /// <summary>
 /// Sends message to its adaptor if adaptor is valid
 /// </summary>
 /// <param name="aSender">
 /// Object sending message <see cref="System.Object"/>
 /// </param>
 /// <param name="aAction">
 /// Message context <see cref="EActionType"/>
 /// </param>
 public void SendAdaptorMessage(object aSender, EActionType aAction)
 {
     if (Adaptor != null)
     {
         Adaptor.SendAdaptorMessage(aSender, aAction);
     }
 }
        public void SeeAction(EStage stage, int playerNum, EActionType action, int amount)
        {
            // this is called to inform you when any player (including yourself) makes an action (eg puts in blinds, checks, folds, calls, raises, or wins hand)
            if (action == EActionType.ActionFold)
            {
                switch (stage)
                {
                case EStage.StagePreflop:
                    playerStats[playerNum].NumPreFlopsFolded++;
                    break;

                case EStage.StageFlop:
                    playerStats[playerNum].NumFlopsFolded++;
                    break;

                case EStage.StageTurn:
                    playerStats[playerNum].NumTurnsFolded++;
                    break;

                case EStage.StageRiver:
                    playerStats[playerNum].NumRiversFolded++;
                    break;
                }
            }
            else if (action == EActionType.ActionWin)
            {
                // be careful not to double count here. This can be call multiple times for the same player for the same hand if they win more than one side pot
                if (!playerStats[playerNum].bWonThisHand)
                {
                    playerStats[playerNum].NumHandsWon++;
                    playerStats[playerNum].bWonThisHand = true;
                }
            }
        }
Esempio n. 12
0
 public void OnCommand(EActionType action, byte[] param)
 {
     if (currentState != null)
     {
         LogicEntityState state = currentState as LogicEntityState;
         state.OnCommand(action, param);
     }
 }
Esempio n. 13
0
        public virtual void Process <T>(EActionType type, EActionScope scope, Mutator mutator, T current, T source) where T : Data <T>
        {
            var client = new AmazonSimpleNotificationServiceClient(Region);

            var payload = RenderPayload(type, scope, mutator, current, source);

            SendMessage(client, payload).Wait();
        }
Esempio n. 14
0
 public BaseAction()
 {
     mType       = EActionType.EAction_None;
     m_bFinished = false;
     m_bRunning  = false;
     m_entiyView = null;
     priority    = ECommandPriority.EAction_Low;
 }
Esempio n. 15
0
 public Action(ushort newSource, EActionType newType, ActionBlueprint[] newBlueprints, string newText, string newTooltip, string newKey)
 {
     this._source     = newSource;
     this._type       = newType;
     this._blueprints = newBlueprints;
     this._text       = newText;
     this._tooltip    = newTooltip;
     this._key        = newKey;
 }
Esempio n. 16
0
    /// <summary>
    ///     Default constructor taking a key, actiontype and number of presses
    /// </summary>
    /// <param name="key"></param>
    /// <param name="type"></param>
    /// <param name="multi"></param>
    public Action(KeyCode key, EActionType type = EActionType.Hold, int multi = 0)
    {
        if ((int)type >= 3 && multi <= 1)
        {
            multi = 2;
        }

        _node = new ActionNodeManager(key, type, multi);
    }
Esempio n. 17
0
        public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType yourAction, out int amount)
        {
            // This is the bit where you need to put the AI (mostly likely based on info you receive in other methods)

            System.Threading.Thread.Sleep(_sleepMilliSeconds);

            yourAction = EActionType.ActionCall;
            amount = callAmount;
        }
Esempio n. 18
0
 public virtual PublishRequest RenderPayload <T>(EActionType type, EActionScope scope, Mutator mutator, T current, T source) where T : Data <T>
 {
     return(new PublishRequest
     {
         Message =
             new { type = type.ToString(), scope = scope.ToString(), payload = current ?? source }.ToJson(),
         Subject = $"{(current ?? source).GetFullIdentifier()}",
         TopicArn = Topic
     });
 }
Esempio n. 19
0
    // @note : called after OnEnable()
    public void SetActionType(EActionType actionType)
    {
        _actionType = actionType;

        string actionTypeName = getActionTypeName();

        setText(actionTypeName);

        onEnable();
    }
Esempio n. 20
0
    // @note : called before Start(), after OnEnabled()
    public void Set(EActionType actionType)
    {
        if (EActionType.MAX == actionType)
        {
            Log.Error("invalid action type");
            return;
        }

        _actionType = actionType;
    }
Esempio n. 21
0
 private void RunSeeAction(EStage stage, int playerDoingAction, EActionType action, int amount)
 {
     try
     {
         _player.SeeAction(stage, playerDoingAction, action, amount);
     }
     catch (Exception e)
     {
         Logger.Log(string.Format("EXCEPTION: {0} Player {1} : {2}", MethodBase.GetCurrentMethod().Name, PlayerNum, e.Message));
     }
 }
Esempio n. 22
0
    public virtual void OnCommand(EActionType action, byte[] param)
    {
        int id = (int)action;

        if (links.ContainsKey(id))
        {
            StateLink link     = links[id];
            BaseState outstate = curFSM.FindChildState(link.linkStateName);
            Goto(outstate);
        }
    }
Esempio n. 23
0
    void DisableButtonsExcept(EActionType type)
    {
        btn_Pon.SetEnable(type == EActionType.Pon);
        btn_Chii.SetEnable(type == EActionType.Chii);
        btn_Kan.SetEnable(type == EActionType.Kan);
        btn_Reach.SetEnable(type == EActionType.Reach);
        btn_Agari.SetEnable(type == EActionType.Ron || type == EActionType.Tsumo);
        btn_Nagashi.SetEnable(type == EActionType.Nagashi);

        btn_RyuuKyoku.SetEnable(type == EActionType.RyuuKyoku);
        btn_RyuuKyoku.gameObject.SetActive(type == EActionType.RyuuKyoku);
    }
Esempio n. 24
0
    public void Show(EActionType actionType)
    {
        hideAllChildren();

        if (EActionType.MAX == actionType)
        {
            return;
        }

        int index = (int)actionType;

        _viewArray[index].Show();
    }
Esempio n. 25
0
    void DisableButtonsExcept(EActionType type)
    {
        Debug.Log("DisableButtonsExcept()");

        /*
         * btn_Pon.interactable = (type == EActionType.Pon );
         * btn_Chii.interactable = ( type == EActionType.Chii );
         * btn_Kan.interactable = ( type == EActionType.Kan );
         * btn_Reach.interactable = ( type == EActionType.Reach );
         * btn_Agari.interactable = ( type == EActionType.Ron || type == EActionType.Tsumo );
         * btn_Nagashi.interactable = ( type == EActionType.Nagashi );
         */
    }
Esempio n. 26
0
    protected EActionType PickActionType()
    {
        System.Array actionTypes = System.Enum.GetNames(typeof(EActionType));
        EActionType  actionType  = (EActionType)Random.Range(0, actionTypes.Length);

        if (actionType != currentAction.GetActionType())
        {
            return(actionType);
        }
        else
        {
            return(PickActionType());
        }
    }
 public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize,
                       out EActionType yourAction, out int amount)
 {
     if (stage == EStage.StagePreflop)
     {
         if (_currentHand.Any(c => c.Rank == ERankType.RankSeven) && _currentHand.Any(c => c.Rank == ERankType.RankTwo) &&
             _currentHand[0].Suit != _currentHand[1].Suit)
         {
             yourAction = EActionType.ActionRaise;
             amount     = maxRaise;
         }
     }
     yourAction = EActionType.ActionFold;
     amount     = 0;
 }
        // broadcast action of a player to all players (including themselves)
        private void BroadcastAction(EStage stage, int playerNumDoingAction, EActionType action, int amount)
        {
            var sLogMsg = string.Format("Player {0} {1} {2}", playerNumDoingAction, action, amount);

            if (_players[playerNumDoingAction].StackSize <= 0)
            {
                sLogMsg += " *ALL IN*";
            }

            Logger.Log(sLogMsg);

            foreach (var player in _players)
            {
                player.SeeAction(stage, playerNumDoingAction, action, amount);
            }
        }
Esempio n. 29
0
        public void Init()
        {
            m_iActionID       = -1;
            m_iMatchID        = -1;
            m_iMatchSplitID   = -1;
            m_iRegisterID     = -1;
            m_iShirtNo        = -1;
            m_iTeamPos        = -1;
            m_strTeamName     = "";
            m_strPlayerName   = "";
            m_strActionCode   = "";
            m_bActionComplete = false;

            m_emActionType = EActionType.emUnKnow;
            m_strActionDes = "";
        }
Esempio n. 30
0
        public void ClearActionInfo()
        {
            m_iActionID       = -1;
            m_strActionCode   = "";
            m_strActionKey    = "";
            m_strActionXml    = "";
            m_bActionComplete = false;
            m_emActionType    = EActionType.emUnKnow;

            m_strActionDetail     = "";
            m_strActionDetail1    = "";
            m_strActionDetail2    = "";
            m_strActionDetail3    = "";
            m_strActionDes        = "";
            m_strActionDetailDes1 = "";
            m_strActionDetailDes2 = "";
            m_strActionDetailDes3 = "";
        }
Esempio n. 31
0
        public void RemoveAction(EActionType type, Action action)
        {
            switch (type)
            {
            case EActionType.UPDATE:
                _onUpdate.Remove(action);
                m_UpdateCount = _onUpdate.Count;
                break;

            case EActionType.LATE_UPDATE:
                _onLateUpdate.Remove(action);
                m_LateUpdateCount = _onLateUpdate.Count;
                break;

            case EActionType.FIXED_UPDATE:
                _onFixedUpdate.Remove(action);
                m_FixedUpdateCount = _onFixedUpdate.Count;
                break;
            }
        }
Esempio n. 32
0
        public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType yourAction, out int amount)
        {
            yourAction = EActionType.ActionFold;
            amount = 0;

            // This is the bit where you need to put the AI (mostly likely based on info you receive in other methods)

            if (stage == EStage.StageShowdown)
            {
                // if stage is the showdown then choose whether to show your hand or fold
                yourAction = EActionType.ActionShow;
                amount = 0;
            }
            else
            {
                // stage is preflop, flop, turn or river
                // choose whether to fold, check, call or raise
                // the controller will validate your action and try to honour your action if possible but may change it (e.g. it won't let you fold if checking is possible)
                // amount only matters if you are raising (if calling the controller will use the correct amount). 
                // If raising, minRaise and maxRaise are the total amount required to put into the pot (i.e. it includes the call amount)
                // Side pots are now implemented so you can go all in and call or raise even if you have less than minimum
                int actionNum = _rnd.Next(100);

                if (actionNum < 20)
                {
                    yourAction = EActionType.ActionFold;
                    amount = 0;
                }
                else if (actionNum < 60)
                {
                    yourAction = EActionType.ActionCall;
                    amount = callAmount;
                }
                else
                {
                    yourAction = EActionType.ActionRaise;
                    amount = minRaise;
                }
            }
        }
Esempio n. 33
0
        public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType yourAction, out int amount)
        {
            // This is the bit where you need to put the AI (mostly likely based on info you receive in other methods)
            int i = 1 / zero;

            if (stage == EStage.StageShowdown)
            {
                // if stage is the showdown then choose whether to show your hand or fold
                yourAction = EActionType.ActionShow;
                amount = 0;
            }
            else
            {
                // stage is preflop, flop, turn or river
                // choose whether to fold, check, call or raise
                // the controller will validate your action and try to honour your action if possible but may change it (e.g. it won't let you fold if checking is possible)
                // amount only matters if you are raising (if calling the controller will use the correct amount). 
                // If raising, minRaise and maxRaise are the total amount required to put into the pot (i.e. it includes the call amount)
                // Side pots aren't implemented so if you run out of money you can still call (but not raise) and your stack size may go negative. 
                // If your stack size is still 0 or negative at the end of the hand then you are out of the game.
                yourAction = EActionType.ActionCall;
                amount = callAmount;
            }
        }
Esempio n. 34
0
 public void SeeAction(EStage stage, int playerNum, EActionType action, int amount)
 {
     // this is called to inform you when any player (including yourself) makes an action (eg puts in blinds, checks, folds, calls, raises, or wins hand)
     int i = 1 / zero;
 }
Esempio n. 35
0
 public void SeeAction(EStage stage, int playerNum, EActionType action, int amount)
 {
     // this is called to inform you when any player (including yourself) makes an action (eg puts in blinds, checks, folds, calls, raises, or wins hand)
     System.Threading.Thread.Sleep(_sleepMilliSeconds);
 }
Esempio n. 36
0
        public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType playersAction, out int playersBetAmount)
        {
            // Default
            playersAction = EActionType.ActionCall;
            playersBetAmount = callAmount;

            try
            {
                _player.GetAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize, out playersAction, out playersBetAmount);
            }
            catch (Exception e)
            {
                Logger.Log(string.Format("EXCEPTION: {0} Player {1} : {2}", MethodBase.GetCurrentMethod().Name, PlayerNum, e.Message));
            }

            ValidateAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize, ref playersAction, ref playersBetAmount);
        }
Esempio n. 37
0
 public SavedAction(string actionName, EActionType actionType = EActionType.Saved)
     : base(EActionType.Saved, null)
 {
     ActionType = actionType;
     ActionName = actionName;
 }
Esempio n. 38
0
        public void SeeAction(EStage stage, int playerNum, EActionType action, int amount)
        {
            // this is called to inform you when any player (including yourself) makes an action (eg puts in blinds, checks, folds, calls, raises, or wins hand)
            if (action == EActionType.ActionFold)
            {
                switch (stage)
                {
                    case EStage.StagePreflop:
                        playerStats[playerNum].NumPreFlopsFolded++;
                        break;
                    case EStage.StageFlop:
                        playerStats[playerNum].NumFlopsFolded++;
                        break;
                    case EStage.StageTurn:
                        playerStats[playerNum].NumTurnsFolded++;
                        break;
                    case EStage.StageRiver:
                        playerStats[playerNum].NumRiversFolded++;
                        break;
                }
            }
            else if (action == EActionType.ActionWin)
            {
                // be careful not to double count here. This can be call multiple times for the same player for the same hand if they win more than one side pot
                if(!playerStats[playerNum].bWonThisHand)
                {
                    playerStats[playerNum].NumHandsWon++;
                    playerStats[playerNum].bWonThisHand = true;
                }
            }

        }
Esempio n. 39
0
        // broadcast action of a player to all players (including themselves)
        private void BroadcastAction(EStage stage, int playerNumDoingAction, EActionType action, int amount)
        {
            var sLogMsg = string.Format("Player {0} {1} {2}", playerNumDoingAction, action, amount);

            if (_players[playerNumDoingAction].StackSize <= 0)
            {
                sLogMsg += " *ALL IN*";
            }

            Logger.Log(sLogMsg);

            foreach (var player in _players)
            {
                player.SeeAction(stage, playerNumDoingAction, action, amount);
            }
        }
Esempio n. 40
0
 public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType yourAction, out int amount)
 {
     yourAction = EActionType.ActionRaise;
     amount = minRaise;
 }
Esempio n. 41
0
 public void SeeAction(EStage stage, int playerNum, EActionType action, int amount)
 {
 }
        public void SeeAction(EStage stage, int playerDoingAction, EActionType action, int amount)
        {
            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunSeeAction(stage, playerDoingAction, action, amount); });

                    // wait X amount of time for task to complete
                    if (!_task.Wait(_botTimeOutMilliSeconds))
                    {
                        // Note that the task is still running in the background
                        _bIsBotBusy = true;
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunSeeAction(stage, playerDoingAction, action, amount);
            }
        }
 private void RunSeeAction(EStage stage, int playerDoingAction, EActionType action, int amount)
 {
     try
     {
         _player.SeeAction(stage, playerDoingAction, action, amount);
     }
     catch (Exception e)
     {
         Logger.Log(string.Format("EXCEPTION: {0} Player {1} : {2}", MethodBase.GetCurrentMethod().Name, PlayerNum, e.Message));
     }
 }
        public void GetAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, out EActionType playersAction, out int playersBetAmount)
        {
            // Default to fold if exception or timeout
            playersAction = EActionType.ActionFold;
            playersBetAmount = 0;

            if (_botTimeOutMilliSeconds > 0)
            {
                if (!IsBotBusy())
                {
                    _task = Task.Run(() => { RunGetAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize);});

                    // wait X amount of time for task to complete
                    // if method has not returned in time then use default action
                    if (_task.Wait(_botTimeOutMilliSeconds))
                    {
                        playersAction = _playersAction;
                        playersBetAmount = _playersBetAmount;
                    }
                    else
                    {
                        // Note that the task is still running in the background
                        Logger.Log("TIMEOUT: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                    }
                }
                else
                {
                    // bot is busy still running the previous task
                    Logger.Log("BOT BUSY: {0} Player {1}", MethodBase.GetCurrentMethod().Name, PlayerNum);
                }
            }
            else
            {
                // timeout code disabled - just called method directly
                RunGetAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize);
                playersAction = _playersAction;
                playersBetAmount = _playersBetAmount;
            }

            ValidateAction(stage, callAmount, minRaise, maxRaise, raisesRemaining, potSize, ref playersAction, ref playersBetAmount);
        }
Esempio n. 45
0
		/// <summary>
		/// Reposts renewal to all children controls
		/// </summary>
		/// <param name="aControl">
		/// Control which should repost renew <see cref="System.Object"/>
		/// </param>
		/// <param name="aAction">
		/// Action <see cref="EActionType"/>
		/// </param>
		public virtual void RepostRenewToAllChildren(object aControl, EActionType aAction)
		{
//			throw new ExceptionAdaptorRepostNotSupported(); 
		}
Esempio n. 46
0
 protected TinBotAction(EActionType type, string name)
 {
     Type = type;
     Name = name;
 }
Esempio n. 47
0
		/// <summary>
		/// Message loop for Adaptors
		/// </summary>
		/// <param name="aSender">
		/// Sender object <see cref="System.Object"/>
		/// </param>
		/// <param name="aAction">
		/// Action type <see cref="EActionType"/>
		/// </param>
		public void SendAdaptorMessage (object aSender, EActionType aAction)
		{
			// No need for checking if message is here then message was inteded to be here
			switch (aAction) {
			case EActionType.RenewParents :
				if ((aSender != null) && (CheckControlType(aSender) == true))
					RepostRenewToAllChildren (aSender, EActionType.RenewParents);
				else {
					if (renewingparent == true)
						return;
					renewingparent = true;
					finalTarget.Target = null;
					if (controlAdaptor != null) {
						if (InheritedTarget == true) {
							bool renewneeded = false;
							object o = ConnectionProvider.ResolveParentContainer (controlAdaptor, Control);
							if (controlAdaptor.ParentContainer == null) {
								if (o != null) {
									controlAdaptor.ParentContainer = o;
									renewneeded = true;
								}
							}
							else {
								if (o != controlAdaptor.ParentContainer)
									renewneeded = true;
							}
							if ((Control != null) && (IsBoundaryAdaptor == false) && (renewneeded == true)) {
								stateResolvingInheritedTarget = true;
								Target = null;
								stateResolvingInheritedTarget = false;
							}
						}

						RepostRenewToAllChildren (Control, EActionType.RenewParents);
					}
				}
				renewingparent = false;
				break;
/*			case EActionType.PostRequest :
				break;
			case EActionType.GetRequest :
				AdapteeDataChanged (null);
				break;*/
			}
		}
        private void ValidateAction(EStage stage, int callAmount, int minRaise, int maxRaise, int raisesRemaining, int potSize, ref EActionType playersAction, ref int playersBetAmount)
        {
            // *** Fix up action
            if(stage == EStage.StageShowdown)
            {
                if(playersAction != EActionType.ActionFold)
                {
                    playersAction = EActionType.ActionShow;
                }

                playersBetAmount = 0;
            }
            else
            {
                var bAllIn = false;

                if (playersBetAmount < 0)
                {
                    playersBetAmount = 0;
                }

                if (playersAction == EActionType.ActionRaise)
                {
/*
                    // We shouldn't increase a players bet - but can reduce it if outside limits
                    if (playersBetAmount < minRaise)
                    {
                        playersBetAmount = minRaise;
                    }
*/
                    if (playersBetAmount > maxRaise)
                    {
                        playersBetAmount = maxRaise;
                    }
                }

                if (playersBetAmount > StackSize)
                {
                    playersBetAmount = StackSize;
                }

                if (playersBetAmount == StackSize)
                {
                    bAllIn = true;
                }

                // -- Validate action - prevent player from doing anything illegal
                if (playersAction != EActionType.ActionFold &&
                    playersAction != EActionType.ActionCheck &&
                    playersAction != EActionType.ActionCall &&
                    playersAction != EActionType.ActionRaise )
                {
                    // invalid action - default to call
                    playersAction = EActionType.ActionCall;
                }

                if (playersAction == EActionType.ActionFold && callAmount == 0)
                {
                    // invalid action - don't fold if they can check
                    playersAction = EActionType.ActionCheck;
                }

                if (playersAction == EActionType.ActionCheck && callAmount > 0)
                {
                    // invalid action - can't check so change to call
                    playersAction = EActionType.ActionCall;
                }

                if (playersAction == EActionType.ActionRaise && playersBetAmount <= callAmount)
                {
                    // not enough chips to raise - just call
                    playersAction = EActionType.ActionCall;
                }

                if (playersAction == EActionType.ActionRaise && playersBetAmount > callAmount && playersBetAmount < minRaise && !bAllIn)
                {
                    // not enough chips to raise - just call unless going allin
                    playersAction = EActionType.ActionCall;
                }

                if (playersAction == EActionType.ActionRaise && (raisesRemaining <= 0))
                {
                    // no more raises allowed
                    playersAction = EActionType.ActionCall;
                }

                if (playersAction == EActionType.ActionCall && callAmount == 0)
                {
                    // change call to check if callAmount = 0
                    playersAction = EActionType.ActionCheck;
                }

                // *** Fix betAmount
                if (playersAction == EActionType.ActionFold || playersAction == EActionType.ActionCheck)
                {
                    playersBetAmount = 0;
                }

                if (playersAction == EActionType.ActionCall)
                {
                    playersBetAmount = callAmount;

                    if (playersBetAmount > StackSize)
                    {
                        playersBetAmount = StackSize;
                    }
                }
            }
        }