示例#1
0
        private void GenerateCommStrip(AssetService assetService)
        {
            Daniel daniel = (Daniel)assetService.GetAsset("Daniel");
            User   user   = (User)assetService.GetAsset("User");

            screen.CommStrip[0] = $"\t\t\tDaniel\tX : {daniel.X}\tY : {daniel.Y}";
            screen.CommStrip[1] = $"\t\t\tUser\tX : {user.X}\tY : {user.Y}";
            screen.CommStrip[2] = $"\t\t\tchosenAction : {user.ChosenAction}";
            screen.CommStrip[3] = string.Empty;
            screen.CommStrip[4] = $"Provision's Left: {user.Provisions}\t\t\t\t\tAquired Meat: {user.Meat}";
            screen.CommStrip[5] = string.Empty;
        }
        public void AddToAssetService_Should_AddDaniel()
        {
            //arr
            var daniel = new Daniel(0, 0);
            var mockAssetServiceObject = new Mock <AssetService>().Object;

            //act
            mockAssetServiceObject.AddToAssets(daniel);

            //ass
            mockAssetServiceObject.GetAsset(daniel.Key).Should().BeOfType(typeof(Daniel));
            mockAssetServiceObject.GetAsset(daniel.Key).Should().Be(daniel);
            mockAssetServiceObject.Should().NotBeNull();
            mockAssetServiceObject.Items.Should().HaveCount(1);
        }
        public void ScoreDaniel(Game game)
        {
            game.userService.User.Meat += 10;
            CheckIfEnoughCollected(game);
            game.userService.User.Provisions += 21;
            Daniel oldDaniel = (Daniel)game.assetService.GetAsset("Daniel");

            game.boardManager.RemoveSymbolFromPlayArea(oldDaniel.Key);
            game.assetService.RemoveFromAssets(oldDaniel);
            new TreeManager().GrowTreesAroundPlayer(game);
            Daniel newDaniel = new Daniel();

            game.assetService.AddToAssets(newDaniel);
            new DanielManager(newDaniel).PlaceDanielAtRandomPlaceOnTheBoard(game);
        }
        public void InsertSymbolIntoPlayArea_ShouldInsertDanielSymbol(int daniel_x, int daniel_y, int board_width, int board_height)
        {
            Daniel daniel           = new Daniel(daniel_x, daniel_y);
            var    mockBoardObject  = new Mock <Board>(board_width, board_height, 0).Object;
            var    mockScreenObject = new Mock <Screen>(mockBoardObject).Object;
            var    mockInitialisationHelperObject = new Mock <InitialisationHelper>().Object;

            mockInitialisationHelperObject.InitialisePlayArea(mockScreenObject);


            new BoardManager(mockBoardObject).InsertSymbolIntoPlayArea(daniel);

            mockBoardObject.PlayArea[daniel_y].Should().NotBeNullOrEmpty();
            mockBoardObject.PlayArea[daniel_y].Should().Contain(daniel.Symbol);
        }
        public void RemoveSymbolFromPlayArea_ShouldNotContainDanielSymbol()
        {
            var danielSymbol     = new Daniel().Symbol;
            var mockUserObject   = new Mock <User>(1, 1, 1, 1).Object;
            var mockBoardObject  = new Mock <Board>(20, 20, 1).Object;
            var mockScreenObject = new Mock <Screen>(mockBoardObject).Object;
            var mockInitialisationHelperObject = new Mock <InitialisationHelper>().Object;

            mockInitialisationHelperObject.InitialisePlayArea(mockScreenObject);
            var boardManager = new BoardManager(mockBoardObject);

            boardManager.InsertSymbolIntoPlayArea(mockUserObject);
            //act
            boardManager.RemoveSymbolFromPlayArea(mockUserObject.Key);
            //ass
            mockBoardObject.PlayArea.Should().NotContain(danielSymbol);
        }
示例#6
0
        public void RunDaniel(Game game)
        {
            Random random    = new Random();
            Daniel daniel    = game.assetService.GetAsset(AssetsNamesEnum.Daniel.ToString()) as Daniel;
            Daniel newDaniel = daniel;

            game.assetManager.DisposeAsset(daniel);
            User user = game.userService.User;

            (int higher, int lower)Y = newDaniel.Y > user.Y ? (newDaniel.Y, user.Y) : (user.Y, newDaniel.Y);
            (int higher, int lower)X = newDaniel.X > user.X ? (newDaniel.X, user.X) : (user.X, newDaniel.Y);
            int distance = Y.higher - Y.lower >= X.higher - X.lower ? (X.higher - X.lower) : (Y.higher - Y.lower);

            if (distance < 11)
            {
                bool placePossible = false;
                do
                {
                    int newX            = newDaniel.X;
                    int newY            = newDaniel.Y;
                    int randomDirection = random.Next(1, 10);
                    var key             = DirectionMenager.ConvertIntToConsoleKey(randomDirection);
                    (int x, int y)modificators = DirectionMenager.PassDirection(key);
                    newX += modificators.x;
                    newY += modificators.y;
                    if (newX >= 0 &&
                        newX < game.boardService.Board.Width &&
                        newY >= 0 &&
                        newY < game.boardService.Board.Height)
                    {
                        if (!game.assetService.IsAsset((newX, newY)))
                        {
                            placePossible = true;
                            newDaniel.X  += modificators.x;
                            newDaniel.Y  += modificators.y;
                        }
                    }
                } while (!placePossible);
            }
            game.assetManager.IntroduceAsset(newDaniel);
        }
示例#7
0
        public void PlaceDanielAtRandomPlaceOnTheBoard(Game game)
        {
            Random random = new Random();
            int    randomX;
            int    randomY;
            bool   placePossible = false;

            do
            {
                randomX = random.Next(0, game.boardService.Board.Width);
                randomY = random.Next(0, game.boardService.Board.Height);

                if (!game.assetService.IsAsset((randomX, randomY)))
                {
                    placePossible = true;
                }
            } while (!placePossible);
            game.assetManager.DisposeAsset(daniel);
            Daniel newDaniel = new Daniel(randomX, randomY);

            game.assetManager.IntroduceAsset(newDaniel);
        }
示例#8
0
 public DanielManager(Daniel daniel)
 {
     this.daniel = daniel;
 }