public List <SpectatingUser> postMessage(SpectatingUser from, SpectatingUser to, string message) { //chat.SendMessage(message); if (players.Contains(from)) { return new List <SpectatingUser> { from, to } } ; else { if (spectators.Contains(to)) { return new List <SpectatingUser> { from, to } } ; else { return(null); } } }
public void AddSpectatorToGame() { Game g = new Game(new GamePreferences()); UserProfile Niv = new UserProfile("Niv", "123"); SpectatingUser nivPlayer = new SpectatingUser(Niv.Username, g); Assert.IsEmpty(g.GetSpectators()); g.addSpectator(nivPlayer); Assert.Contains(nivPlayer, g.GetSpectators()); }
public void AddSpectatorsToGameThatDoesntAllowSpecators() { Assert.Throws(typeof(InvalidOperationException), delegate() { Game g = new Game(new GamePreferences(8, 2, 5, 10, 1, 2, 3, false)); UserProfile Niv = new UserProfile("Niv", "123"); SpectatingUser N = new SpectatingUser(Niv.Username, g); Assert.False(g.GetGamePref().AllowSpec()); g.addSpectator(N); }); }
public void RemoveSpectatorFromGame() { Game g = new Game(new GamePreferences()); UserProfile Niv = new UserProfile("Niv", "123"); SpectatingUser nivPlayer = new SpectatingUser(Niv.Username, g); g.addSpectator(nivPlayer); Assert.IsNotEmpty(g.GetSpectators()); g.removeSpectator(nivPlayer); Assert.IsEmpty(g.GetSpectators()); }
public List <SpectatingUser> postMessage(SpectatingUser user, string message) { //chat.SendMessage(message); if (players.Contains(user)) { return((List <SpectatingUser>)players.Union(spectators)); } else { return(spectators); } }
public void removeSpectator(SpectatingUser spec) { if (spectators.Count == 0) { throw new InvalidOperationException("No spectators to remove"); } if (!spectators.Contains(spec)) { throw new InvalidOperationException("player.getName()" + " is not spectating in this game"); } spectators.Remove(spec); spec = null; }
public void addSpectator(SpectatingUser spec) { if (!gamePref.AllowSpec()) { throw new InvalidOperationException("Spectating is not allowed in this game"); } if (this.gamePref.GetStatus().Equals("Active")) { specWaitingList.Add(spec); } else { spectators.Add(spec); } }
public void ChatTest() { Game g = new Game(new GamePreferences()); UserProfile Niv = new UserProfile("Niv", "123"); SpectatingUser nivPlayer = new SpectatingUser(Niv.Username, g); UserProfile Omer = new UserProfile("Omer", "123"); SpectatingUser omerPlayer = new SpectatingUser(Omer.Username, g); g.addSpectator(nivPlayer); g.addSpectator(omerPlayer); nivPlayer.SendMessage("hello world!"); Assert.AreEqual("hello world!", omerPlayer.GetMessages().First()); }
internal void Message(SpectatingUser spectaitngUser, string v) { throw new NotImplementedException(); }