Exemplo n.º 1
0
        public async Task <ActionResult <PlayerRound> > GetExistingRound(int playerHistoryID)
        {
            PlayerRoundBE playerRoundBE = await base.Adapter.GetExistingRound(playerHistoryID);

            PlayerRound playerRound = base.Mapper.Map <PlayerRound>(playerRoundBE);

            return(playerRound);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <PlayerRound> > GetGuestTriviaRound()
        {
            PlayerRoundBE playerRoundBE = await base.Adapter.GetTriviaRound(null);

            PlayerRound playerRound = base.Mapper.Map <PlayerRound>(playerRoundBE);

            return(playerRound);
        }
        public async Task <PlayerRoundCardInLimbo> AddLimboAsync(PlayerRound playerRound, Card card)
        {
            var cardInLimbo = new PlayerRoundCardInLimbo
            {
                CardId        = card.Id,
                InsertedIn    = DateTime.Now,
                PlayerRoundId = playerRound.Id
            };

            await CreateAsync(cardInLimbo);

            return(cardInLimbo);
        }
Exemplo n.º 4
0
        private void SaveDieCount(string username, int numberOfDice)
        {
            var lastRound = _gameService.AddRoundIfNotExists();
            var player    = _playerService.AddPlayerIfNotExists(username);

            var playerRound = new PlayerRound()
            {
                NumberOfDice = numberOfDice,
                Player       = player,
                Round        = lastRound
            };

            _db.PlayerRound.Add(playerRound);
            _db.SaveChanges();
        }
Exemplo n.º 5
0
        private void SaveDice(string username, List <int> dice)
        {
            var currentRound = _gameService.AddRoundIfNotExists();
            var player       = _playerService.AddPlayerIfNotExists(username);

            var playerRound = new PlayerRound()
            {
                Dice         = string.Join(",", dice),
                NumberOfDice = dice.Count,
                Player       = player,
                Round        = currentRound
            };

            _db.PlayerRound.Add(playerRound);
            _db.SaveChanges();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Recieve round results from the game manager
        /// </summary>
        /// <param name="round">The object from server containing the players round result information</param>
        public void SendRoundResults(PlayerRound round)
        {
            //Only one thread may manage the GUI
            if (System.Threading.Thread.CurrentThread != Dispatcher.Thread)
            {
                //Hand the task to the dispatcher
                Dispatcher.BeginInvoke(new Action <PlayerRound>(SendRoundResults), new object[] { round }); //Cannot pass raw players as it excepts an object[]
                return;
            }

            //Update health and the current action
            currentAction         = -1;
            health                = health - round.HealthLost < 0 ? 0 : health - round.HealthLost;
            WaitingBox.Visibility = Visibility.Hidden;
            RefreshUI();

            //Check if the player won (in the event of a tie, it will just show that both died)
            if (health > 0 && round.Results[0] == "You are the last player standing!")
            {
                GameEndText.Content      = round.Results[0];
                GameEndScreen.Visibility = Visibility.Visible;
                ResetGameState();
            }
            else
            {
                // Ensure results don't go out of bounds
                for (int i = 0; i < round.Results.Count; ++i)
                {
                    if (round.Results[i].Length > 29)
                    {
                        int lastSpace = round.Results[i].Substring(0, 29).LastIndexOf(' ');
                        round.Results[i] = $"{round.Results[i].Substring(0, lastSpace)}\n{round.Results[i].Substring(lastSpace + 1)}";
                    }
                }

                // Temporary displaying the result
                ResultsText.Content = round.Results.Aggregate((r1, r2) => r1 + '\n' + r2); //Store all round results
                EnableActionButtons();

                if (health <= 0)
                {
                    GameEndText.Content      = "You have died!";
                    GameEndScreen.Visibility = Visibility.Visible;
                    ResetGameState(true);
                }
            }
        }
 // Called during a remove operation
 private void detach_Instance(PlayerRound playerRound)
 {
     NotifyPropertyChanging("ExerciseInstance");
     //playerRound.ParentScorecard = null;
 }
 // Called during an add operation
 private void attach_Instance(PlayerRound playerRound)
 {
     NotifyPropertyChanging("ExerciseInstance");
     //playerRound.p = this;
 }
 // Called during a remove operation
 private void detach_Instance(PlayerRound playerRound)
 {
     NotifyPropertyChanging("ExerciseInstance");
     playerRound.Player = null;
 }