public async Task <List <PlayerPositionDTO> > MapPlayerPositionDtos(DAL.App.DTO.Identity.AppUser user) { var databasePositions = await ServiceUnitOfWork.PlayerPostionRepository.GetUserPositions(user.Id); var positions = new List <PlayerPositionDTO>(); foreach (var position in databasePositions) { var pos = new PlayerPositionDTO() { Position = position.PersonPosition }; positions.Add(pos); } return(positions); }
private static List <PlayerPositionDTO> MapPositionToPlayerPositionDtos( List <DAL.App.DTO.PlayerPosition> positions) { var postions = new List <PlayerPositionDTO>(); foreach (var pos in positions) { var dto = new PlayerPositionDTO() { Id = pos.Id, Position = pos.PersonPosition }; postions.Add(dto); } return(postions); }
public void RefreshBoardStateSuccess() { var assignedPlayerId = Guid.NewGuid().ToString(); var playerPos1 = new PlayerPositionDTO { PlayerId = assignedPlayerId, X = 10, Y = 10 }; var playerPos2 = new PlayerPositionDTO { PlayerId = Guid.NewGuid().ToString(), X = 20, Y = 20 }; var playerPositions = new List <PlayerPositionDTO> { playerPos1, playerPos2 }; var msg2 = new Message <RefreshStateResponsePayload> { Type = Common.Consts.RefreshStateResponse, SenderId = Common.Consts.GameMasterId, RecipientId = assignedPlayerId, Payload = new RefreshStateResponsePayload { CurrentPositionDistanceToClosestPiece = 10, Team1Score = 5, Team2Score = 6, Timestamp = 123, PlayerPositions = playerPositions } }; _messageProvider.Setup(x => x.Receive <ActionValidPayload>()).Returns(new Message <ActionValidPayload>()); _messageProvider.Setup(x => x.Receive <RefreshStateResponsePayload>()).Returns(msg2); var game = new GameInfo() { BoardSize = new BoardSize { GoalArea = 20, TaskArea = 20, X = 20 } }; _playerState.Game = game; _playerState.Board = new Board(game.BoardSize); _playerState.Id = assignedPlayerId; var actionExecutor = new ActionExecutor(_messageProvider.Object, _playerState); var result = actionExecutor.RefreshBoardState(); Assert.That(result, Is.True); (int foundX, int foundY) = _playerState.Board.FindPlayerPosition(assignedPlayerId); Assert.That(foundX, Is.Not.Negative); Assert.That(foundY, Is.Not.Negative); Assert.That(_playerState.Board.At(foundX, foundY).DistanceToClosestPiece, Is.EqualTo(msg2.Payload.CurrentPositionDistanceToClosestPiece)); Assert.That(_playerState.X, Is.EqualTo(playerPos1.X)); Assert.That(_playerState.Y, Is.EqualTo(playerPos1.Y)); foreach (var p in playerPositions) { Assert.That(_playerState.Board.At(p.X, p.Y).PlayerId, Is.EqualTo(p.PlayerId)); Assert.That(_playerState.Board.At(p.X, p.Y).Timestamp, Is.EqualTo(msg2.Payload.Timestamp)); } }