Ejemplo n.º 1
0
        public void show_error_if_char_not_found_to_give()
        {
            var apple = new GameLogic.Item.Item();

            apple.Name        = "apple";
            apple.Description = new Description()
            {
                Room = "apple"
            };

            var room = new Room();

            var player = new Player();

            player.ConnectionId = "1";
            player.Name         = "Gary";
            player.Inventory    = new ItemList();
            player.Inventory.Add(apple);

            var mob = new Player();

            mob.ConnectionId = "mob";
            mob.Name         = "Mob";
            mob.Inventory    = new ItemList();

            room.Players.Add(player);
            room.Players.Add(mob);

            var objects = new GameLogic.Commands.Objects.Object(_IWriteToClient.Object, _IUpdateUI.Object, _IMobScripts.Object);

            objects.Give("apple", "max", room, player, "");

            _IWriteToClient.Verify(w => w.WriteLine(It.Is <string>(s => s.Contains("They aren't here.")), "1"), Times.Once());
        }
Ejemplo n.º 2
0
        public void give_item_to_mob()
        {
            var apple = new GameLogic.Item.Item();

            apple.Name        = "apple";
            apple.Description = new Description()
            {
                Room = "apple"
            };

            var room = new Room();

            var player = new Player();

            player.ConnectionId = "1";
            player.Name         = "Gary";
            player.Inventory    = new ItemList();
            player.Inventory.Add(apple);

            var mob = new Player();

            mob.ConnectionId = "mob";
            mob.Name         = "Mob";
            mob.Inventory    = new ItemList();

            room.Players.Add(player);
            room.Players.Add(mob);

            var objects = new GameLogic.Commands.Objects.Object(_IWriteToClient.Object, _IUpdateUI.Object, _IMobScripts.Object);

            objects.Give("apple", "mob", room, player, "");


            Assert.True(player.Inventory.FirstOrDefault(x => x.Name == "apple") == null);
            Assert.True(mob.Inventory.FirstOrDefault(x => x.Name == "apple") != null);
        }
Ejemplo n.º 3
0
        public void Give_gold_to_player()
        {
            var room = new Room();

            var player = new Player();

            player.ConnectionId = "1";
            player.Name         = "Gary";
            player.Inventory    = new ItemList();
            player.Money        = new GameLogic.Character.Model.Money()
            {
                Gold   = 500,
                Silver = 0
            };

            var playerB = new Player();

            playerB.ConnectionId = "2";
            playerB.Name         = "Barry";
            playerB.Inventory    = new ItemList();
            playerB.Money        = new GameLogic.Character.Model.Money()
            {
                Gold   = 0,
                Silver = 0
            };

            room.Players.Add(playerB);
            room.Players.Add(player);

            var objects = new GameLogic.Commands.Objects.Object(_IWriteToClient.Object, _IUpdateUI.Object, _IMobScripts.Object);

            objects.Give("500", "gold", room, player, "give 500 gold barry");

            Assert.True(player.Money.Gold.Equals(0));
            Assert.True(playerB.Money.Gold.Equals(500));
        }