public void RemoveSpectator(PlayerMobile pm, bool teleport) { if (!IsSpectator(pm)) { return; } Spectators.Remove(pm); if (teleport) { var bounce = BounceInfo.GetValue(pm); if (bounce != null && !bounce.InternalOrZero) { Teleport(pm, bounce, bounce); BounceInfo.Remove(pm); } else { Teleport(pm, Options.Locations.Eject, Options.Locations.Eject); } } OnSpectatorRemoved(pm); }
/// <summary> /// Adds a spectator /// </summary> public static void AddSpectator(Guid id) { var client = ClientHandler.GetById(id); if (client == null) { return; } if (Spectators.Contains(client)) { return; } if (Participants.Contains(client)) { Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Participant"); ClientHandler.BroadcastServerMessage($"{client.Name} has left the game."); Participants.Remove(client); } Spectators.Add(client); Console.WriteLine($"Spectator {client.Id}|{client.Name} added to the game of {CurrentGameType}"); ClientHandler.BroadcastServerMessage($"{client.Name} is now spectating."); }
public bool AddSpectator(string id) { if (Spectators.Contains(id)) { return(false); } Spectators.Add(id); return(true); }
public override JObject ToJson() { var jobj = new JObject(); jobj["white"] = White?.Player?.Id ?? 0; jobj["black"] = Black?.Player?.Id ?? 0; jobj["spectators"] = JToken.FromObject(Spectators.Select(x => x.Player.Id).ToList()); jobj["wait"] = Black == null ? 0 : (int)(InnerGame.turn == OtherGame.WHITE ? PlayerSide.White : PlayerSide.Black); jobj["cheat"] = UsesAntiCheat; jobj["fen"] = InnerGame?.generate_fen() ?? ""; return(jobj); }
public void RemoveSpectator(PlayerMobile pm, bool teleport) { if (!IsSpectator(pm)) { return; } Spectators.Remove(pm); if (teleport) { Teleport(pm, Options.Locations.Eject, Options.Locations.Eject.Map); } OnSpectatorRemoved(pm); }
/// <summary> /// Invokes the <see cref="UserDropping"/> event from derived classes. /// </summary> protected void OnDroppingUser(IUser user) { if (Players.Contains(user, DiscordComparers.UserComparer)) { Players = Players.Remove(user, DiscordComparers.UserComparer); } else if (Spectators.Contains(user, DiscordComparers.UserComparer)) { Spectators = Spectators.Remove(user, DiscordComparers.UserComparer); } else { throw new ArgumentException("The given user is not playing in or spectating this game.", nameof(user)); } UserDropping?.Invoke(this, new UserDroppingEventArgs(user)); }
public void MessageSpectators(Player p, string Content) { if (!Spectators.Contains(p) && this != p) { return; } if (this != p) { this.AddQueue(Packets.Packets.IrcMessage(Content, p.Username, "#spectator", p.Id)); } for (int i = 0; i < Spectators.Count; i++) { if (Spectators[i] != p) { Spectators[i].AddQueue(Packets.Packets.IrcMessage(Content, p.Username, "#spectator", p.Id)); } } }
public void AddSpectator(ISocket spec) { var ret = ""; ret += (int)PacmanGame.EventType.BoardReset + " " + Game.GetBoardString() + "*"; ret += (int)PacmanGame.EventType.PacmanLives + " " + Game.Pacman.Lives + "*"; foreach (var g in Game.Ghosts) { ret += (int)PacmanGame.EventType.GhostUpdate + $" {g.GetPosition().ToString()} {g.IsDead} {g.IsVulnerable}*"; } ret += (int)PacmanGame.EventType.PacmanUpdate + " " + Game.Pacman.GetPosition().ToString() + "*"; ret += (int)PacmanGame.EventType.Score + " " + Game.Score; spec.WriteData(ret); if (spec.IsConnected) { Spectators.Add(spec); } }
/// <summary> /// Adds a participant /// </summary> public static void AddParticipant(Client client) { if (Participants.Contains(client)) { return; } if (Spectators.Contains(client)) { Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Spectator"); ClientHandler.BroadcastServerMessage($"{client.Name} is no longer spectating."); Spectators.Remove(client); } Participants.Add(client); Console.WriteLine($"Participant {client.Id}|{client.Name} added to the game of {CurrentGameType}"); ClientHandler.BroadcastServerMessage($"{client.Name} has joined the game."); }
public static Element Hud( IWorkshopTree players = null, IWorkshopTree header = null, IWorkshopTree subheader = null, IWorkshopTree text = null, HudLocation location = HudLocation.Top, double?sortOrder = null, Color headerColor = Color.White, Color subheaderColor = Color.White, Color textColor = Color.White, HudTextRev reevaluation = HudTextRev.VisibleToSortOrderAndString, Spectators spectators = Spectators.DefaultVisibility) => Element.Part <A_CreateHudText>( players ?? Element.Part <V_AllPlayers>(), header ?? Element.Part <V_Null>(), subheader ?? Element.Part <V_Null>(), text ?? Element.Part <V_Null>(), EnumData.GetEnumValue(location), new V_Number(sortOrder == null ? 0 : sortOrder.Value), EnumData.GetEnumValue(headerColor), EnumData.GetEnumValue(subheaderColor), EnumData.GetEnumValue(textColor), EnumData.GetEnumValue(reevaluation), EnumData.GetEnumValue(spectators) );
public bool Disconnect(string id) { if (!Spectators.Remove(id)) { Player player = Players.Find(p => p.Id == id); if (player != null) { if (player.IsTurn) { NextTurn(); } if (Players.IndexOf(player) < PlayerTurn) { PlayerTurn--; } Players.Remove(player); return(true); } } return(false); }
public void AddSpectator(PlayerMobile pm, bool teleport) { if (pm == null || pm.Deleted) { return; } if (!CanSpectate(pm)) { OnSpectateReject(pm); return; } Spectators.Add(pm); if (teleport) { Teleport(pm, Options.Locations.SpectateJoin, Options.Locations.Map); } OnSpectatorAdded(pm); }
private void UpdateUsers() { var data = ""; for (var i = 0; i < Game.CurrentGameEvent.Count; i++) { var e = Game.CurrentGameEvent[i]; data += ((int)e.Key + " " + e.Value); if (i < Game.CurrentGameEvent.Count - 1) { data += "*"; } } Game.CurrentGameEvent.Clear(); foreach (var chat in chats) { data += "*CHAT " + chat; } chats.Clear(); for (var i = 0; i < Spectators.Count; i++) { Spectators[i].WriteData(data); if (!Spectators[i].IsConnected) { Spectators.RemoveAt(i); i--; } } User.Socket.WriteData(data); if (!User.Socket.IsConnected) { IsRunning = false; } }
static void Main(string[] args) { Person pDominikWiesend = new Person("Dominik", "Wiesend"); Person pBenediktWiesend = new Person("Benedikt", "Wiesend"); SteamAccount saDominikWiesend = new SteamAccount("STEAM:0:05642354"); SteamAccount saBenediktWiesend = new SteamAccount("STEAM:0:213124354"); Player plDominikWiesend = new Player() { Person = pDominikWiesend, SteamAccounts = new List <SteamAccount>() { saDominikWiesend } }; Player plBenediktWiesend = new Player() { Person = pBenediktWiesend, SteamAccounts = new List <SteamAccount>() { saBenediktWiesend } }; // <summary> // Create Team #1 // </summary> Team team1 = new Team(); team1.TeamFlag = "DE"; team1.TeamName = "DominikWiesend"; team1.TeamTag = "DW"; team1.Logo = string.Empty; team1.Players = new List <Player>() { plDominikWiesend }; // <summary> // Create Team #2 // </summary> Team team2 = new Team(); team2.TeamFlag = "DE"; team2.TeamName = "BenediktWiesend"; team2.TeamTag = "BW"; team2.Logo = string.Empty; team2.Players = new List <Player>() { plBenediktWiesend }; // <summary> // Create a new spectators team. // </summary> Spectators spectators = new Spectators() { Players = new List <Player>() { plDominikWiesend, plBenediktWiesend } }; // <summary> // Create a new Match // </summary> Match match = new Match(); match.Team1 = team1; match.Team2 = team2; match.Spectators = spectators; match.MatchName = "Dominik [vs] Benedikt"; // <summary> // Save the Match to the database. // </summary> using (CSGOServerDatabase dbContext = new CSGOServerDatabase()) { dbContext.Persons.Add(pDominikWiesend); dbContext.Persons.Add(pBenediktWiesend); dbContext.SteamAccounts.Add(saDominikWiesend); dbContext.SteamAccounts.Add(saBenediktWiesend); dbContext.Players.Add(plDominikWiesend); dbContext.Players.Add(plBenediktWiesend); dbContext.Spectators.Add(spectators); dbContext.Teams.Add(team1); dbContext.Teams.Add(team2); dbContext.Matches.Add(match); dbContext.SaveChanges(); } // <summary> // Get all match config(s) from Database. // </summary> #region // <summary> // Create a new database context connection. // </summary> using (CSGOServerDatabase dbContext = new CSGOServerDatabase()) { List <Match> matches = dbContext.Matches.ToList(); foreach (Match myMatch in matches) { string json = JsonConvert.SerializeObject(myMatch, Formatting.Indented); Console.WriteLine(json); Console.ReadKey(); } } #endregion }
public bool IsSpectator(PlayerMobile pm) { return(Spectators.Contains(pm)); }