Beispiel #1
0
        private void FetchTurn(int positionId, Action <string> callback)
        {
            DataManager <PositionTurn> turnDM = DataManagerFactory.GetManager <PositionTurn> ();
            TurnRequest request = new TurnRequest(User.Id, User.Code, positionId);

            request.Get((results, ex) => {
                if (results == null)
                {
                    callback("Not found");
                }
                else
                {
                    IEnumerator <PositionTurn> i = results.GetEnumerator();
                    if (i.MoveNext())
                    {
                        PositionTurn pt = i.Current;
                        turnDM.SaveItem(pt);
                        callback(pt.Content);
                    }
                    else
                    {
                        callback("Not Found");
                    }
                }
            });
        }
Beispiel #2
0
        /// <summary>
        /// Включение/выключение бота (только телеграм)
        /// </summary>
        /// <param name="request"></param>
        /// <param name="masterId"></param>
        /// <returns></returns>
        public async Task TurnBotAsync(TurnRequest request, int masterId)
        {
            Bot dataBot = await context.Bots.FirstOrDefaultAsync(b => b.Id == request.BotId);

            BotActivity bot = BotStorage.ActivityBots.FirstOrDefault(b => b.Id == request.BotId);

            if (dataBot != null && dataBot.MasterId == masterId)
            {
                if (!request.TurnOn)
                {
                    if (bot != null)
                    {
                        BotStorage.ActivityBots.Remove(bot);
                        dataBot.IsActive = false;
                    }
                }
                else
                {
                    if (bot == null)
                    {
                        // бот автоматом добавляется в конструкторе
                        dataBot.IsActive = true;
                        BotActivity botActive = await TakeAsBotActivity(dataBot);

                        botActive.Sessions = await context.Sessions.Where(s => s.BotId == botActive.Id).ToListAsync();

                        await botActive.UploadFunctionalAsync();
                    }
                }
                await context.SaveChangesAsync();
            }
        }
Beispiel #3
0
    public static void RequestTurn(Unit unit, Action <Vector3, bool> callback)
    {
        Debug.Log(unit.name + " requested turn");
        TurnRequest newRequest = new TurnRequest(unit, callback);

        instance.turnRequestQueue.Enqueue(newRequest);
        instance.TryProcessNext();
    }
Beispiel #4
0
 void TryProcessNext()
 {
     if (!isProcessingTurn && turnRequestQueue.Count > 0)
     {
         currentTurnRequest = turnRequestQueue.Dequeue();
         isProcessingTurn   = true;
         turnHandler.StartHandleTurn(currentTurnRequest.currentUnit);
     }
 }
Beispiel #5
0
        public async Task <JsonResult> TurnBot([FromBody] TurnRequest request)
        {
            if (request != null)
            {
                await botServ.TurnBotAsync(request, (await accServ.GetCurrentUserAsync(User.Identity.Name)).Id);

                return(Json(true));
            }
            return(Json(false));
        }
Beispiel #6
0
        public void SubmitTurn(GameTurn turn)
        {
            var cToken  = new System.Threading.CancellationToken();
            var request = new TurnRequest()
            {
                MatchId     = matchID,
                DomGameTurn = turn
            };
            var response = client.SubmitTurn(request, null, null, cToken);

            if (response.TurnStatus == TurnStatus.InvalidTurn)
            {
                Console.WriteLine("Ooops, invalid turn!");
                AbortMatch();
            }
        }
Beispiel #7
0
        public async Task<ActionResult<TurnResponse>> Turn([FromBody] TurnRequest request)
        {
            await _machine.TurnAsync(request.Degrees);

            return _machine.Position.To<TurnResponse>();
        }