Exemple #1
0
 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);
         }
     }
 }
Exemple #2
0
        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());
        }
Exemple #3
0
 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);
     });
 }
Exemple #4
0
        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());
        }
Exemple #5
0
 public List <SpectatingUser> postMessage(SpectatingUser user, string message)
 {
     //chat.SendMessage(message);
     if (players.Contains(user))
     {
         return((List <SpectatingUser>)players.Union(spectators));
     }
     else
     {
         return(spectators);
     }
 }
Exemple #6
0
        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;
        }
Exemple #7
0
 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);
     }
 }
Exemple #8
0
        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());
        }
Exemple #9
0
 internal void Message(SpectatingUser spectaitngUser, string v)
 {
     throw new NotImplementedException();
 }