Beispiel #1
0
        private void Move(UserToken token, MoveDto moveDto)
        {
            int id = userCache.GetUserId(token);

            moveDto.userId = id;
            Brocast(MapProtocol.Move_BRO, moveDto);
        }
        public MoveDto makeMove(MoveDto moveDto)
        {
            var moveEntity = getMoveFromIA(fromMoveDTOToMoveEntity(moveDto));

            _repository.saveMove(moveEntity);
            return(fromMoveEntityToMoveDTO(moveEntity));
        }
        private MoveEntity fromMoveDTOToMoveEntity(MoveDto move)
        {
            var config = new MapperConfiguration(c => c.CreateMap <MoveDto, MoveEntity>());
            var mapper = config.CreateMapper();

            return(mapper.Map <MoveEntity>(move));
        }
Beispiel #4
0
 public void PlayerMove(Player player, MoveDto data)
 {
     foreach (IPlayerMovement ipa in ListenersPlayerMovement)
     {
         ipa.PlayerMove(player, data);
     }
 }
        public IActionResult rateMove([FromBody] MoveDto moveDto)
        {
            BoardGame game = boardCreationService.createBoardGame(moveDto.game);

            return(ExecuteApiAction(() => new ApiResult <RatingDTO> {
                Model = gameService.rateMove(game, moveDto.move, moveDto.UserId, moveDto.lastMove)
            }));
        }
        public static string ToCSV(this MoveDto move)
        {
            if (move == null)
            {
                throw new ArgumentNullException("move");
            }

            return($"{move.Id},{move.Alias},{move.SourceId},{move.DestinationId}");
        }
Beispiel #7
0
        public async Task <IActionResult> MakeMove([FromBody] MoveDto move, Guid gameId)
        {
            var game = await this.gameService.MakeMoveAsync(move, gameId);

            if (game == null)
            {
                return(BadRequest());
            }
            return(Ok(game));
        }
Beispiel #8
0
        public void PlayerMove(Player player, MoveDto data)
        {
            GridGenerator terrainGrid = GridGenerator.Instance;

            terrainGrid.ChangeStateCell(data.lastCell, CellState.Empty);
            terrainGrid.ChangeStateCell(data.newCell, CellState.Occupied);

            player.SetPositionOnGrid(data.newCell);

            terrainGrid.MovePlayerOnGrid(data.lastCell, data.newCell, player.Visual);
        }
Beispiel #9
0
 /// <summary>
 /// 服务器返回移动
 /// </summary>
 /// <param name="moveDto"></param>
 void Move(MoveDto moveDto)
 {
     if (idToGameObjectDic.ContainsKey(moveDto.userId))
     {
         GameObject model = idToGameObjectDic[moveDto.userId];
         Vector3    pos   = new Vector3(moveDto.posx, moveDto.posy, moveDto.posz);
         Vector3    rota  = new Vector3(moveDto.rotax, moveDto.rotay, moveDto.rotaz);
         Vector3    dir   = new Vector3(moveDto.dirx, moveDto.diry, moveDto.dirz);
         model.GetComponent <SyncMove>().SetMove(pos, rota, dir);
     }
 }
        public async Task <ActionResult <Move> > Create(MoveDto move)
        {
            var newMove = new Move
            {
                Name     = move.Name,
                Attack   = move.Attack,
                Accuracy = move.Accuracy
            };
            var result = await _moveService.Create(newMove);

            return(CreatedAtRoute("GetMove", new { id = result.ID }, newMove));
        }
Beispiel #11
0
        public async Task <GameDto> MakeMoveAsync(MoveDto move, Guid gameId)
        {
            try
            {
                var  standardRepository = this.uow.GetStandardRepository();
                Game currentGame        = null;
                var  mappedMove         = this.mapper.Map <Move>(move);
                var  moves = await standardRepository.QueryAsync <Move>(x => x.GameId == gameId);

                int nextOrder = 1;
                if (moves.Count() > 0)
                {
                    var maxOrder = moves.Select(x => x.Order).Max();
                    nextOrder = maxOrder + 1;
                }

                mappedMove.Order    = nextOrder;
                mappedMove.IsPlayer = true;

                if (moves.Select(x => (int)x.Position).ToList().Contains(move.Position))
                {
                    return(null);
                }

                currentGame = await standardRepository.GetAsync <Game>(gameId);

                if (!currentGame.IsFinished)
                {
                    standardRepository.Add <Move>(mappedMove);
                    mappedMove.GameId = gameId;
                    await this.uow.SaveChangesAsync();
                }
                else
                {
                    return(null);
                }


                currentGame = await UpdateGameStatusAsync(gameId);

                if (!currentGame.IsFinished)
                {
                    currentGame = await MakeMachineTurnAsync(gameId);
                }

                return(this.mapper.Map <GameDto>(currentGame));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #12
0
 public void PushMove(MoveDto Input)
 {
     _context.Moves.Add(
         new Move
     {
         MatchId      = Input.MatchId,
         PlayerId     = Input.PlayerId,
         MoveLocation = Input.MoveLocation,
         MoveName     = Input.MoveName
     }
         );
     _context.SaveChanges();
 }
        public void WillPassTheGameToTheBoardCreationService()
        {
            MoveDto moveDto             = new MoveDto();
            List <List <JObject> > game = new List <List <JObject> >();

            moveDto.game = game;
            Mock <BoardCreationService> mockCreationService = new Mock <BoardCreationService>();

            mockCreationService.Setup(x => x.createBoardGame(game)).Verifiable();
            cont = new GameController(new Mock <IGameService>().Object, mockCreationService.Object, null);
            cont.rateMove(moveDto);
            mockCreationService.Verify();
        }
Beispiel #14
0
        private void RaiseEventPhoton(Vector3 newPos, Vector2Int newPosGrid, Vector2Int oldPosGrid)
        {
            byte evCode   = (byte)ConnectorPhoton.EventCode.EvMove;
            var  moveData = new MoveDto(newPos, oldPosGrid, newPosGrid);

            string content  = JsonUtility.ToJson(moveData);
            bool   reliable = true;

            PhotonNetwork.RaiseEvent(evCode, content, reliable, new RaiseEventOptions()
            {
                CachingOption = EventCaching.DoNotCache, Receivers = ReceiverGroup.Others
            });
        }
        public async Task <ActionResult <Move> > Update(string id, MoveDto move)
        {
            var updatedMove = new Move
            {
                ID       = id,
                Name     = move.Name,
                Attack   = move.Attack,
                Accuracy = move.Accuracy
            };
            await _moveService.Update(id, updatedMove);

            return(updatedMove);
        }
Beispiel #16
0
    /// <summary>
    /// 同步位置
    /// </summary>
    void SyncPos()
    {
        MoveDto    moveDto = new MoveDto();
        GameObject self    = GameData.play;

        moveDto.userId = GameData.UserDto.id;
        moveDto.posx   = self.transform.position.x;
        moveDto.posy   = self.transform.position.y;
        moveDto.posz   = self.transform.position.z;
        moveDto.rotax  = self.transform.eulerAngles.x;
        moveDto.rotay  = self.transform.eulerAngles.y;
        moveDto.rotaz  = self.transform.eulerAngles.z;
        moveDto.dirx   = 0;
        moveDto.diry   = 0;
        moveDto.dirz   = 0;
        NetIO.Instance.Write(Protocol.Map, SceneManager.GetActiveScene().buildIndex, MapProtocol.Move_CREQ, moveDto);
    }
Beispiel #17
0
    MoveDto GetMoveDto(float x, float y)
    {
        Transform model   = GameData.play.transform;
        MoveDto   moveDto = new MoveDto();

        moveDto.userId = GameData.UserDto.id;
        moveDto.posx   = model.position.x;
        moveDto.posy   = model.position.y;
        moveDto.posz   = model.position.z;
        moveDto.rotax  = model.eulerAngles.x;
        moveDto.rotay  = model.eulerAngles.y;
        moveDto.rotaz  = model.eulerAngles.z;
        moveDto.dirx   = x;
        moveDto.diry   = 0;
        moveDto.dirz   = y;
        return(moveDto);
    }
        public void WillPassTheGameTheMoveAndThePlayerIdToTheGameService()
        {
            MoveDto moveDto = new MoveDto();

            moveDto.move   = new Move();
            moveDto.UserId = 100;
            Mock <BoardGame>            mockGame            = new Mock <BoardGame>();
            Mock <IGameService>         mockGameService     = new Mock <IGameService>();
            Mock <BoardCreationService> mockCreationService = new Mock <BoardCreationService>();

            mockCreationService.Setup(x => x.createBoardGame(It.IsAny <List <List <JObject> > >()))
            .Returns(mockGame.Object);
            mockGameService.Setup(x => x.rateMove(mockGame.Object, moveDto.move, moveDto.UserId, null))
            .Returns((RatingDTO)null)
            .Verifiable();
            cont = new GameController(mockGameService.Object, mockCreationService.Object, null);
            cont.rateMove(moveDto);
            mockGameService.Verify();
        }
Beispiel #19
0
        public MoveDto Move()
        {
            var move = new MoveDto
            {
                Angle = "40",
                AutoCancel = "3",
                BaseDamage = "53",
                BaseKnockBackSetKnockback = "60/25",
                FirstActionableFrame = "2",
                HitboxActive = "23-25",
                Id = ++_moveCounter,
                KnockbackGrowth = "89",
                LandingLag = "11",
                Name = "falco phantasm",
                OwnerId = 1,
                Type = MoveType.Special
            };

            return move;
        }
Beispiel #20
0
        [HttpPost("{_}/move")] // Для универсальности ¯\_(ツ)_/¯
        public virtual IActionResult Move([FromBody] MoveDto move)
        {
            try
            {
                var startTime = DateTime.Now;
                var result    = _behavior.Move(MoveDto.MapFromDto(move));

                var diffMilliseconds = (DateTime.Now - startTime).Milliseconds;
                if (diffMilliseconds > 200)
                {
                    Console.WriteLine($"!!!!!!! Вычисление заняло {diffMilliseconds}");
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Ошибка при вызове Move => {ex.Message}");
                return(Ok());
            }
        }
Beispiel #21
0
        /// <summary>
        /// Determines if a move is within a bounding box.
        /// </summary>
        /// <param name="move">Target move</param>
        /// <param name="nodes">Enumerable of all nodes in the roadmap</param>
        /// <param name="boundingBox">Bounding box.</param>
        /// <returns>True if the move is within the bounding box.</returns>
        public static bool IsWithin(this MoveDto move, IEnumerable <NodeDto> nodes, Rect boundingBox)
        {
            if (move == null)
            {
                throw new ArgumentNullException("move");
            }

            if (nodes == null)
            {
                throw new ArgumentNullException("nodes");
            }

            NodeDto source = nodes.FirstOrDefault(e => e.Id == move.SourceId);

            if (source == null)
            {
                throw new ArgumentOutOfRangeException("Nodes does not contain source node for move");
            }

            NodeDto dest = nodes.FirstOrDefault(e => e.Id == move.DestinationId);

            if (dest == null)
            {
                throw new ArgumentOutOfRangeException("Nodes does not contain destination node for move");
            }

            if (boundingBox.Contains(source.ToPoint()))
            {
                return(true);
            }

            if (boundingBox.Contains(dest.ToPoint()))
            {
                return(true);
            }

            return(false);
        }
        public async Task <GameStateDto> MakeMove(MoveDto moveDto)
        {
            var uri  = new Uri("http://10.124.2.119:50001/tictactoe/api/game/move");
            var body = new StringContent(JsonConvert.SerializeObject(moveDto), Encoding.UTF8, "application/json");

            try
            {
                var response = await _client.PostAsync(uri, body);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    var gameState = JsonConvert.DeserializeObject <GameStateDto>(content);
                    return(gameState);
                }
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);
            }

            return(null);
        }
Beispiel #23
0
        public IHttpActionResult GetMoveOrderList([FromUri] MoveDto modeDto)
        {
            var moveService = new MoveService();
            var moveList    = moveService.GetMoveOrderList(modeDto.Status, modeDto.OrderNum, modeDto.StartTime, modeDto.EndTime).OrderByDescending(item => item.CreateTime);
            var listObj     = new List <Object>();

            moveList.ToList().ForEach(item =>
            {
                string MoveName, Status = "", OperateName;
                if (item.MoveType == 1)
                {
                    MoveName = "移库上架";
                }
                else if (item.MoveType == 2)
                {
                    MoveName = "仓库移库";
                }
                else
                {
                    MoveName = "报损移库";
                }
                if (item.Status == 1)
                {
                    Status = "等待审核";
                }
                else if (item.Status == 2)
                {
                    Status = "审核通过";
                }
                else
                {
                    Status = "审核失败";
                }
                if (item.OperateType == 1)
                {
                    OperateName = "电脑";
                }
                else
                {
                    OperateName = "其他";
                }
                var obj = new
                {
                    ID            = item.ID,
                    OrderNum      = item.OrderNum,
                    MoveType      = item.MoveType,
                    MoveTypeName  = MoveName,
                    Status        = item.Status,
                    StatusName    = Status,
                    Num           = item.Num,
                    Amout         = item.Amout,
                    CreateTime    = item.CreateTime.ToString("yyyy-MM-dd HH:MM"),
                    OperateType   = OperateName,
                    ContractOrder = item.ContractOrder,
                    Remark        = item.Remark
                };
                listObj.Add(obj);
            });
            var result = new
            {
                list = listObj
            };

            return(Json(result));
        }
        public IHttpActionResult PutMove(int id, MoveDto dto)
        {
            if (id != dto.Id)
            {
                return BadRequest();
            }

            _metadataService.Update<Move, MoveDto>(id, dto);
            return StatusCode(HttpStatusCode.NoContent);
        }
Beispiel #25
0
 public async Task <GameDto> MakeMoveAsync(MoveDto move)
 {
     return(null);
 }
 public IHttpActionResult PostMove(MoveDto dto)
 {
     var newDto = _metadataService.Add<Move, MoveDto>(dto);
     return CreatedAtRoute("DefaultApi", new { controller = MovesRouteKey + "", id = newDto.Id }, newDto);
 }
        public async Task <IActionResult> Move([FromBody] MoveDto move)
        {
            var count = db.Moves.Where(x => x.GameId == move.GameId).Count();

            if (count >= 5)
            {
                var data  = db.Moves.Where(x => x.GameId == move.GameId).Select(x => x.Position).ToList();
                var value = db.Moves.Where(x => x.GameId == move.GameId && x.MoveType == move.MoveType).Select(x => x.Position).ToList();
                var arr   = db.Moves.Where(x => x.MoveType == move.MoveType).OrderBy(x => x.Position).ToList();

                List <List <int> > test = new List <List <int> >
                {
                    new List <int>()
                    {
                        1, 2, 3
                    },
                    new List <int>()
                    {
                        4, 5, 6
                    },
                    new List <int>()
                    {
                        7, 8, 9
                    },
                    new List <int>()
                    {
                        1, 4, 7
                    },
                    new List <int>()
                    {
                        2, 5, 8
                    },
                    new List <int>()
                    {
                        3, 6, 9
                    },
                    new List <int>()
                    {
                        1, 5, 9
                    },
                    new List <int>()
                    {
                        3, 5, 7
                    },
                };

                var allNumbers = from l in test
                                 let numbers = l
                                               from n in numbers
                                               select n;
                foreach (var n in allNumbers)
                {
                    foreach (var a in arr)
                    {
                        var v = n.Equals(a);
                        if (move.MoveType == "x")
                        {
                            if (v)
                            {
                                return(Ok("Winner is Player" + move.PlayerId));
                            }
                        }
                        else if (move.MoveType == "x")
                        {
                            if (v)
                            {
                                return(Ok("Winner is Player" + move.PlayerId));
                            }
                        }
                        else
                        {
                            return(Ok("Game ends in a Tie"));
                        }
                    }
                }
            }
            var myMove = new Move()
            {
                MoveType = move.MoveType,
                Position = move.Position,
                PlayerId = move.PlayerId,
                GameId   = move.GameId,
            };
            await db.Moves.AddAsync(myMove);

            await db.SaveChangesAsync();

            return(Ok(true));
        }
        public void ShouldGetAllMovesByName(string name)
        {
            //arrange
            var character = ExecuteAndReturnContent<IEnumerable<dynamic>>(() => new CharactersController(_service).GetCharacters()).First();

            var move = TestObjects.Move();
            var move2 = new MoveDto
            {
                Id = 2,
                Name = name,
                OwnerId = character.Id
            };

            Post(move);
            Post(move2);

            //act
            var results = ExecuteAndReturnContent<IEnumerable<dynamic>>(() => _controller.GetMovesByName(name))
                .ToList();

            //assert
            CollectionAssert.AllItemsAreNotNull(results);
            CollectionAssert.AllItemsAreUnique(results);
            CollectionAssert.AllItemsAreInstancesOfType(results, typeof(MoveDto));
        }
 private MoveDto Post(MoveDto move)
 {
     return ExecuteAndReturnCreatedAtRouteContent<MoveDto>(
         () => _controller.PostMove(move));
 }