private IEnumerator UpdateSetups() { while (true) { yield return(null); if (Players.Any(x => x == null)) { Players.Clear(); AllPlayerEntities.Clear(); PlayerStates.Clear(); Players.AddRange(Scene.SceneTracker.allPlayers); for (int i = 0; i < Scene.SceneTracker.allPlayers.Count; i++) { BoltEntity b = Scene.SceneTracker.allPlayers[i].GetComponent <BoltEntity>(); if (b != null) { AllPlayerEntities.Add(b); PlayerStates.Add(b.GetState <IPlayerState>()); } } } yield return(new WaitForSeconds(10)); } }
private void Update() { try { if (BoltNetwork.isRunning && LocalPlayer.Entity != null && LocalPlayer.Entity.isAttached) { PlayerName = LocalPlayer.Entity.GetState <IPlayerState>().name; } } catch { } // Only in Multiplayer if (!BoltNetwork.isRunning || Scene.SceneTracker == null || Scene.SceneTracker.allPlayerEntities == null) { return; } // Refresh players Players.Clear(); Players.AddRange(TheForest.Utils.Scene.SceneTracker.allPlayerEntities .Where(o => o.isAttached && o.StateIs <IPlayerState>() && LocalPlayer.Entity != o && //o.GetState<IPlayerState>().name != GriefClientPro.PlayerName && o.gameObject.activeSelf && o.gameObject.activeInHierarchy && o.GetComponent <BoltPlayerSetup>() != null) .OrderBy(o => o.GetState <IPlayerState>().name) .Select(o => new Player(o))); }
public FormationViewModel(FormationDbManager formationDbManager) { myGame = MainViewModel.Instance.CurrentGame; Guid teamId = MainViewModel.Instance.Team.Id; Players.AddRange(ServiceLocator.GetService <PlayersService>().GetPlayersForTeamId(teamId)); myFormationDbManager = formationDbManager; }
/// <summary> /// Seats the players at the table. /// </summary> /// <param name="players">The players to be seated.</param> public void SeatPlayers(List <IPlayer> players) { Players.AddRange(players); foreach (IPlayer player in this) { player.Table = this; } }
public void AddPlayers(IEnumerable <Player> players) { Players.AddRange(players); UpdateStarters(); Events.Add(new TeamChangedEvent(Id)); foreach (var player in players) { Events.Add(new PlayerChangedEvent(player)); } }
public void InitPlayers(Player first, Player second) { if (Players.Count > 0) { throw new InvalidOperationException("Players already initialized"); } Players.AddRange(new Player[] { first, second }); SetCardsToPlayers(); }
public PlayersViewModel() { try { PlayersService service = ServiceLocator.GetService <PlayersService>(); Players.AddRange(service.GetPlayersForTeamId(MainViewModel.Instance.Team.Id)); } catch (Exception e) { Console.WriteLine(e); } }
public void AddPlayers(params string[] players) { if (Players.Any(players.Contains)) { throw new DuplicateKeyException("The players being added are already on this team."); } Players.AddRange(players); foreach (var team in ScoreboardManager.Teams.Where(t => t != this)) { foreach (var player in players.Where(team.Players.Contains)) { team.RemovePlayers(player); } } foreach (var client in Server.Clients.Where(c => c.IsLoggedIn)) { client.SendPacket(SetTeamsPacket.AddPlayers(Name, players)); } }
static Database() { Players.AddRange( new[] { new Player { Name = "Pietje", PlayerClass = PlayerClass.Fighter, PlayerRace = PlayerRace.Dwarf }, new Player { Name = "Jantje", PlayerClass = PlayerClass.Fighter, PlayerRace = PlayerRace.Dwarf }, } ); NPC.AddRange( new[] { new NPC { Name = "Grum", PlayerRace = PlayerRace.Dwarf, StartGold = 100, BluffChance = 5 }, new NPC { Name = "Olm", PlayerRace = PlayerRace.Dwarf, StartGold = 120, BluffChance = 15 }, } ); }
private async Task UpdateQueueOrder(bool firstRound) { List <ClientHandler> temporary = new List <ClientHandler>(); Card bestCard = firstRound ? null : Assess(); await UpdatePlayersStats(); for (int i = 0; i < Players.Count; i++) { if (firstRound) { if (Players[i].PlayerStats.CurrentCard != null && Players[i].PlayerStats.CurrentCard.Value == Values.Two && Players[i].PlayerStats.CurrentCard.Suit == Suits.Clubs) { break; } } else { if (Players[i].PlayerStats.CurrentCard.Equals(bestCard)) { break; } } temporary.Add(Players[i]); //TODO check if works Players[i].PlayerStats.CurrentCard = null; } if (temporary.Count > 0) { Players.RemoveRange(0, temporary.Count); Players.AddRange(temporary); temporary = null; } }
public MainVM() { Players.CollectionChanged += (s, e) => PlayersPresentationData.OnPlayersInfoUpdate(Players.OrderByDescending(p => p.PlayerName.Length).First().PlayerName); DBWorker dataBase = new DBWorker(); Players.AddRange(dataBase.GetAllPlayers(). Select(p => new PlayerDataVM(p)). ToList()); int playersCount = Players.Count; for (int i = 0; i < MIN_PLAYERS_COUNT - playersCount; ++i) { Players.Add(new PlayerDataVM(new Player( "Player " + (Players.Count + 1).ToString(), 0, Players.Count >= _defaultPlayerColours.Length ? Color.FromRgb(125, 125, 125) : _defaultPlayerColours[Players.Count] ))); } Players.LinkActionToPlayerDataList(Player_OnPlayerSelected); ChangePointsVM.OnPlayerPointsChanged += ChangePointsVM_OnPlayerPointsChanged; }
public void StartNewRound() { GameCounter += 1; if (InactivePlayer == null) { foreach (var p in Players) { p.Stitches.Clear(); p.Cards.Clear(); p.Game = new Game(GameType.Grand); switch (p.Position) { case PlayerPosition.Middlehand: p.Position = PlayerPosition.Forehand; p.BidStatus = BidStatus.Accept; break; case PlayerPosition.Rearhand: p.Position = PlayerPosition.Middlehand; p.BidStatus = BidStatus.Bid; break; case PlayerPosition.Forehand: p.Position = PlayerPosition.Rearhand; p.BidStatus = BidStatus.Wait; break; default: break; } } } else { var nextPlayers = new Player[3]; var newPlayer = InactivePlayer; newPlayer.Position = PlayerPosition.Rearhand; newPlayer.BidStatus = BidStatus.Wait; newPlayer.Stitches.Clear(); newPlayer.Cards.Clear(); newPlayer.Game = new Game(GameType.Grand); nextPlayers[2] = newPlayer; foreach (var p in Players) { p.Stitches.Clear(); p.Cards.Clear(); p.Game = new Game(GameType.Grand); if (p.Position == PlayerPosition.Forehand) { InactivePlayer = p; p.Position = PlayerPosition.Inactive; p.BidStatus = BidStatus.Wait; } else if (p.Position == PlayerPosition.Middlehand) { p.Position = PlayerPosition.Forehand; p.BidStatus = BidStatus.Accept; nextPlayers[0] = p; } else if (p.Position == PlayerPosition.Rearhand) { p.Position = PlayerPosition.Middlehand; p.BidStatus = BidStatus.Bid; nextPlayers[1] = p; } } Players.Clear(); Players.AddRange(nextPlayers); } MatadorsJackStraight = null; GameStarted = false; GamePlayer = null; GameValue = null; IsSpeedUp = false; SkatTaken = false; CurrentPlayer = null; Stitch.Clear(); Skat.Clear(); LastStitch.Clear(); CurrentHistory = new GameHistory(); var deck = Card.GenerateDeck(); foreach (var player in Players) { player.Cards.AddRange(Card.Draw(deck, 10)); player.SortCards(); CurrentHistory.PlayerCards.Add((player.Name, new List <Card>(player.Cards))); } Skat.AddRange(Card.Draw(deck, 2)); CurrentHistory.Skat.AddRange(Skat); BidSaid = false; BidValueIndex = -1; }
public void Update(ServerState newState, Connection connection) { lock (ServerStateLock) { if (Status != newState.Status) { connection.RecordMatchResults(this); } if (connection.ServerHookEnabled && Teams != newState.Teams) { Scoreboard.RegenerateScoreboardImage = true; } Name = newState.Name; Port = newState.Port; HostPlayer = newState.HostPlayer; SprintEnabled = newState.SprintEnabled; SprintUnlimitedEnabled = newState.SprintUnlimitedEnabled; DualWielding = newState.DualWielding; AssassinationEnabled = newState.AssassinationEnabled; VotingEnabled = newState.VotingEnabled; Teams = newState.Teams; Map = newState.Map; MapFile = newState.MapFile; Variant = newState.Variant; VariantType = newState.VariantType; NumPlayers = newState.NumPlayers; MaxPlayers = newState.MaxPlayers; TeamScores = newState.TeamScores; Passworded = newState.Passworded; Xnkid = newState.Xnkid; Xnaddr = newState.Xnaddr; IsDedicated = newState.IsDedicated; GameVersion = newState.GameVersion; EldewritoVersion = newState.EldewritoVersion; PreviousStatus = Status; Status = newState.Status; inLobby = Status == "InLobby"; isLoading = Status == "Loading"; GameVariantType = GameVariant.GetBaseGameID(VariantType); } //string date = System.DateTime.Now.ToString("[MM-dd-yyyy HH:mm:ss] "); string date = $"[{DateTimeUTC()}] "; // Detect Match Start and End if (Status != PreviousStatus) { // Game Started if (Status == Connection.StatusStringInGame) { connection.InvokeMatchBeganOrEnded(new Connection.MatchBeginEndArgs(true, connection)); //connection.OnMatchBeginOrEnd(this, new Connection.MatchBeginEndArgs(true, connection)); connection.PrintToConsole("Game Started: " + newState.Variant + " ON " + newState.Map); } // Game Ended else if (Status == Connection.StatusStringInLobby && PreviousStatus == Connection.StatusStringInGame) { connection.InvokeMatchBeganOrEnded(new Connection.MatchBeginEndArgs(false, connection)); //connection.OnMatchBeginOrEnd(this, new Connection.MatchBeginEndArgs(false, connection)); connection.PrintToConsole("Game Ended"); PlayerStatsRecord match; foreach (PlayerInfo player in Players) { match = App.PlayerStatsRecords.Value.Find(x => x.Uid == player.Uid); if (match != null) { match.Kills += player.Kills; match.Deaths += player.Deaths; } else { match = new PlayerStatsRecord(player); if (match.IsValid) { App.PlayerStatsRecords.Value.Add(match); } } } App.PlayerStatsRecords.Save(); } } // For each player in the new server state's player list foreach (PlayerInfo player in newState.Players) { if (player.Name.Length == 0) { continue; } if (!Teams) { player.Team = -1; } else if (Status == Connection.StatusStringInLobby) { player.Team = -1; } else if (Status == Connection.StatusStringLoading) { player.Team = -1; } // If the player list does not contain this player, this player has just joined the game PlayerInfo match = Players.Find(x => x.Uid == player.Uid); if (match == null) { connection.PrintToPlayerLog(player.Name + " - " + player.ServiceTag + " : " + player.Uid + " has Joined."); connection.OnPlayerJoined(new Connection.PlayerJoinLeaveEventArgs(player, true, newState.Players.Count, date, connection)); lock (ServerStateLock) { // add new player to the player list Players.Add(player); } } } // For each player in the player list foreach (PlayerInfo player in Players) { // If the new server state's player list does not contain this player, this player has just left the game //NOTE added '&& x.Name == player.Name', so if any bugs crop up check here PlayerInfo match = newState.Players.Find(x => x.Uid == player.Uid && x.Name == player.Name); if (match == null) { connection.PrintToPlayerLog(player.Name + " - " + player.ServiceTag + " : " + player.Uid + " has Left."); connection.OnPlayerLeft(new Connection.PlayerJoinLeaveEventArgs(player, false, newState.Players.Count, date, connection)); // Mark player for removal from players list RemovePlayers.Add(player); } else { if (player.Team != match.Team && player.Team != -1 && match.Team != -1) { // Player has switched teams connection.OnPlayerTeamChanged(this, new Connection.PlayerTeamChangeEventArgs(match, player, connection)); } lock (ServerStateLock) { // Update the player's stats player.Update(match); } } } lock (ServerStateLock) { // Remove players that left from the player list foreach (PlayerInfo removePlayer in RemovePlayers) { Players.Remove(removePlayer); } RemovePlayers.Clear(); // Sort by team and then by score List <IGrouping <int, PlayerInfo> > teams = Players.GroupBy(x => x.Team).OrderBy(x => x.Key).ToList(); Players.Clear(); foreach (IGrouping <int, PlayerInfo> team in teams) { Players.AddRange(team.OrderByDescending(x => x.Score)); } OrderedTeamScores.Clear(); OrderedTeams.Clear(); RankedPlayers.Clear(); // Sort team scores for scoreboard display if (Teams) { OrderedTeamScores = TeamScores.Select( (x, i) => (Players.Any(p => p.Team == i)) ? new Tuple <int, int>(i, x) : new Tuple <int, int>(-1, x) ) // Mark all empty teams with -1 .Where(x => x.Item1 > -1) // Grab all non-empty teams .OrderByDescending(x => x.Item2).ToList(); // Order teams by score (descending) connection.PopulatedTeams = OrderedTeamScores?.Count ?? 1; for (int i = 0; i < OrderedTeamScores.Count; i++) { OrderedTeams.Add( new Tuple <Tuple <int, int>, List <PlayerInfo> >( OrderedTeamScores[i], Players.Where(x => x.Team == OrderedTeamScores[i].Item1).ToList() ) ); } } } }
public void AddPlayers(List<Player> players) { Players.AddRange(players); }
public IEnumerable <ManualPockerPlayer> AddPlayers(IEnumerable <ManualPockerPlayer> players) { this.Players.Clear(); return(Players.AddRange(players)); }