Ejemplo n.º 1
0
        public IActionResult AddPlayer(CreateGameModel model)
        {
            var             gameId        = model.gameId;
            var             game          = GetTotalGameInfo(gameId);
            CreateGameModel postBackModel = new CreateGameModel();

            if (ModelState.IsValid)
            {
                AddPlayer playerData = new AddPlayer();

                playerData.Name  = model.ludoplayer.name;
                playerData.Color = model.ludoplayer.playerColor;

                var request = new RestRequest($"api/ludo/{gameId}/players", Method.POST);
                request.RequestFormat = DataFormat.Json;
                request.AddJsonBody(playerData);
                IRestResponse addPlayerRequest = _client.Post(request);
                var           postedgame       = GetTotalGameInfo(gameId);
                postBackModel.ludoPlayers     = postedgame.ludoPlayers;
                postBackModel.numberOfPlayers = postedgame.numberOfPlayers;
                postBackModel.gameId          = postedgame.gameId;
                Log.Information("Added player with name: {nameOfPlayer}" + " with color: {playerColor}" + " and gameId: {gameId}", model.ludoplayer.name, model.ludoplayer.playerColor, gameId);
                return(View("GameConfiguration", postBackModel));
            }
            else
            {
                postBackModel.ludoPlayers     = game.ludoPlayers;
                postBackModel.numberOfPlayers = game.numberOfPlayers;
                postBackModel.gameId          = game.gameId;

                return(View("GameConfiguration", postBackModel));
            }
        }
        public NewGameViewModel()
        {
            Players = new ReactiveList <string>();

            var canStart = this.Players.CountChanged.Select(count => count >= 3);

            StartGame      = canStart.ToCommand();
            RandomizeOrder = canStart.ToCommand();

            RemovePlayer = ReactiveCommand.Create();
            AddPlayer    = this.WhenAnyValue(x => x.Players.Count, x => x.NewPlayerName,
                                             (count, newPlayerName) => count < 7 && !string.IsNullOrWhiteSpace(newPlayerName) && !this.Players.Contains(newPlayerName))
                           .ToCommand();

            RandomizeOrder.Subscribe(_ => {
                using (Players.SuppressChangeNotifications()) {
                    var r        = new Random();
                    var newOrder = Players.OrderBy(x => r.NextDouble()).ToList();
                    Players.Clear();
                    Players.AddRange(newOrder);
                }
            });

            RemovePlayer.Subscribe(player => {
                this.Players.Remove((string)player);
            });

            AddPlayer.Subscribe(_ => {
                Players.Add(NewPlayerName.Trim());
                NewPlayerName = string.Empty;
            });
        }
Ejemplo n.º 3
0
 void OnMouseDown()
 {
     foreach (var tile in tiles)
     {
         AddPlayer player = tile.GetComponent <AddPlayer>() as AddPlayer;
         player.player = unit;
     }
 }
        public void Ctor_ShouldReturnInstanceOfClass_WhenDependenciesAreValid()
        {
            Mock <ILogger <AddPlayer> >   mockLogger = new Mock <ILogger <AddPlayer> >();
            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            AddPlayer sut = new AddPlayer(mockLogger.Object, mockSkillRequestValidator.Object);

            Assert.IsType <AddPlayer>(sut);
        }
Ejemplo n.º 5
0
 private void AddPlayer_Click(object sender, RoutedEventArgs e)
 {
     if (sampleTeam == null)
     {
         sampleTeam = new Team(league, team.Text, manager.Text, phone.Text, email.Text, imageUrl.Text);
     }
     addPlayerWindow = new AddPlayer(sampleTeam, playersList, league);
     bool? res = addPlayerWindow.ShowDialog();
 }
Ejemplo n.º 6
0
    public async Task AddPlayerAsync(AddPlayer cmd)
    {
        var task = State.TeamExists() switch
        {
            Results.Unit => PersistPublishAsync(new PlayerAdded(cmd.Name, cmd.TeamId, cmd.TraceId, cmd.InvokerUserId)),
            Results x => PublishErrorAsync(new ErrorHasOccurred((int)x, x.ToString(), cmd.TraceId, cmd.InvokerUserId))
        };

        await task;
    }
Ejemplo n.º 7
0
    void Start()
    {
        m_board         = FindObjectOfType <Board>();
        m_spawner       = FindObjectOfType <Spawner>();
        m_soundManager  = FindObjectOfType <SoundManager>();
        m_scoreManager  = FindObjectOfType <ScoreManager>();
        m_ghost         = FindObjectOfType <Ghost>();
        m_holder        = FindObjectOfType <Holder>();
        m_addPlayer     = FindObjectOfType <AddPlayer>();
        m_getPlayerInfo = FindObjectOfType <GetPlayerInfos>();
        m_updatePlayer  = FindObjectOfType <UpdatePlayer>();

        m_timeToNextKey          = Time.time;
        m_timeToNextKeyLeftRight = Time.time + m_keyRepeatRateLeftRight;
        m_timeToNextKeyDown      = Time.time + m_keyRepeatRateDown;
        m_timeToNextKeyRotate    = Time.time + m_keyRepeatRateRotate;

        if (!m_spawner || !m_board || !m_soundManager || !m_scoreManager)
        {
            Debug.LogWarning("Warning! m_board or m_spawner or m_soundManager or m_scoreManager aren't defined.");
        }
        else
        {
            if (m_activeShape == null)
            {
                m_activeShape = m_spawner.SpawnShape();
            }

            m_spawner.transform.position = Vectorf.Round(m_spawner.transform.position);
        }

        if (m_gameOverPanel)
        {
            m_gameOverPanel.SetActive(false);
        }

        if (m_pausePanel)
        {
            m_pausePanel.SetActive(false);
        }


        m_dropIntervalModded          = m_dropInterval;
        m_soundManager.m_fxEnabled    = SaveManager.Instance.IsFxOn();
        m_soundManager.m_musicEnabled = SaveManager.Instance.IsMusicOn();

        m_soundManager.m_fxIconToggle.ToggleIcon(m_soundManager.m_fxEnabled);
        m_soundManager.m_musicIconToggle.ToggleIcon(m_soundManager.m_musicEnabled);

        m_soundManager.UpdateMusic();
    }
        public void Handle_ShouldThrowArgumentNullException_WhenTokenUserIsNull()
        {
            Mock <ILogger <AddPlayer> > mockLogger = new Mock <ILogger <AddPlayer> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            AddPlayer sut = new AddPlayer(mockLogger.Object, mockSkillRequestValidator.Object);

            SkillRequest skillRequest = new SkillRequest();

            Assert.Throws <ArgumentNullException>(() => sut.Handle(skillRequest, null));
        }
Ejemplo n.º 9
0
        // Add Player MSG
        private AddPlayer GetAPMSG(byte[] msg, Int64 msgSize)
        {
            Int32 type = ByteInt32(msg[8]);

            byte[] seq_num = new byte[4];
            byte[] vars    = new byte[msgSize - 13];

            Array.Copy(msg, 9, seq_num, 0, 4);
            Array.Copy(msg, 13, vars, 0, msgSize - 13);

            AddPlayer APMSG = APMSGVars(vars);

            APMSG.msgType = type;
            return(APMSG);
        }
Ejemplo n.º 10
0
        public IHttpActionResult AddPlayerToGameByGameId([FromBody] AddPlayer model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var response = DBService.AddPlayerToGame(model.GameID, model.UserId);

            if (response == 0)
            {
                return(BadRequest("Cant add player"));
            }

            return(Ok());
        }
Ejemplo n.º 11
0
        public ActionResult Add()
        {
            // The Add.cshtml needs a list of Teams:
            var         team_query = "SELECT * FROM teams ORDER BY name";
            List <Team> teams      = db.Teams.SqlQuery(team_query).ToList();

            // The Add.cshtml needs a list of Positions:
            var             position_query = "SELECT * FROM Positions";
            List <Position> positions      = db.Positions.SqlQuery(position_query).ToList();

            AddPlayer AddPlayerViewModel = new AddPlayer();

            AddPlayerViewModel.Teams     = teams;
            AddPlayerViewModel.Positions = positions;

            return(View(AddPlayerViewModel));
        }
        public void Handle_ShouldThrowArgumentNullException_WhenCalledWithInvalidSkillRequest()
        {
            Mock <ILogger <AddPlayer> > mockLogger = new Mock <ILogger <AddPlayer> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(false);

            AddPlayer sut = new AddPlayer(mockLogger.Object, mockSkillRequestValidator.Object);

            TokenUser tokenUser = new TokenUser()
            {
                Players = new List <Player>()
            };

            SkillRequest skillRequest = new SkillRequest();

            Assert.Throws <ArgumentNullException>(() => sut.Handle(skillRequest, tokenUser));
        }
        public void Handle_ShouldReturnSkillResponse_WhenCalledWithValidInputs()
        {
            Mock <ILogger <AddPlayer> > mockLogger = new Mock <ILogger <AddPlayer> >();

            Mock <ISkillRequestValidator> mockSkillRequestValidator = new Mock <ISkillRequestValidator>();

            mockSkillRequestValidator.Setup(x => x.IsValid(It.IsAny <SkillRequest>())).Returns(true);

            AddPlayer sut = new AddPlayer(mockLogger.Object, mockSkillRequestValidator.Object);

            SkillRequest skillRequest = GenerateValidSkillRequest(new IntentRequest()
            {
                RequestId = "TestRequestId",
                Locale    = "en-US",
                Type      = "IntentRequest",
                Intent    = new Intent()
                {
                    ConfirmationStatus = "CONFIRMED",
                    Name  = "AddPlayer",
                    Slots = new Dictionary <string, Slot>()
                    {
                        {
                            "player",
                            new Slot()
                            {
                                Name  = "player",
                                Value = "blue",
                                ConfirmationStatus = "NONE"
                            }
                        }
                    }
                }
            });

            TokenUser tokenUser = new TokenUser()
            {
                Players = new List <Player>()
            };

            SkillResponse skillResponse = sut.Handle(skillRequest, tokenUser);

            Assert.IsType <SkillResponse>(skillResponse);
        }
Ejemplo n.º 14
0
        private void EnableLogIn()  //Habilita botones cuando usuario inicia sesion
        {
            DelegadoParaLogIn delegadoLogIn = new DelegadoParaLogIn(LogIn);

            text.Invoke(delegadoLogIn);
            empezar.Invoke(delegadoLogIn);
            AddPlayer.Invoke(delegadoLogIn);
            TextMessage.Invoke(delegadoLogIn);
            nombre.Invoke(delegadoLogIn);
            pass.Invoke(delegadoLogIn);

            //label6.Text = "Has iniciado sesión como: " + conectado;  //Lo quito de aqui por el tema del excepcion cross thread
            DelegadoParaEscribir delegado = new DelegadoParaEscribir(PonNombre);

            label6.Invoke(delegado, new object[] { conectado });

            //mensajes.Items.Add("Has iniciado sesión como : " + conectado);
            DelegadoParaMensajes delegadoMensajes = new DelegadoParaMensajes(PonMensaje);

            mensajes.Invoke(delegadoMensajes, new object[] { conectado });
        }
Ejemplo n.º 15
0
        public async Task AddPlayerShouldCreateDbEntity()
        {
            var externalId = Guid.NewGuid().ToString();
            var command    = new AddPlayer()
            {
                ExternalId = externalId,
                FirstName  = "Test FirstName",
                LastName   = "Test LastName"
            };

            var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <PlayerAdded>(
                _testDbFixture.GetPlayerByExternalId,
                externalId);

            await _rabbitMqFixture.PublishAsync(command);

            Player player = await creationTask.Task;

            player.FirstName.Should().Be(command.FirstName);
            player.LastName.Should().Be(command.LastName);
            player.ExternalId.Should().Be(command.ExternalId);
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            //

            AddPlayer    player     = new AddPlayer("rooooooms", null, "playerNaameab"); // port do komunikacji zwraca w resultMessage() jako string;
            RoomCreation room       = new RoomCreation("playeeerr", "rooooooms", 3);
            RoomStart    start      = new RoomStart("roomnaaamex", "token", "abs");
            PlayerMove   playerMove = new PlayerMove();

            //udpClient.SendRequest<RoomStart>(start, 38621);

            //########## PIERW TO
            //RoomManager rm = new RoomManager(38621);
            //rm.addRoom("abs", "roomnaaame", 3);

            //########## POTEM TO Z NAZWA POKOJU CO ADDROOM
            //PlayerManager pm = new PlayerManager(38621);
            //pm.addPlayer("roomnaaame", null, "playernameA");


            //####### POTEM TO I WSZYSTKO DZIAŁA
            UdpManager udpClient = new UdpManager();
            RoomStart  start1    = new RoomStart("roomnaaamex", "token", "abs");

            Console.WriteLine(udpClient.SendRequest <RoomStart>(start1, 38621).isRequestSuccess());

            //to jest odpowiedzialne za poruszanie graczem
            //wysylasz swoj ruch i konczysz polaczenie
            //udpClient.SendRequestPlayerMove(playerMove, 58278);
            //laczysz sie z serwerem i sluchasz wiadomosci
            while (true)
            {
                //udpClient.waitForMessages(58278);
                //jak jakas przyjdzie mozesz dac break i znow SendRequestPlayerMove z twoim ruchem
            }
            Console.Read();
        }
Ejemplo n.º 17
0
        public int addPlayer(String roomName, String roomPassword, String playerName, out List <string> players)
        {
            AddPlayer player = new AddPlayer(roomName, roomPassword, playerName);

            factory.Request r = udp.SendRequest <AddPlayer>(player, serverPort);
            int             port;

            Debug.Log("RESPONSE ON ADD PLAYER: " + r.additionalInformations());
            players = ResponseHandler.getArrayFromString(r.additionalInformations());
            if (int.TryParse(r.responseMessage(), out port))
            {
                Debug.Log("ADDING PLAYER ON PORT: " + port);
                Debug.Log("PLAYER LIST: ");
                foreach (string p in players)
                {
                    Debug.Log("PLAYER: " + p);
                }
                return(port);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 18
0
        public static Command UnpackCommand(BinaryReader reader)
        {
            var commandType = (CommandType)reader.ReadByte();

            Command command;

            switch (commandType)
            {
            case CommandType.SetRandomSeed:
                command = new SetRandomSeed();
                break;

            case CommandType.AddPlayer:
                command = new AddPlayer();
                break;

            case CommandType.RemovePlayer:
                command = new RemovePlayer();
                break;

            case CommandType.Respawn:
                command = new Respawn();
                break;

            case CommandType.SetSpaceshipControls:
                command = new SetSpaceshipControls();
                break;

            default:
                return(null);
            }

            command.LoadState(reader);

            return(command);
        }
Ejemplo n.º 19
0
        private AddPlayer APMSGVars(byte[] playerType)
        {
            AddPlayer msg = new AddPlayer(ByteInt32(playerType));

            return(msg);
        }
Ejemplo n.º 20
0
    public void OnAddPlayerInGameReciveMessageClient(NetworkMessage receiverMsg)
    {
        AddPlayer msg = receiverMsg.ReadMessage <AddPlayer>();

        GameObject.Find("SceneController").GetComponent <OnlineGameProcesClient>().AddPlayer(msg.type, (sbyte)msg.point);
    }
Ejemplo n.º 21
0
 public byte[] SerializeMSG(AddPlayer msg)
 {
     byte[] header = Header(msg.msgType);
     byte[] body   = BuildMSG(msg.playerType);
     return(Combine(IntByte((Int64)8 + header.Length + body.Length), header, body));
 }
Ejemplo n.º 22
0
 public async Task <IActionResult> Post(AddPlayer command)
 {
     return(await SendAsync(command));
 }
 public static void OnAddPlayer(object sender, PlayerDataEventArgs e)
 {
     AddPlayer?.Invoke(null, e);
 }
Ejemplo n.º 24
0
 public async Task <IActionResult> AddPlayer([FromBody] AddPlayer command)
 => await ProcessCommand(command);