예제 #1
0
        private void ReinitializeDictionaries()
        {
            ActivePlayers.Clear();

            Teams.Clear();
            Teams[ETeamID.TEAM_1] = new List <EPlayerID>();
            Teams[ETeamID.TEAM_2] = new List <EPlayerID>();
            Teams[ETeamID.TEAM_3] = new List <EPlayerID>();
            Teams[ETeamID.TEAM_4] = new List <EPlayerID>();

            partyStatusMap.Clear();
            PlayersTeam.Clear();
            PlayersDeathPositions.Clear();
            PlayersDeathRotations.Clear();

            // Adding all players (Besides Spectator and None)
            foreach (EPlayerID playerID in Enum.GetValues(typeof(EPlayerID)))
            {
                if ((playerID != EPlayerID.NONE) &&
                    (playerID != EPlayerID.SPECTATOR))
                {
                    PlayersTeam.Add(playerID, ETeamID.NONE);
                    PlayersDeathPositions.Add(playerID, Vector3.zero);
                    PlayersDeathRotations.Add(playerID, Quaternion.identity);
                    partyStatusMap.Add(playerID, new PlayerJoinStatus(EControllerID.NONE));
                }
            }
        }
예제 #2
0
        private void On_INPUT_ControllerDisconnected(BEHandle <EControllerID> eventHandle)
        {
            EControllerID controllerID = eventHandle.Arg1;

            if (IS_KEY_CONTAINED(ControllersMap, controllerID))
            {
                EPlayerID playerID = ControllersMap[controllerID];

                // Was a joined controller?
                if (playerID != EPlayerID.SPECTATOR &&
                    IS_KEY_CONTAINED(partyStatusMap, playerID))
                {
                    partyStatusMap[playerID].Flush();
                }

                // Destroy Player
                if (ActivePlayers.ContainsKey(playerID))
                {
                    DestroyPlayer(playerID);
                }

                ControllersMap.Remove(controllerID);

                BEventsCollection.PLAYERS_PlayerLeft.Invoke(new BEHandle <EPlayerID, EControllerID>(playerID, controllerID));
            }
        }
예제 #3
0
        private void CompareNodes(ChanceTreeNode *pNode0, ChanceTreeNode *pNode1)
        {
            double probab0 = pNode0->Probab;
            double probab1 = pNode1->Probab;

            double probabDiff = Math.Abs(probab0 - probab1);

            SumProbabDiff += probabDiff;
            MaxProbabDiff  = Math.Max(MaxProbabDiff, probabDiff);

            double relProbabDiff = (probab0 + probab1) != 0 ? probabDiff / (probab0 + probab1) / 2 : 0;

            SumRelProbabDiff += relProbabDiff;
            MaxRelProbabDiff  = Math.Max(MaxRelProbabDiff, relProbabDiff);

            UInt16[] activePlayers;
            activePlayers = ActivePlayers.Get(_playersCount, 2, _playersCount);

            double[] potShares0 = new double[_playersCount];
            double[] potShares1 = new double[_playersCount];
            foreach (UInt16 ap in activePlayers)
            {
                pNode0->GetPotShare(ap, potShares0);
                pNode1->GetPotShare(ap, potShares1);

                for (int p = 0; p < _playersCount; ++p)
                {
                    double potShareDiff = Math.Abs(potShares0[p] - potShares1[p]);
                    SumPotShareDiff[p] += potShareDiff;
                    MaxPotShareDiff[p]  = Math.Max(MaxPotShareDiff[p], potShareDiff);
                }
            }
        }
    public void Despawn(PlayerIndex index, bool removeActivePlayer)
    {
        PlayerInput player = _players.FirstOrDefault(p => p.Index == index);

        if (player)
        {
            Transform playerTransform = player.transform;
            Destroy(player.gameObject);

            ParticleSystem particleEmitter = Instantiate(_despawnParticleEffect, playerTransform.position, Quaternion.identity);
            particleEmitter.transform.parent = gameObject.transform;

            Material material = player.GetComponentInChildren <SkinnedMeshRenderer>().material;
            particleEmitter.GetComponent <Renderer>().material = material;
            int removedPlayers = _players.RemoveAll(p => p.Index == index);
            _colorController.ReturnMaterialToPool(material);

            if (removedPlayers > 0)
            {
                AudioManager.Instance.PlayOneShot("Character Death");
                if (removeActivePlayer)
                {
                    ActivePlayers.RemovePlayer(new Player((int)index, material));
                }
            }
        }
    }
    public void Spawn(PlayerIndex index, bool addActivePlayer)
    {
        if (LobbyStateManager.Instance.State == LobbyStateManager.LobbyState.TitleScreen || !LobbyStateManager.Instance.CameraAtDestination)
        {
            return;
        }

        if (!_players.FirstOrDefault(p => p.Index == index))
        {
            Vector3    position = _spawnLocations[(int)index - 1];
            GameObject player   = Instantiate(_playerPrefab, position, Quaternion.identity);
            player.GetComponent <PlayerInput>().Index = index;
            player.transform.parent = gameObject.transform;

            Material material = _colorController.AssignRandomPlayerMaterial(player);
            _players.Add(player.GetComponent <PlayerInput>());
            AudioManager.Instance.PlayOneShot("Player Jump");

            if (PlayerSelectUIManager.Instance.PlayerIsReady(index))
            {
                _colorController.ShowIcon(index);
            }
            else
            {
                _colorController.HideIcon(index);
            }

            if (addActivePlayer)
            {
                ActivePlayers.AddPlayer(new Player((int)index, material));
            }
        }
    }
예제 #6
0
        public void LeavePlayer(EPlayerID playerID)
        {
            if ((IS_KEY_CONTAINED(partyStatusMap, playerID)) &&
                (IS_TRUE(partyStatusMap[playerID].HasJoined)))
            {
                // Destroy Player
                if (ActivePlayers.ContainsKey(playerID))
                {
                    DestroyPlayer(playerID);
                }

                // Reset controller to Spectator
                EControllerID controllerID = partyStatusMap[playerID].ControllerID;
                if (IS_KEY_CONTAINED(ControllersMap, controllerID))
                {
                    ControllersMap[controllerID] = EPlayerID.SPECTATOR;
                }

                // Reset entry of playerID in party status
                partyStatusMap[playerID] = new PlayerJoinStatus(EControllerID.NONE);

                // Trigger global event
                BEventsCollection.PLAYERS_PlayerLeft.Invoke(new BEHandle <EPlayerID, EControllerID>(playerID, controllerID));

                // Are the rest of the joined players ready?
                CheckIfAllPlayersAreReady();
            }
        }
예제 #7
0
        public void Test_GetActivePlayers()
        {
            UInt16[] ap;
            // Total: 0
            ap = ActivePlayers.Get(0, 0, 0);
            Assert.AreEqual(1, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);

            // Total: 1
            ap = ActivePlayers.Get(1, 0, 0);
            Assert.AreEqual(1, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);
            ap = ActivePlayers.Get(1, 0, 1);
            Assert.AreEqual(2, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);
            Assert.AreEqual(1, ap[1]);

            // Total: 2
            ap = ActivePlayers.Get(2, 0, 0);
            Assert.AreEqual(1, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);

            ap = ActivePlayers.Get(2, 0, 1);
            Assert.AreEqual(3, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);
            Assert.AreEqual(1, ap[1]);
            Assert.AreEqual(2, ap[2]);

            ap = ActivePlayers.Get(2, 1, 1);
            Assert.AreEqual(2, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(1, ap[0]);
            Assert.AreEqual(2, ap[1]);

            ap = ActivePlayers.Get(2, 0, 2);
            Assert.AreEqual(4, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(0, ap[0]);
            Assert.AreEqual(1, ap[1]);
            Assert.AreEqual(2, ap[2]);
            Assert.AreEqual(3, ap[3]);

            // Total: 3
            ap = ActivePlayers.Get(3, 2, 2);
            Assert.AreEqual(3, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(3, ap[0]);
            Assert.AreEqual(5, ap[1]);
            Assert.AreEqual(6, ap[2]);

            ap = ActivePlayers.Get(3, 3, 3);
            Assert.AreEqual(1, ap.Length);
            Array.Sort(ap);
            Assert.AreEqual(7, ap[0]);
        }
예제 #8
0
 void IStarcraftBot.onPlayerLeft(SWIG.BWAPI.Player player)
 {
     if (ActivePlayers.ContainsKey(player.getName()))
     {
         ActivePlayers.Remove(player.getName());
     }
 }
예제 #9
0
        /// <summary>
        ///     Remove player from the game
        /// </summary>
        public void RemovePlayer(PokerPlayer player)
        {
            if (player != null)
            {
                //null these here so we know that one of the key players for the next game has left
                if (DealerButton == player)
                {
                    DealerButton = null;
                }
                if (SmallBlind == player)
                {
                    SmallBlind = null;
                }
                if (BigBlind == player)
                {
                    BigBlind = null;
                }

                //Move to view list so that they can continue viewing the game
                if (ActivePlayers.Contains(player))
                {
                    Viewers.Add(player.Owner);
                }

                Players.Remove(player);

                player.LeaveGame(this);
            }
        }
예제 #10
0
    /// <summary>
    /// Initializes Players arrays and Input array depending on the number of players in the game.
    /// First player always gets WSADE keymap and red color indication, whereas second gets Arrow-0 keymap and green color indication.
    /// Both players instantiate in their own predefined locations.
    /// </summary>
    /// <param name="_numberOfPlayers"></param>
    private void InitializePlayers(ActivePlayers _numberOfPlayers)
    {
        int numOfPlayers = _numberOfPlayers == ActivePlayers.OnePlayer ? 1 : 2;

        _playerModels        = new PlayerModel[numOfPlayers];
        _playerControllers   = new PlayerController[numOfPlayers];
        _playerViews         = new PlayerView[numOfPlayers];
        _playerInputControls = new InputControl [numOfPlayers];
        for (int i = 0; i < numOfPlayers; i++)
        {
            _playerViews [i]         = GameObject.Instantiate <PlayerView> (_playerPrefab);
            _playerInputControls [i] = _playerViews [i].gameObject.AddComponent <InputControl> ( );
            _playerModels [i]        = new PlayerModel(_playerStartTimeInSeconds);
            if (i == 0)
            {
                _playerViews [i].transform.localPosition = MoveableAreaConstants._firstPlayerSpawnPoint;
                _playerViews [i].AssignPlayerViewDetails(Color.red, "Player1", _scoreTextPlayer01, _timeTextPlayer01);
                _playerInputControls [i].AssignInputs(KeyCode.W, KeyCode.S, KeyCode.D, KeyCode.A, KeyCode.E);
                _playerModels [i]._playerID = PlayerID.Player01;
            }
            else
            {
                _playerViews [i].transform.localPosition = MoveableAreaConstants._secondPlayerSpawnPoint;
                _playerViews [i].AssignPlayerViewDetails(Color.green, "Player2", _scoreTextPlayer02, _timeTextPlayer02);
                _playerInputControls [i].AssignInputs(KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.RightArrow, KeyCode.LeftArrow, KeyCode.Keypad0);
                _playerModels [i]._playerID = PlayerID.Player02;
            }
            _playerControllers [i] = _playerViews [i].gameObject.AddComponent <PlayerController> ( );
            _playerControllers [i].Init(_playerModels [i], _playerViews [i], _playerInputControls [i]);
        }
    }
예제 #11
0
        public void ResetGame()
        {
            CloseGumps();

            State = PokerGameState.Inactive;

            RoundActions = new List <PlayerAction>();

            CommunityCards.Clear();

            //create and shuffle a new deck
            Deck = new Deck();

            PokerPots.Clear();

            ActivePlayers.Clear();

            foreach (var player in Players.ToArray())
            {
                player.ClearGame();
            }

            ActivePlayers.AddRange(Players.Where(x => x.Currency > 0));

            if (GetActiveElliblePlayersCount() > 1)
            {
                BeginGame();
            }
            else
            {
                StopIntermission();
                ActivePlayers.Clear();
            }
        }
예제 #12
0
 public void RankHands()
 {
     foreach (var player in ActivePlayers.Where(x => !x.HasFolded))
     {
         player.RankHand(CommunityCards);
     }
 }
예제 #13
0
        /// <summary>
        /// UC014 Start (Deal) a New Hand
        /// </summary>
        /// <see cref="https://docs.google.com/document/d/1OTee6BGDWK2usL53jdoeBOI-1Jh8wyNejbQ0ZroUhcA/edit#heading=h.3z6a7b6nlnjj"/>
        public void StartNewHand()
        {
            while (true)
            {
                Monitor.Enter(_lock);
                while (ActivePlayers.Count < Preferences.MinNumberOfPlayers)
                {
                    Monitor.Wait(_lock);
                    //throw new NotEnoughPlayersException("Its should be at least 2 active players to start new hand!");
                }
                Monitor.Exit(_lock);

                if (this.CurrentHand != null && this.CurrentHand.Active)
                {
                    throw new NotEnoughPlayersException("The previous hand hasnt ended");
                }

                Player dealer = ActivePlayers.ElementAt(dealerIndex);
                CurrentHand = new Hand(dealer, ActivePlayers, Preferences);

                CurrentHand.PlayHand(_lock);
                EndCurrentHand();

                /* Note: only the first player joining the room start
                 * the new thread of the hand
                 */
            }
        }
예제 #14
0
        /// <summary>
        /// Remove the player from the Active Players list for the Mission.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool RemoveActivePlayer(Client client)
        {
            if (!ActivePlayers.Contains(client))
            {
                return(false);
            }

            ActivePlayers.Remove(client);
            client.ResetData(EntityData.ActiveMission);
            NAPI.ClientEvent.TriggerClientEvent(client, "MissionInfo", "Mission_Active_Players", "");
            NAPI.ClientEvent.TriggerClientEvent(client, "MissionInfo", "Mission_Active_Objectives", "");

            string activePlayers = JsonConvert.SerializeObject(GetActivePlayers());

            for (int i = 0; i < ActivePlayers.Count; i++)
            {
                NAPI.ClientEvent.TriggerClientEvent(NAPI.Player.GetPlayerFromHandle(ActivePlayers[i]), "MissionInfo", "Mission_Active_Players", activePlayers);
            }

            if (ActivePlayers.Count <= 0)
            {
                CleanupMission();
            }

            return(true);
        }
예제 #15
0
        private void RoboPlayerCallback(RoboPlayerPlugin plugin, RoboCard[] chosenCards, Exception ex)
        {
            RoboPlayer player = plugin.Player;

            if (player == null || !ActivePlayers.Contains(plugin))
            {
                return;
            }
            if (player.PlayerState != RoboPlayerState.Thinking || ex != null)
            {
                player.PlayerState = RoboPlayerState.Error;
            }
            else
            {
                if (player.EndRound(chosenCards))
                {
                    player.PlayerState = RoboPlayerState.Decided;
                }
                else
                {
                    player.PlayerState = RoboPlayerState.Error;
                }
            }

            Action playingCards = DoPlayingCards;

            playingCards.BeginInvoke(null, playingCards);
        }
예제 #16
0
 /// <summary>
 /// Check if only one player is left that isn't allin.
 /// </summary>
 private void CheckAllins()
 {
     if (ActivePlayers.Count(x => x.Allin) == ActivePlayers.Length - 1 && ActivePlayers.First(x => !x.Allin).Checked)
     {
         foreach (var player2 in ActivePlayers)
         {
             player2.Allin = true;
         }
     }
     else
     {
         CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex);
     }
     // If only one player isn't allin, check everyone as allin. No further actions can be taken.
     //if (ActivePlayers.Where(x => !x.Allin && x.Checked).Count() <= 1)
     //{
     //    foreach (var player2 in ActivePlayers)
     //    {
     //        player2.Allin = true;
     //    }
     //}
     //else
     //{
     //    CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex);
     //}
 }
예제 #17
0
        public bool Fold(Msg message)
        {
            if (ValidPlayer(message.From))
            {
                var player = Players.FirstOrDefault(x => x.UserId == message.From.UserId);

                if (player.Active && !player.Allin && !player.Checked)
                {
                    player.Active = false;
                    Bot.Say(player.Username, "Foldaat.");
                    if (ActivePlayers.Count(x => x.Allin) == ActivePlayers.Length - 1 && ActivePlayers.First(x => !x.Allin).Checked)
                    {
                        foreach (var player2 in ActivePlayers)
                        {
                            player2.Allin = true;
                        }
                    }
                }
                if (!CheckStatuses())
                {
                    CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex);
                }
                return(true);
            }
            else
            {
                NotAPlayer(message.From.Username);
            }
            return(false);
        }
예제 #18
0
        /// <summary>
        /// Get the index of the next active player after the given index.
        /// </summary>
        private int NextActivePlayerIndex(int currentIndex, bool informOfTurn = true)
        {
            currentIndex++;
            if (currentIndex >= Players.Count)
            {
                currentIndex = 0;
            }

            int loopCount = 0;

            while (loopCount < 100 && (!Players[currentIndex].Active || Players[currentIndex].Allin))
            {
                currentIndex++;
                if (currentIndex >= Players.Count)
                {
                    currentIndex = 0;
                }
                loopCount++;
            }

            if (informOfTurn && ActivePlayers.Where(x => x.Checked).Count() != ActivePlayers.Length)
            {
                InformOfPlayerTurn(currentIndex);
            }

            return(currentIndex);
        }
예제 #19
0
        /// <summary>
        /// Add the player to the Active Players list for the Mission.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public bool AddActivePlayer(Client client)
        {
            if (client.HasData(EntityData.ActiveMission))
            {
                client.SendChatMessage("You must leave your current mission to join a new one. /leavemission");
                return(false);
            }

            if (ActivePlayers.Contains(client))
            {
                return(false);
            }

            ActivePlayers.Add(client);
            client.SetData(EntityData.ActiveMission, this);

            string activePlayers    = JsonConvert.SerializeObject(GetActivePlayers());
            string activeObjectives = JsonConvert.SerializeObject(GetObjectives());

            for (int i = 0; i < ActivePlayers.Count; i++)
            {
                NAPI.ClientEvent.TriggerClientEvent(NAPI.Player.GetPlayerFromHandle(ActivePlayers[i]), "MissionInfo", "Mission_Active_Players", activePlayers);
                NAPI.ClientEvent.TriggerClientEvent(NAPI.Player.GetPlayerFromHandle(ActivePlayers[i]), "MissionInfo", "Mission_Active_Objectives", activeObjectives);
            }

            return(true);
        }
예제 #20
0
        private void GameEnded()
        {
            gameEnded = true;
            List <Player> Results = new List <Player>();

            for (int i = 0; i < ActivePlayers.Count; i++)
            {
                Results = ActivePlayers.ToList <Player>();
                //Results.OrderBy(ActivePlayer => ActivePlayer.TotalScore).ToList();
            }

            var orderByResult = from r in Results
                                orderby r.TotalScore descending
                                select r;

            PlayVictorySound();
            MessageBox.Show(orderByResult.First().Firstname.ToString() + " vann med " + orderByResult.First().TotalScore.ToString() + " poäng");
            dbOps.SaveGameTransaction(ActivePlayers);



            if (MessageBox.Show("Spelet är s**t, vill du avsluta?", "Avsluta spel", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                //rutan stängs ned här
            }
            else
            {
                gameEngine.NullProps();
                playerEngine.NullProps();

                SelectedViewModel = new MainMenuViewModel();
            }
        }
 private void Start()
 {
     if (!AudioManager.Instance.IsPlaying("Menu Theme"))
     {
         AudioManager.Instance.FadeInSound("Menu Theme", 1f);
     }
     ActivePlayers.Reset();
 }
    public void Reset()
    {
        List <GameObject> players = GetComponentsInChildren <PlayerInput>().Select(p => p.gameObject).ToList();

        players.ForEach(p => DestroyPlayer(p));
        ActivePlayers.Reset();
        _players.Clear();
        _playersToRespawn.Clear();
    }
    public void SetPlayerColor(GameObject player, Material material)
    {
        PlayerInput input = player.GetComponent <PlayerInput>();

        player.GetComponentInChildren <SkinnedMeshRenderer>().material = material;
        ActivePlayers.UpdateMaterial((int)player.GetComponent <PlayerInput>().Index, material);
        PlayerSelectUIManager.Instance.UpdateColor(input.Index, material);
        _playerMaterials[input.Index] = material;
    }
예제 #24
0
        public Game(
            Dictionary <string, string> userProfileMap,
            Dictionary <string, List <string> > roleToUsers,
            List <string> activePlayers,
            string mafiaTarget,
            string doctorTarget,
            string voteTarget,
            GameState currentState
            )
        {
            CurrentState = currentState;
            List <string> mafiaIdList;  // all mafias
            List <string> doctorIdList;

            roleToUsers.TryGetValue(Role.Mafia.ToString(), out mafiaIdList);
            roleToUsers.TryGetValue(Role.Doctor.ToString(), out doctorIdList);

            foreach (KeyValuePair <string, string> idWithName in userProfileMap)
            {
                Player newPlayer = new Player(idWithName.Key, idWithName.Value);
                AddPlayer(newPlayer);
                newPlayer.Vote   = voteTarget;
                newPlayer.Active = true;

                if (activePlayers.Contains(newPlayer.Id))
                {
                    // TODO: Sheriff
                    if (mafiaIdList != null && mafiaIdList.Contains(newPlayer.Id))
                    {
                        var mafia = new Mafia(newPlayer);
                        mafia.Target = mafiaTarget;
                        Mafias.Add(mafia);
                        PlayerMapping[newPlayer.Id] = mafia;
                        ActivePlayers.Add(mafia);
                    }
                    else if (doctorIdList != null && doctorIdList.Contains(newPlayer.Id))
                    {
                        var doctor = new Doctor(newPlayer);
                        doctor.Target = doctorTarget;
                        Doctors.Add(doctor);
                        PlayerMapping[newPlayer.Id] = doctor;
                        ActivePlayers.Add(doctor);
                    }
                    else
                    {
                        var village = new Villager(newPlayer);
                        PlayerMapping[newPlayer.Id] = village;
                        ActivePlayers.Add(village);
                    }
                }
                else
                {
                    newPlayer.Active            = false;
                    PlayerMapping[newPlayer.Id] = newPlayer;
                }
            }
        }
예제 #25
0
    public void InitPlayers()
    {
        ActivePlayers.Clear();
        BettingPlayers = 0;

        for (int i = 0; i < Config.MaxPlayers; i++)
        {
            if (i < Config.Players)
            {
                ActivePlayers.Add(players[i]);
                //turn on active players game objects
                players[i].gameObject.SetActive(true);
            }
            else
            {
                //turn off inactive players gameobjects
                players[i].gameObject.SetActive(false);
                //players[i].Role = Role.Defeated;
            }
        }


        for (int i = 0; i < ActivePlayers.Count; i++)
        {
            //if player has been initialized, reset player.
            if (!ActivePlayers[i].Initialized)
            {
                ActivePlayers[i].Init(i, turnSequencer, this, Config.placingBetDelay, Config.takeDelay, options.CardBackground);
            }

            ActivePlayers[i].ResetPlayer();

            if (!Config.specialCards)
            {
                ActivePlayers[i].Cards = deck.GetCardsFromLiveDeckTasselated(i); //give activePlayers random cards
            }
            else
            {
                ActivePlayers[i].Cards = deck.GetSpecialCards(i);
            }

            ActivePlayers[i].StartReceivingCards();
        }
        //Recalculate turning order after live players list has been created.
        turnSequencer.RecalculateTurningOrder(ActivePlayers);

        PlayDealingSound();
        //test

        //activePlayers[0].MakeAllCardsHighestRank();
        //activePlayers[1].MakeAllCardsHighestRank();
        //activePlayers[2].MakeAllCardsHighestRank();
    }
예제 #26
0
        public void AssignVoteToPlayers(string voteId)
        {
            // If the vote is not within active players, assign null to the Vote property
            if (!ActivePlayers.Select(p => p.Id).Contains(voteId))
            {
                voteId = null;
            }

            foreach (Player player in ActivePlayers)
            {
                player.Vote = voteId;
            }
        }
 public void SetPlayers(ActivePlayers players)
 {
     _players          = players;
     _lastPlayerChange = DateTime.Now;
     System.IO.File.WriteAllText("players/playerLeft_name.txt", _players.playerLeft.name);
     System.IO.File.WriteAllText("players/playerLeft_deck.txt", _players.playerLeft.deck);
     System.IO.File.WriteAllText("players/playerLeft_score.txt", _players.playerLeft.score);
     System.IO.File.WriteAllText("players/playerLeft_lpoints.txt", _players.playerLeft.lifePoints);
     System.IO.File.WriteAllText("players/playerRight_name.txt", _players.playerRight.name);
     System.IO.File.WriteAllText("players/playerRight_deck.txt", _players.playerRight.deck);
     System.IO.File.WriteAllText("players/playerRight_score.txt", _players.playerRight.score);
     System.IO.File.WriteAllText("players/playerRight_lpoints.txt", _players.playerRight.lifePoints);
 }
예제 #28
0
        private void VoteOutPlayer()
        {
            // All players have the same vote
            string playerVote = ActivePlayers.FirstOrDefault()?.Vote;

            if (string.IsNullOrEmpty(playerVote))
            {
                return;
            }

            Player playerToEliminate = PlayerMapping[playerVote];

            EliminatePlayer(playerToEliminate);
        }
예제 #29
0
 public void AddActivePlayer(Player player, int index)
 {
     player.Team = this;
     ActivePlayers.Insert(index, player);
     if (metadata.NumActivePlayers.HasValue)
     {
         if (ActivePlayers.Count > metadata.NumActivePlayers.Value)
         {
             Player end = ActivePlayers[ActivePlayers.Count - 1];
             ActivePlayers.RemoveAt(ActivePlayers.Count - 1);
             BenchPlayers.Insert(0, end);
         }
     }
 }
예제 #30
0
        /// <summary>
        ///     Creates a list of active players and grabs the next active player that can act. If play doesn't exist, grab the
        ///     first player in the list
        ///     <returns>next active player</returns>
        /// </summary>
        public PokerPlayer GetNextActivePlayer(PokerPlayer current)
        {
            var index = ActivePlayers.IndexOf(current);

            PokerPlayer activeplayer;

            do
            {
                activeplayer = ActivePlayers[index == -1 ? 0 : (index + 1 >= ActivePlayers.Count ? 0 : (index + 1))];
                index        = ActivePlayers.IndexOf(activeplayer);
            }while (activeplayer.Currency == 0 || activeplayer.HasFolded);

            return(activeplayer == current ? null : activeplayer);
        }