Exemplo n.º 1
0
        public void TestAddAndRemoveFriends()
        {
            Assert.AreEqual(playerBehavior.Friends.Count, 0);
            playerBehavior.AddFriend("fufa");
            Assert.AreEqual(playerBehavior.Friends.Count, 1);
            playerBehavior.AddFriend("fufa");
            Assert.AreEqual(playerBehavior.Friends.Count, 1);
            playerBehavior.AddFriend("another");
            Assert.AreEqual(playerBehavior.Friends.Count, 2);

            playerBehavior.RemoveFriend("invalid");
            Assert.AreEqual(playerBehavior.Friends.Count, 2);
            playerBehavior.RemoveFriend("fufa");
            Assert.AreEqual(playerBehavior.Friends.Count, 1);
        }
Exemplo n.º 2
0
        private void AddFriend(IController sender, Thing targetFriend)
        {
            var output = new OutputBuilder();

            if (targetFriend == null)
            {
                output.AppendLine("Doesn't appear to be online at the moment.");
                sender.Write(output);
                return;
            }

            if (targetFriend == player)
            {
                output.AppendLine("You cannot add yourself as a friend.");
                sender.Write(output);
                return;
            }

            if (playerBehavior.Friends.Contains(targetFriend.Name))
            {
                output.AppendLine($"{player.Name} is already on your friends list.");
                sender.Write(output);
                return;
            }

            playerBehavior.AddFriend(player.Name);

            output.AppendLine($"You have added {targetFriend.Name} to your friends list.");
            sender.Write(output);
        }
Exemplo n.º 3
0
        private void AddFriend(IController sender, Thing targetFriend)
        {
            if (targetFriend == null)
            {
                sender.Write(string.Format("{0} doesn't appear to be online at the moment.", targetFriend.Name));
                return;
            }

            if (targetFriend == player)
            {
                sender.Write("You cannot add yourself as a friend.");
                return;
            }

            if (playerBehavior.Friends.Contains(targetFriend.Name))
            {
                sender.Write(string.Format("{0} is already on your friends list.", player.Name));
                return;
            }

            playerBehavior.AddFriend(player.Name);
            sender.Write(string.Format("You have added {0} to your friends list.", targetFriend.Name));
        }
Exemplo n.º 4
0
        private void AddFriend(Session session, Thing targetFriend)
        {
            if (targetFriend == null)
            {
                session.WriteLine("Doesn't appear to be online at the moment.");
                return;
            }

            if (targetFriend == player)
            {
                session.WriteLine("You cannot add yourself as a friend.");
                return;
            }

            if (playerBehavior.Friends.Contains(targetFriend.Name))
            {
                session.WriteLine($"{player.Name} is already on your friends list.");
                return;
            }

            playerBehavior.AddFriend(player.Name);
            session.WriteLine($"You have added {targetFriend.Name} to your friends list.");
        }