private async void Translate(string currentlyTranslating, StreamWriter writer)
        {
            Language          cn     = Language.ChineseTraditional;
            Language          en     = Language.English;
            TranslationResult result = await m_translator.TranslateAsync(currentlyTranslating, cn, en);

            foreach (string res in result.MergedTranslation.Split(new string[] { "|||" },
                                                                  StringSplitOptions.RemoveEmptyEntries))
            {
                uint   idAction = uint.Parse(res.Split('►')[0].Trim());
                string param    = res.Split(new char[] { '►' }, 2, StringSplitOptions.RemoveEmptyEntries)[1]
                                  .Trim();
                param = BackCommand(param);

                GameActionEntity old       = m_entities.FirstOrDefault(x => x.Identity == idAction);
                GameActionEntity newAction = new GameActionEntity
                {
                    Identity   = old.Identity,
                    IdNext     = old.IdNext,
                    IdNextfail = old.IdNextfail,
                    Type       = old.Type,
                    Data       = old.Data,
                    Param      = param
                };

                m_newEntities.Add(newAction);
                dgvNew.Rows.Add(newAction.Identity, newAction.IdNext, newAction.IdNextfail, newAction.Type,
                                newAction.Data, newAction.Param);
                pbProgressAction.Value++;
                dgvNew.FirstDisplayedScrollingRowIndex = dgvNew.RowCount - 1;
                await writer.WriteLineAsync(
                    $"INSERT INTO cq_action VALUES ('{newAction.Identity}','{newAction.IdNext}','{newAction.IdNextfail}'," +
                    $"'{newAction.Type}','{newAction.Data}','{newAction.Param}');");
            }
        }
        public void SetAction(ActionType type, int amount)
        {
            currentPendingAction = null;
            var gameAction = new GameActionEntity()
            {
                ActionType = type,
                Amount     = amount,
                PlayerId   = currentHumanPlayer.Id
            };

            currentPlayerAction = gameAction;
        }
        private GameActionEntity Player_ActionRequired(HeadsupGame game, List <ActionType> possibleActions, int amountToCall)
        {
            currentPendingAction = new PendingAction()
            {
                PossibleActions = possibleActions,
                AmountToCall    = amountToCall
            };

            while (currentPlayerAction == null)
            {
                Task.Delay(1000);
            }

            var playerAction = currentPlayerAction;

            currentPlayerAction = null;

            return(playerAction);
        }
Example #4
0
        public override async Task <GameActionEntity> GetAction(List <ActionType> possibleActions, int amountToCall)
        {
            GameActionEntity action         = null;
            bool             actionReceived = false;

            while (!actionReceived)
            {
                action = base.OnActionRequired(possibleActions, amountToCall);
                if (action != null)
                {
                    actionReceived = true;
                }
                else
                {
                    await Task.Delay(1000);
                }
            }

            if (!possibleActions.Contains(action.ActionType))
            {
                switch (action.ActionType)
                {
                case ActionType.Call:
                    if (possibleActions.Contains(ActionType.Check))
                    {
                        action.ActionType = ActionType.Check;
                    }
                    break;

                case ActionType.Fold:

                    break;
                }
            }

            return(await Task.FromResult <GameActionEntity>(action));
        }