private void _handleIngredientCardDrop(CustomerCardView customerView)
    {
        Debug.Log("PlayField Received drop of: " + customerView.cardData.titleKey);
        if (_draggedIngredient == null)
        {
            return;
        }

        CustomerCardState  customerState  = customerView.cardState;
        IngredientCardData ingredientData = _draggedIngredient.cardData as IngredientCardData;

        if (!customerState.CanAcceptCard(ingredientData))
        {
            return;
        }


        MoveRequest move = MoveRequest.Create(
            activePlayer.index,
            _draggedIngredient.handIndex,
            customerState.slotIndex);

        Assert.IsNotNull(onPlayOnCustomer);
        _draggedIngredient.isDropSuccessfull = onPlayOnCustomer(move);

        if (_draggedIngredient.isDropSuccessfull)
        {
            _droppedCustomer = customerView;
        }
    }
Example #2
0
 public static void ReportDeviationsFromExpectedResults(TankMovementResolver resolver, MoveStatus[] expectedMoveStatuses)
 {
     for (int i = 0; i < 4; i++)
     {
         MoveRequest  request    = resolver.Requests[i];
         ConsoleColor oldFGColor = System.Console.ForegroundColor;
         try
         {
             if (request.Status == expectedMoveStatuses[i])
             {
                 System.Console.ForegroundColor = ConsoleColor.Green;
                 System.Console.WriteLine("    Tank {0} move = {1} (as expected).", i, request.Status);
             }
             else
             {
                 System.Console.ForegroundColor = ConsoleColor.Red;
                 System.Console.WriteLine("    Tank {0} move. Expected: {1}. Actual: {2}.", i, expectedMoveStatuses[i], request.Status);
             }
         }
         finally
         {
             System.Console.ForegroundColor = oldFGColor;
         }
     }
 }
Example #3
0
    public bool PlayCardOnCustomer(MoveRequest move)
    {
        if (isGameOver)
        {
            Debug.LogError("Game is over!");
            return(false);
        }

        if (!activeCustomerSet.IsSlotActive(move.customerSlot))
        {
            return(false);
        }

        PlayerState        playerState    = playerGroup.GetPlayerByIndex(move.playerIndex);
        IngredientCardData ingredientData = playerState.hand.GetCard(move.handSlot);
        CustomerCardState  customerState  = activeCustomerSet.GetCustomerByIndex(move.customerSlot);

        if (playerState.cardsPlayed >= PlayerState.kMaxCardsPerTurn)
        {
            return(false);
        }
        if (!customerState.CanAcceptCard(ingredientData))
        {
            return(false);
        }

        _playCard(move, playerState, customerState, ingredientData);

        _playCardEvent();

        return(true);
    }
Example #4
0
        public async Task <IActionResult> Move([FromBody] MoveRequest move)
        {
            var _move = await service.Move(move);

            return(_move == null?StatusCode(409) as IActionResult
                   : Ok(_move) as IActionResult);
        }
    /// <summary>
    /// 生成同步相关的Request
    /// </summary>
    public void CreatAndStartSyncRequest()
    {
        //创建这个用来挂载Request的游戏物体
        _playerSyncGo = new GameObject("PlayerSyncGameObject");
        //添加MoveRequest同步位置动画请求
        MoveRequest moveRequest = _playerSyncGo.AddComponent <MoveRequest>();

        //设置同步位置动画请求的对象-本地玩家
        moveRequest.currentControllRoleTransform  = _currentControllRoleGo.transform;
        moveRequest.currentControllRolePlayerMove = _currentControllRoleGo.GetComponent <PlayerMove>();
        //设置同步位置动画响应的对象-远端玩家
        moveRequest.remoteRoleTransform = _remoteRoleGo.transform;
        moveRequest.remoteRoleAnimator  = _remoteRoleGo.GetComponent <Animator>();

        //添加SyncArrowRequest同步箭请求
        _playerSyncGo.AddComponent <SyncArrowRequest>();

        //添加伤害有关处理TakeDamageRequest请求
        _playerSyncGo.AddComponent <TakeDamageRequest>();

        //添加动作同步SyncAnimation的请求-并设置远端玩家的Animator组件
        SyncAnimationRequest syncAnimationRequest = _playerSyncGo.AddComponent <SyncAnimationRequest>();

        syncAnimationRequest.remoteRoleAnimator = _remoteRoleGo.GetComponent <Animator>();
    }
Example #6
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new PagesApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath = "WordProcessing/four-pages.docx"
                };

                var options = new MoveOptions
                {
                    FileInfo      = fileInfo,
                    OutputPath    = "Output/move-pages.docx",
                    PageNumber    = 1,
                    NewPageNumber = 2
                };
                var request = new MoveRequest(options);

                var response = apiInstance.Move(request);

                Console.WriteLine("Output file path: " + response.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Example #7
0
        /// <summary>
        /// 确认重置站台设置信息
        /// </summary>
        public DTOResponse RestChanelStorestate(MoveRequest request)
        {
            DTOResponse    dtoResponse = new DTOResponse();
            IDbConnection  dbCon       = (IDbConnection)null;
            IDbTransaction dbTrans     = (IDbTransaction)null;

            try
            {
                HelperDbOperation.BeginTransaction(ref dbCon, ref dbTrans);

                string msg          = "重置站台设置信息";
                string sqlUpdateStn = string.Format(
                    @"UPDATE PROJ_STATIONINFO SET USECAPACITY=0,OPDATE='{1}',OPMESSAGE='{2}' WHERE CONTROLNO='{0}'",
                    request.StationNo, Utils.GetDatetime(), msg);
                int count1 = dbCon.ExecuteSql(sqlUpdateStn);

                dtoResponse.IsSuccess   = count1 > 0 ? true : false;
                dtoResponse.MessageText = "确认重置" + request.StationNo + "站台状态成功:" + count1 + "个工位";
                LogService.logger.Info((object)dtoResponse.ToString());
                return(dtoResponse);
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                LogService.logger.Error((object)ex);
                return(dtoResponse);
            }
            finally
            {
                HelperDbOperation.EndTransaction(dtoResponse.IsSuccess, ref dbCon, ref dbTrans);
            }
        }
Example #8
0
        void PacketHandler.Run(int credential, string payload)
        {
            ClientSession clientSession = EasyGameServer.g_WorldManager.GetClient(credential);
            MoveRequest   moveRequest   = JsonFx.Json.JsonReader.Deserialize <MoveRequest>(payload);

            clientSession.m_PosX  = moveRequest.m_PosX;
            clientSession.m_PosY  = moveRequest.m_PosY;
            clientSession.m_PosZ  = moveRequest.m_PosZ;
            clientSession.m_Angle = moveRequest.m_Angle;
            clientSession.m_Speed = moveRequest.m_Speed;


            MoveResult moveResultPay = new MoveResult();

            moveResultPay.m_PlayerID = clientSession.m_PlayerID;
            moveResultPay.m_PosX     = clientSession.m_PosX;
            moveResultPay.m_PosY     = clientSession.m_PosY;
            moveResultPay.m_PosZ     = clientSession.m_PosZ;
            moveResultPay.m_Angle    = clientSession.m_Angle;
            moveResultPay.m_Speed    = clientSession.m_Speed;

            string resultPayload = JsonFx.Json.JsonWriter.Serialize(moveResultPay);

            resultPayload = Utils.Base64Encoding(resultPayload);

            Packet moveResult = new Packet();

            moveResult.m_Type    = (int)PacketTypes.PKT_SC_MOVE;
            moveResult.m_Payload = resultPayload;
            string resultPacket = JsonFx.Json.JsonWriter.Serialize(moveResult);

            EasyGameServer.g_WorldManager.SendBroadCast(resultPacket);
        }
Example #9
0
    public static void RequestMove(Node start, Node end, Action <bool> callback)
    {
        MoveRequest newRequest = new MoveRequest(start, end, callback);

        instance.moveRequestQueue.Enqueue(newRequest);
        instance.TryProcessNext();
    }
Example #10
0
        public DTOResponse CreateTaskByMen(MoveRequest request)
        {
            DTOResponse    dtoResponse = new DTOResponse();
            IDbConnection  dbCon       = (IDbConnection)null;
            IDbTransaction dbTrans     = (IDbTransaction)null;

            try
            {
                HelperDbOperation.BeginTransaction(ref dbCon, ref dbTrans);
                dtoResponse = this.CreateTaskByMen(request, dbCon, dbTrans);
                LogService.logger.Info((object)dtoResponse.ToString());
                return(dtoResponse);
            }
            catch (Exception ex)
            {
                dtoResponse.IsSuccess   = false;
                dtoResponse.MessageText = ex.Message;
                LogService.logger.Error((object)ex);
                return(dtoResponse);
            }
            finally
            {
                HelperDbOperation.EndTransaction(dtoResponse.IsSuccess, ref dbCon, ref dbTrans);
            }
        }
Example #11
0
    /// <summary>
    /// Starts the pass of the pack
    /// </summary>
    /// <returns>If there was cards left to pass</returns>
    public bool PassCardPack()
    {
        SetNewState(PlayerState.Passing);
        if (handCards.Count == 0)
        {
            SetNewState(PlayerState.WaitingToPlay);
            endOfRound = true;
            return(false);
        }
        endOfRound = false;
        if (cardPack == null)
        {
            GameObject gameObj = Instantiate(Deck.Instance().cardPackPrefab, handPosition.transform);
            cardPack = gameObj.GetComponent <CardPack>();
        }
        cardPack.SetCards(handCards);
        Player  neighbor = Deck.Instance().GetNeighbor(this);
        Vector3 targetPosition;

        if (Deck.Instance().PassingLeft())
        {
            cardPack.gameObject.transform.rotation = transform.rotation;
            targetPosition = transform.position;
        }
        else
        {
            cardPack.gameObject.transform.rotation = neighbor.gameObject.transform.rotation;
            targetPosition = neighbor.transform.position;
        }
        cardPack.gameObject.SetActive(true);
        MoveRequest request = new MoveRequest(targetPosition, neighbor.gameObject, this.OnCardPackPassed, 24);

        cardPack.SetMoveRequest(request);
        return(true);
    }
Example #12
0
        public void Can_Generate_Api_Xml_With_RequestFilter()
        {
            //Arrange
            string expected =
                new XElement("MoveRequest",
                             new XAttribute("name", "foo"),
                             new XAttribute("targetLocation", "bar"),
                             new XAttribute("returnNoAttributes", "true")).ToString();

            var request = new MoveRequest("foo", "bar")
            {
                RequestFilters = new List <IMoveRequestFilter> {
                    Filter.ReturnNoAttributes()
                }
            };

            //Act
            var actual       = request.ToAdsml();
            var batchRequest = new BatchRequest(request);

            Console.WriteLine(actual.ToString());

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expected));
            Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
Example #13
0
        protected void MoveButton_Click(object sender, EventArgs e)
        {
            if (DeviceGridPanel.SelectedDevice != null)
            {
                string         destinationDevices = string.Empty;
                string         separator          = string.Empty;
                int            i       = 0;
                IList <Device> devices = DeviceGridPanel.SelectedDevices;
                foreach (Device device in devices)
                {
                    if (i > 0)
                    {
                        separator = ", ";
                    }
                    destinationDevices = device.AeTitle + separator + destinationDevices;
                    i++;
                }

                MoveConfirmation.Message = DialogHelper.createConfirmationMessage(string.Format(SR.MoveSeriesMessage, destinationDevices));

                MoveConfirmation.Message += DialogHelper.createSeriesTable(SeriesGridView.SeriesList);

                MoveConfirmation.MessageType = MessageBox.MessageTypeEnum.OKCANCEL;

                // Create the move request, although it really isn't needed.
                MoveRequest moveData = new MoveRequest();
                moveData.SelectedStudy      = SeriesGridView.Study;
                moveData.DestinationDevices = DeviceGridPanel.SelectedDevices;
                moveData.Series             = SeriesGridView.SeriesList;
                moveData.Partition          = SeriesGridView.Partition;
                MoveConfirmation.Data       = moveData;

                MoveConfirmation.Show();
            }
        }
Example #14
0
        private static void Execute()
        {
            string input = COMMAND_REPEAT;

            while (string.Equals(COMMAND_REPEAT, input, StringComparison.OrdinalIgnoreCase))
            {
                // Business Req: no exceptions
                try
                {
                    int numberOfCommands = Get_NumberOfCommands();
                    (int X, int Y)startCoordinate = Get_StartingCoordinates();
                    IEnumerable <(DirectionEnum Direction, int Steps)> commands = Get_MoveCommands(numberOfCommands);

                    using (AsyncScopedLifestyle.BeginScope(_container))
                    {
                        var moveRequest = new MoveRequest(startCoordinate.X, startCoordinate.Y, commands);
                        var useCase     = _container.GetInstance <IUseCase <MoveRequest, MoveResponse> >();
                        var response    = useCase.Execute(moveRequest);
                        Console.WriteLine($"Cleaned: {response.CleanedVertices}");
                    }
                }
                finally
                {
                    Console.WriteLine($"[{COMMAND_REPEAT}]epeat?");
                    input = Console.ReadLine();
                }
            }
        }
Example #15
0
    /// <summary>
    /// Gets a move request to place a card into place on this scoregroup
    /// </summary>
    /// <returns></returns>
    public MoveRequest GetNextCardMoveRequest()
    {
        MoveRequest request = new MoveRequest(this.transform.TransformPoint(positionOfNextCard), this.gameObject, this.OnCardInPlace);

        positionOfNextCard += nextCardDelta;
        return(request);
    }
Example #16
0
        /// <summary>
        /// Moves the specified query.
        /// </summary>
        /// <param name="moveRequest">The query.</param>
        /// <param name="db">The database.</param>
        public ProcessResponse Move(MoveRequest moveRequest, string db)
        {
            this.SetDatabase(db);

            var processId = Guid.NewGuid();

            progressStatus.TryAdd(processId, new ConcurrentQueue <string>());

            var targetItem = this.database.GetItem(moveRequest.TargetPath);

            moveRequest.Items.ForEach(t => progressStatus[processId].Enqueue(t));

            List <Action> actions = new List <Action>();

            for (int i = 0; i < this.MaximumNumberOfThreads; i++)
            {
                Action action = () =>
                {
                    string itemId;
                    while (progressStatus[processId].TryDequeue(out itemId))
                    {
                        try
                        {
                            var sourceItem = database.GetItem(new ID(itemId));
                            sourceItem.MoveTo(targetItem);
                        }
                        catch (Exception ex)
                        {
                            List <string> errorMessages = new List <string>();
                            if (errors == null)
                            {
                                errors = new ConcurrentDictionary <Guid, List <string> >();
                            }

                            if (errors.TryGetValue(processId, out errorMessages))
                            {
                                var newErrors = new List <string>();
                                newErrors.AddRange(errorMessages);
                                newErrors.Add(ex.Message + " Item Id: " + itemId);
                                errors.TryUpdate(processId, newErrors, errorMessages);
                            }
                            else
                            {
                                errors.TryAdd(processId, new List <string> {
                                    ex.Message + " Item Id: " + itemId
                                });
                            }
                        }
                    }
                };

                actions.Add(action);
            }

            Task.Run(() => Parallel.Invoke(actions.ToArray()));

            return(new ProcessResponse {
                StatusId = processId
            });
        }
Example #17
0
        public async Task <MoveResponse> Move(long gameId, MoveRequest move)
        {
            string URL      = BASE_URL + gameId + "/move";
            var    response = await client.PutAsync <MoveResponse>(URL, move);

            return(response.Result);
        }
Example #18
0
 private Move HandleMoveNewStyle(MoveRequest request)
 {
     if (request.AllowedMoves.Count() == 1)
     {
         List <Move> doneMoves = new List <Move>();
         List <Tuple <Move, Move, double> > monsterStuff = new List <Tuple <Move, Move, double> >();
         foreach (var location in GetMyLocations(request.Board))
         {
             foreach (var move in GetPossibleToLocations(request.Board, location, true).Select <BoardLocation, Move>(l => CreateMove(request.Board, location, l)))
             {
                 //.Where(m => !doneMoves.Contains(m))
                 var newBoard = CopyBoard(request.Board);
                 newBoard.ApplyMove(move);
                 foreach (var nextLocation in GetMyLocations(newBoard))
                 {
                     foreach (var secondMove in GetPossibleToLocations(newBoard, nextLocation).Where(l => l != nextLocation).Select <BoardLocation, Move>(l => CreateMove(newBoard, nextLocation, l)).Where(m => !doneMoves.Contains(m)))
                     {
                         var evenNewerBoard = CopyBoard(newBoard);
                         evenNewerBoard.ApplyMove(secondMove);
                         monsterStuff.Add(new Tuple <Move, Move, double>(move, secondMove, GetBoardDanger(evenNewerBoard)));
                         doneMoves.Add(move);
                     }
                 }
             }
         }
         Console.Error.Write("SIZE: " + monsterStuff.Count + " ");
         var orderedMonster = monsterStuff.OrderBy(t => t.Item3);
         return(orderedMonster.First().Item1);
     }
     else
     {
         return(HandleMoveOldStyle(request));
     }
 }
        public MoveResponse PostMove(MoveRequest moveRequest)
        {
            var strategy   = ResolveGameModeStrategy(moveRequest.GameMode);
            var move       = new Move(moveRequest.Row, moveRequest.Column, moveRequest.PlayerNumber);
            var moveResult = strategy.OnMove(move, moveRequest.MatchId, moveRequest.Gameboard);

            moveRequest.Players.ForEach(p =>
                                        p.Score = ScoreKeeper.GetScoreForPlayer(p.Number, moveResult.Gameboard)
                                        );

            var response = new MoveResponse
            {
                Result  = moveResult,
                Players = moveRequest.Players
            };

            if (moveResult.IsEndOfMatch)
            {
                response.Winner = moveRequest
                                  .Players
                                  .OrderByDescending(p => p.Score)
                                  .First( );
            }

            return(response);
        }
Example #20
0
        public void Can_Generate_Api_Xml_With_CopyControl()
        {
            //Arrange
            string expected =
                new XElement("MoveRequest",
                             new XAttribute("name", "foo"),
                             new XAttribute("targetLocation", "bar"),
                             new XElement("CopyControls",
                                          new XAttribute("copyLocalAttributes", "true"))).ToString();

            var request = new MoveRequest("foo", "bar")
            {
                CopyControl = new CopyControl(new List <ICopyControlFilter> {
                    Filter.CopyLocalAttributesFromSource()
                })
            };

            //Act
            var actual       = request.ToAdsml();
            var batchRequest = new BatchRequest(request);

            Console.WriteLine(actual.ToString());

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expected));
            Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
Example #21
0
        public IActionResult MovePiece([FromBody] MoveRequest moveRequest)
        {
            var endPosition   = Position.FromString(moveRequest.End);
            var startPosition = Position.FromString(moveRequest.Start);

            _gameService.ProcessMove(startPosition, endPosition);
            return(PartialView("_Board", GameStateViewModel.FromGameState(_gameService._gameState)));
        }
Example #22
0
    private bool onPlayCard(MoveRequest move)
    {
        _recycleRequest.Clear();
        _recycleRequest.Add(move);
        int playerIndex = _gameMatchCore.playerGroup.activePlayer.index;

        return(attemptMoves(playerIndex, _recycleRequest, false));
    }
        public MoveResult Execute(MoveRequest request)
        {
            var game   = Games[request.GameId];
            var result = game.MoveFleet(request);

            result.Success = true;
            return(result);
        }
Example #24
0
    /// <summary>
    /// Starts drawing the next turn's card pack from the table
    /// </summary>
    public void DrawCardPack()
    {
        SetNewState(PlayerState.Drawing);
        MoveRequest request = new MoveRequest(handPosition.transform.position, this.gameObject, this.OnCardPackDrawn, 24);

        cardPack = this.GetComponentInChildren <CardPack>();
        cardPack.SetMoveRequest(request);
    }
Example #25
0
        public void Validate_Throws_ApiSerializationValidationException_If_Target_Is_Empty()
        {
            //Arrange
            var req = new MoveRequest("foo", string.Empty);

            //Act
            req.ToAdsml();
        }
Example #26
0
        public override async Task <MoveResponse> Move(MoveRequest request, ServerCallContext context)
        {
            await Task.Delay(1000);

            return(new MoveResponse {
                Result = request.Amount <= 10 ? MoveResult.Done : MoveResult.Crashed
            });
        }
Example #27
0
        private void HandleMoveRequest(MoveRequest packet)
        {
            player.CurrentSequenceKey = (byte)(packet.SequenceKey + 1);
            player.WalkRequestQueue.Enqueue(new WalkRequest(packet.SequenceKey,
                                                            packet.Direction, packet.MovementType, false));

            eventJournalSource.Publish(new PlayerMoveRequestedEvent(packet.Direction));
        }
Example #28
0
        public bool SendMove(Move move)
        {
            var moveRequest = new MoveRequest(move);

            byte[] moveRequestBytes = moveRequest.PackRequest();
            _tcpClient.GetStream().BeginWrite(moveRequestBytes, 0, moveRequestBytes.Length, new AsyncCallback(WriteCallBack), null);
            Log.Information("Sent Move request.");
            return(true);
        }
Example #29
0
    public static MoveRequest Create(int index, int handSlot, int customerSlot)
    {
        MoveRequest request = new MoveRequest();

        request.playerIndex  = index;
        request.handSlot     = handSlot;
        request.customerSlot = customerSlot;
        return(request);
    }
Example #30
0
        public void OnOprationRequest(string playerId, MoveRequest mr)
        {
            var unit = Find(mr.unitId);

            if (unit != null)
            {
                unit.OnPlayerOprationRequest(mr);
            }
        }
Example #31
0
        protected void MoveButton_Click(object sender, EventArgs e)
        {
            if (DeviceGridPanel.SelectedDevice != null)
            {
                string destinationDevices = string.Empty;
                string separator = string.Empty;
                int i = 0;
                IList<Device> devices = DeviceGridPanel.SelectedDevices;
                foreach (Device device in devices)
                {
                    if (i > 0) separator = ", ";
                    destinationDevices = device.AeTitle + separator + destinationDevices;
                    i++;
                }

                MoveConfirmation.Message = DialogHelper.createConfirmationMessage(string.Format(SR.MoveSeriesMessage, destinationDevices));
                
                MoveConfirmation.Message += DialogHelper.createSeriesTable(SeriesGridView.SeriesList);

                MoveConfirmation.MessageType = MessageBox.MessageTypeEnum.OKCANCEL;

                // Create the move request, although it really isn't needed.
                MoveRequest moveData = new MoveRequest();
                moveData.SelectedStudy = SeriesGridView.Study;
                moveData.DestinationDevices = DeviceGridPanel.SelectedDevices;
                moveData.Series = SeriesGridView.SeriesList;
                moveData.Partition = SeriesGridView.Partition;
                MoveConfirmation.Data = moveData;

                MoveConfirmation.Show();
            }
        }