Esempio n. 1
0
        public void Should_return_room_description()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Title       = "Room 1",
                Description =
                    "room descriptions",

                Exits = new ExitDirections()
                {
                    North = new Exit()
                    {
                        Name = "North"
                    }
                }
            };

            _player = new Player();
            _player.Config.VerboseExits = false;
            _player.ConnectionId        = "1";

            new RoomActions(_writer.Object, _time.Object, _cache.Object).Look("", _room, _player);

            _writer.Verify(w => w.WriteLine(It.IsAny <string>(), "1"), Times.Once);
        }
Esempio n. 2
0
        public void Should_not_move_if_no_moves()
        {
            var player2 = new Player();

            player2.ConnectionId = "2";

            _player = new Player();
            _player.ConnectionId = "1";
            _player.Name         = "Bob";
            _player.Stats        = new Stats()
            {
                MovePoints = 0
            };

            _room = new Room()
            {
                AreaId      = 1,
                Title       = "Room 1",
                Description = "room 1",
                Exits       = new ExitDirections()
                {
                    North = new Exit()
                    {
                        AreaId = 2,
                        Name   = "North"
                    }
                },
                Players = new List <Player>()
                {
                    _player,

                    player2
                }
            };

            var room2 = new Room()
            {
                AreaId      = 2,
                Title       = "Room 2",
                Description = "room 2",
                Exits       = new ExitDirections()
                {
                    South = new Exit()
                    {
                        AreaId = 1,
                        Name   = "South"
                    }
                },
                Players = new List <Player>()
            };

            //  _cache.Setup(x => x.GetRoom(2)).Returns(room2);
            _cache.AddRoom(2, room2);
            // _cache.AddRoom(1, _room);

            new GameLogic.Commands.Movement.Movement(_writer.Object, _cache, _roomActions.Object, _clientui.Object, _dice.Object).Move(_room, _player, "North");


            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "<p>You are too exhausted to move.</p>"), "1"), Times.Once);
        }
Esempio n. 3
0
        public void Should_sit_down()
        {
            var player2 = new Player();

            player2.ConnectionId = "2";
            player2.Id           = new Guid();

            _player              = new Player();
            _player.Id           = Guid.NewGuid();
            _player.ConnectionId = "1";
            _player.Name         = "Bob";
            _player.Stats        = new Stats()
            {
                MovePoints = 110
            };

            _room = new Room()
            {
                AreaId      = 1,
                Id          = 1,
                Title       = "Room 1",
                Description = "room 1",
                Coords      = new Coordinates
                {
                    X = 0,
                    Y = 0,
                    Z = 0
                },
                Exits = new ExitDirections()
                {
                    North = new Exit()
                    {
                        AreaId = 1,
                        RoomId = 2,
                        Name   = "North",
                        Coords = new Coordinates
                        {
                            X = 0,
                            Y = 1,
                            Z = 0
                        }
                    }
                },
                Players = new List <Player>()
                {
                    _player,

                    player2
                }
            };



            new GameLogic.Commands.Movement.Movement(_writer.Object, _cache, _roomActions.Object, _clientui.Object, _dice.Object, _combat.Object, _mobScript.Object).Sit(_player, _room, "sit");
            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "<p>You sit down.</p>"), "1"), Times.Once);
            Assert.Equal(CharacterStatus.Status.Sitting, _player.Status);
        }
Esempio n. 4
0
        public void Should_return_view_of_next_room_from_portal()
        {
            _player      = new Player();
            _player.Name = "Liam";
            _player.Config.VerboseExits = false;
            _player.ConnectionId        = "1";


            var item = new GameLogic.Item.Item()
            {
                Name     = "A portal",
                ItemType = GameLogic.Item.Item.ItemTypes.Portal,
                Portal   = new Portal()
                {
                    Destination = "0000"
                }
            };
            var currentRoom = new GameLogic.World.Room.Room()
            {
                Items = new ItemList()
                {
                    item
                },
                AreaId = 1,
                Coords =
                {
                    X = 1,
                    Y = 0,
                    Z = 0
                },
                Players = new List <Player>()
                {
                    _player
                }
            };



            _room = new GameLogic.World.Room.Room()
            {
                Description = "Room description",
                AreaId      = 0,
                Coords      =
                {
                    X = 0,
                    Y = 0,
                    Z = 0
                }
            };

            _cache.Setup(x => x.GetRoom("0000")).Returns(_room);
            new RoomActions(_writer.Object, _time.Object, _cache.Object).LookInPortal(item, currentRoom, _player);

            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s.Contains("Room description")), "1"), Times.Once());
        }
Esempio n. 5
0
        public void Should_return_all_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    NorthWest = new Exit()
                    {
                        Name = " North West",
                        Door = false,
                    },

                    North = new Exit()
                    {
                        Name = " North",
                        Door = false,
                    },
                    NorthEast = new Exit()
                    {
                        Name = " North East",
                        Door = false,
                    },
                    East = new Exit()
                    {
                        Name = " East",
                        Door = false,
                    },
                    SouthEast = new Exit()
                    {
                        Name = " South East",
                        Door = false,
                    },
                    South = new Exit()
                    {
                        Name = " South",
                        Door = false,
                    },
                    SouthWest = new Exit()
                    {
                        Name = " South West",
                        Door = false,
                    },
                    West = new Exit()
                    {
                        Name = " West",
                        Door = false,
                    },
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object).FindValidExits(_room);

            Assert.Equal(" North West,  North,  North East,  East,  South East,  South,  South West,  West", exits);
        }
Esempio n. 6
0
        public void Should_return_none_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                }
            };

            var exits = new RoomActions(_writer.Object).FindValidExits(_room);

            Assert.Equal("None", exits);
        }
        public void Should_return_none_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object, _cache.Object, _dice.Object, _gain.Object, _formulas.Object).FindValidExits(_room, false);

            Assert.Equal("None", exits);
        }
Esempio n. 8
0
        public CommandsTests()
        {
            _movement       = new Mock <IMovement>();
            _roomActions    = new Mock <IRoomActions>();
            _debug          = new Mock <IDebug>();
            _skill          = new Mock <ISkills>();
            _spell          = new Mock <ISpells>();
            _object         = new Mock <IObject>();
            _inventory      = new Mock <IInventory>();
            _communication  = new Mock <Icommunication>();
            _equipment      = new Mock <IEquip>();
            _score          = new Mock <IScore>();
            _combat         = new Mock <ICombat>();
            _commandHandler = new Mock <ICommandHandler>();
            _cache          = new Mock <ICache>();
            _socials        = new Mock <ISocials>();
            _core           = new Mock <ICore>();
            _mobFunctions   = new Mock <IMobFunctions>();
            _mobScripts     = new Mock <IMobScripts>();
            _player         = new Player();
            _help           = new Mock <IHelp>();
            _crafting       = new Mock <ICrafting>();
            _cooking        = new Mock <ICooking>();
            _utilSkills     = new Mock <IUtilSkills>();
            _passiveSkills  = new Mock <IPassiveSkills>();
            _healer         = new Mock <IHealer>();

            _player.ConnectionId = "1";
            _player.Name         = "Bob";

            _room = new Room()
            {
                AreaId      = 1,
                Title       = "Room 1",
                Description = "room 1",
                Exits       = new ExitDirections()
                {
                    North = new Exit()
                    {
                        AreaId = 2,
                        Name   = "North"
                    }
                },
                Players = new List <Player>()
                {
                    _player
                }
            };

            _commands = new GameLogic.Commands.Commands(_movement.Object, _roomActions.Object, _debug.Object, _skill.Object, _spell.Object, _object.Object, _inventory.Object, _communication.Object, _equipment.Object, _score.Object, _combat.Object, _cache.Object, _socials.Object, _commandHandler.Object, _core.Object, _mobFunctions.Object, _help.Object, _mobScripts.Object, _crafting.Object, _cooking.Object, _utilSkills.Object, _passiveSkills.Object, _healer.Object);
        }
Esempio n. 9
0
        public void Should_return_east_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    East = new Exit()
                    {
                        Name = "East"
                    }
                }
            };

            var exits = new RoomActions(_writer.Object).FindValidExits(_room);

            Assert.Equal("East", exits);
        }
Esempio n. 10
0
        public void Should_return_custom_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    NorthWest = new Exit()
                    {
                        Name = "A hole in the wall"
                    }
                }
            };

            var exits = new RoomActions(_writer.Object).FindValidExits(_room);

            Assert.Equal("A hole in the wall", exits);
        }
Esempio n. 11
0
        public void Should_return_northEast_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    NorthEast = new Exit()
                    {
                        Name = "North East",
                        Door = false,
                    }
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object).FindValidExits(_room);

            Assert.Equal("North East", exits);
        }
Esempio n. 12
0
        public void Should_return_custom_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    NorthWest = new Exit()
                    {
                        Name = "A hole in the wall",
                        Door = false,
                    }
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object, _cache.Object, _dice.Object, _gain.Object, _formulas.Object).FindValidExits(_room, false);

            Assert.Equal("A hole in the wall", exits);
        }
Esempio n. 13
0
        public void Should_return_south_west_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    SouthWest = new Exit()
                    {
                        Name = "South West",
                        Door = false,
                    }
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object, _cache.Object).FindValidExits(_room, false);

            Assert.Equal("South West", exits);
        }
Esempio n. 14
0
        public void Should_return_east_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    East = new Exit()
                    {
                        Name   = "East",
                        Door   = false,
                        Coords = new Coordinates()
                    }
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object, _cache.Object, _dice.Object, _gain.Object, _formulas.Object).FindValidExits(_room, false);

            Assert.Equal("East", exits);
        }
Esempio n. 15
0
        public void Should_return_all_exits()
        {
            _room = new GameLogic.World.Room.Room()
            {
                Exits = new ExitDirections()
                {
                    NorthWest = new Exit()
                    {
                        Name   = " North West",
                        Door   = false,
                        Coords = new Coordinates()
                    },

                    North = new Exit()
                    {
                        Name   = " North",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    NorthEast = new Exit()
                    {
                        Name   = " North East",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    East = new Exit()
                    {
                        Name   = " East",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    SouthEast = new Exit()
                    {
                        Name   = " South East",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    South = new Exit()
                    {
                        Name   = " South",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    SouthWest = new Exit()
                    {
                        Name   = " South West",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                    West = new Exit()
                    {
                        Name   = " West",
                        Door   = false,
                        Coords = new Coordinates()
                    },
                }
            };

            var exits = new RoomActions(_writer.Object, _time.Object, _cache.Object, _dice.Object, _gain.Object, _formulas.Object).FindValidExits(_room, false);

            Assert.Equal(" North,  East,  South,  West,  North East,  South East,  South West,  North West", exits);
        }
Esempio n. 16
0
        public void Should_move_characters_position()
        {
            var player2 = new Player();

            player2.ConnectionId = "2";
            player2.Name         = "Jane";

            _player = new Player();
            _player.ConnectionId = "1";
            _player.Name         = "Bob";
            _player.Stats        = new Stats()
            {
                MovePoints = 110
            };
            _player.Attributes = new Attributes();

            _player.Attributes.Attribute[EffectLocation.Moves] = 100;

            _room = new Room()
            {
                AreaId      = 1,
                Id          = 1,
                Title       = "Room 1",
                Description = "room 1",
                Coords      = new Coordinates {
                    X = 0,
                    Y = 0,
                    Z = 0
                },
                Exits = new ExitDirections()
                {
                    North = new Exit()
                    {
                        AreaId = 1,
                        RoomId = 2,
                        Name   = "North",
                        Coords = new Coordinates
                        {
                            X = 0,
                            Y = 1,
                            Z = 0
                        },
                        Door   = false,
                        Closed = false
                    }
                },
                Players = new List <Player>()
                {
                    _player,

                    player2
                }
            };

            var room2 = new Room()
            {
                AreaId      = 1,
                Id          = 2,
                Title       = "Room 2",
                Description = "room 2",
                Coords      = new Coordinates {
                    X = 0,
                    Y = 1,
                    Z = 0
                },
                Exits = new ExitDirections()
                {
                    South = new Exit()
                    {
                        AreaId = 1,
                        Name   = "South",
                        Door   = false,
                        Closed = false,
                        Coords =
                            new Coordinates {
                            X = 0,
                            Y = 0,
                            Z = 0
                        }
                    }
                },
                Players = new List <Player>()
            };

            var newRoomCoords = new Coordinates
            {
                X = 0,
                Y = 1,
                Z = 0
            };


            _cache.AddRoom($"{room2.AreaId}{room2.Coords.X}{room2.Coords.Y}{room2.Coords.Z}", room2);
            _cache.AddRoom($"{_room.AreaId}{_room.Coords.X}{_room.Coords.Y}{_room.Coords.Z}", _room);


            new GameLogic.Commands.Movement.Movement(_writer.Object, _cache, _roomActions.Object, _clientui.Object, _dice.Object, _combat.Object, _mobScript.Object).Move(_room, _player, "North");

            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s.Contains("Bob walks north.")), "1"), Times.Never);
            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "Bob walks north."), "2"), Times.Once);
            Assert.Equal("1010", _player.RoomId);
        }
Esempio n. 17
0
        public void Should_return_error_if_room_not_found()
        {
            var player2 = new Player();

            player2.ConnectionId = "2";

            _player = new Player();
            _player.ConnectionId = "1";
            _player.Name         = "Bob";
            _player.Stats        = new Stats()
            {
                MovePoints = 110
            };
            _player.Attributes = new Attributes();

            _player.Attributes.Attribute[EffectLocation.Moves] = 100;
            _room = new Room()
            {
                AreaId      = 1,
                Id          = 1,
                Title       = "Room 1",
                Description = "room 1",
                Coords      = new Coordinates
                {
                    X = 0,
                    Y = 0,
                    Z = 0
                },
                Exits = new ExitDirections()
                {
                    North = new Exit()
                    {
                        AreaId = 1,
                        RoomId = 2,
                        Name   = "North",
                        Coords = new Coordinates
                        {
                            X = 0,
                            Y = 1,
                            Z = 0
                        }
                    }
                },
                Players = new List <Player>()
                {
                    _player,

                    player2
                }
            };

            var room2 = new Room()
            {
                AreaId      = 1,
                Id          = 2,
                Title       = "Room 2",
                Description = "room 2",
                Coords      = new Coordinates
                {
                    X = 0,
                    Y = 2,
                    Z = 0
                },
                Exits = new ExitDirections()
                {
                    South = new Exit()
                    {
                        AreaId = 1,
                        Name   = "South",
                        Coords =
                            new Coordinates
                        {
                            X = 0,
                            Y = 0,
                            Z = 0
                        }
                    }
                },
                Players = new List <Player>()
            };


            _cache.AddRoom($"1020", room2);


            new GameLogic.Commands.Movement.Movement(_writer.Object, _cache, _roomActions.Object, _clientui.Object, _dice.Object, _combat.Object, _mobScript.Object).Move(_room, _player, "North");


            _writer.Verify(w => w.WriteLine(It.Is <string>(s => s == "<p>A mysterious force prevents you from going that way.</p>"), "1"), Times.Once);
        }