Пример #1
0
        public void UnitTestMeatList()
        {
            using (var context = new GroceryCartContext(DbOptionsFactory.DbContextOptions))
            {
                // 1. Create instance of fake repo using IProductRepository interface.
                var mockMeatRepo = new Mock <IMeatRepository>();

                // 2. Set up return data for ProductList() method.
                mockMeatRepo.Setup(mpr => mpr.MeatList())
                .Returns(new List <Meat> {
                    new Meat(), new Meat(), new Meat()
                });

                // 3. Define controller instance with mock repository instance.
                var controller = new MeatController(context, mockMeatRepo.Object);

                // 4. Make your test Assertions
                // Check if it returns a view
                var result = Assert.IsType <ViewResult>(controller.Index());

                // Check that the model returned to the view is 'List<Product>'.
                var model = Assert.IsType <List <Meat> >(result.Model);

                // Ensure count of objects is 3.
                int expected = 3;
                int actual   = model.Count;
                Assert.Equal(expected, actual);
            }
        }
Пример #2
0
 public void IndexViewHas5Meats()
 {
     using (var context = new GroceryCartContext(DbOptionsFactory.DbContextOptions))
     {
         var meatRepository = new MeatRepo(context);
         var controller     = new MeatController(context, meatRepository);
         int expected       = 5;
         var viewResult     = Assert.IsType <ViewResult>(controller.Index());
         var model          = Assert.IsType <List <Meat> >(viewResult.Model);
         int actual         = model.Count;
         Assert.Equal(expected, actual);
     }
 }
Пример #3
0
        // Funcion que se encarga de iniciar un nuevo juego
        private void newGame()
        {
            player.Stop();
            scienceMode = false;
            if (dificilToolStripMenuItem.Checked)
            {
                this.meat            = new MeatController(canvasSnake.Width, canvasSnake.Height, Color.Black, this.pixelLength, defaultMeatVal, 1);
                this.timerReduction  = 7;
                this.timer1.Interval = 140;
            }
            else if (mediaToolStripMenuItem.Checked)
            {
                this.meat            = new MeatController(canvasSnake.Width, canvasSnake.Height, Color.Black, this.pixelLength, defaultMeatVal, 1);
                this.timerReduction  = 6;
                this.timer1.Interval = 170;
            }
            else if (sCIENCEMODEToolStripMenuItem.Checked)
            {
                player.PlayLooping();
                this.meat            = new MeatController(canvasSnake.Width, canvasSnake.Height, Color.Black, pixelLength, defaultMeatVal, 1);
                this.timerReduction  = 8;
                this.timer1.Interval = 100;
                scienceMode          = true;
            }
            else
            {
                this.meat            = new MeatController(canvasSnake.Width, canvasSnake.Height, Color.Black, this.pixelLength, defaultMeatVal, 1);
                this.timerReduction  = 5;
                this.timer1.Interval = 200;
            }
            this.snake = new SnakeController(initialX, initialY, pixelLength, Color.Black);

            meat.generateMeat(snake.getSnakeBody());
            this.nextDirection = SnakeController.Directions.NO_KEY;
            this.score.Text    = "0";
            this.isGameOver    = false;
            canvasSnake.Invalidate();
        }
        public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            base.DoFunction(location, x, y, power, who);
            who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            if (this._animal != null && this._animal.type.Value == "Dinosaur" && DataLoader.ModConfig.DisableMeatFromDinosaur)
            {
                return;
            }

            if (this._animal != null && this._animal.age.Value >= (int)this._animal.ageWhenMature.Value)
            {
                (this._animal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(this._animal.myID.Value);
                this._animal.health.Value = -1;
                int numClouds   = this._animal.frontBackSourceRect.Width / 2;
                int cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;
                for (int i = 0; i < numClouds; i++)
                {
                    int   nonRedness = Game1.random.Next(0, 80);
                    Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);;

                    Game1.currentLocation.temporarySprites.Add
                    (
                        new TemporaryAnimatedSprite
                        (
                            cloudSprite
                            , this._animal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Width * 3)
                                                                  , Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Height * 3))
                            , cloudColor
                            , 8
                            , false,
                            Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                            , -1
                            , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                        )
                    {
                        scale  = Game1.random.Next(2, 5) * .25f,
                        alpha  = Game1.random.Next(2, 5) * .25f,
                        motion = new Vector2(0, (float)-Game1.random.NextDouble())
                    }
                    );
                }
                Color animalColor;
                float alfaFade;
                if (!DataLoader.ModConfig.Softmode)
                {
                    animalColor = Color.LightPink;
                    alfaFade    = .025f;
                }
                else
                {
                    animalColor = Color.White;
                    alfaFade    = .050f;
                }
                Game1.currentLocation.temporarySprites.Add
                (
                    new TemporaryAnimatedSprite
                    (
                        this._animal.Sprite.textureName.Value
                        , this._animal.Sprite.SourceRect
                        , this._animal.position
                        , this._animal.FacingDirection == Game1.left
                        , alfaFade
                        , animalColor
                    )
                {
                    scale = 4f
                }
                );
                if (!DataLoader.ModConfig.Softmode)
                {
                    Game1.playSound("killAnimal");
                }
                else
                {
                    Microsoft.Xna.Framework.Audio.Cue warptSound = Game1.soundBank.GetCue("wand");
                    warptSound.SetVariable("Pitch", 1800);
                    warptSound.Play();
                }

                MeatController.ThrowItem(MeatController.CreateMeat(this._animal), this._animal);
                who.gainExperience(0, 5);
                this._animal     = (FarmAnimal)null;
                this._tempAnimal = (FarmAnimal)null;
            }
        }
Пример #5
0
        public static bool DoFunction(Axe __instance, GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            if (!IsMeatCleaver(__instance))
            {
                return(true);
            }

            string meatCleaverId = __instance.modData[MeatCleaverKey];

            BaseToolDoFunction(__instance, location, x, y, power, who);

            if (!__instance.IsEfficient)
            {
                who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            }
            if (!Animals.ContainsKey(meatCleaverId))
            {
                return(false);
            }
            FarmAnimal farmAnimal = Animals[meatCleaverId];

            if (farmAnimal == null ||
                !MeatController.CanGetMeatFrom(Animals[meatCleaverId]) ||
                farmAnimal.age.Value < (int)farmAnimal.ageWhenMature.Value)
            {
                return(false);
            }

            (farmAnimal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(farmAnimal.myID.Value);
            farmAnimal.health.Value = -1;
            int numClouds   = farmAnimal.frontBackSourceRect.Width / 2;
            int cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;

            for (int i = 0; i < numClouds; i++)
            {
                int   nonRedness = Game1.random.Next(0, 80);
                Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);

                location.temporarySprites.Add(
                    new TemporaryAnimatedSprite
                    (
                        cloudSprite
                        , farmAnimal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Width * 3), Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Height * 3))
                        , cloudColor
                        , 8
                        , false,
                        Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                        , -1
                        , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                    )
                {
                    scale  = Game1.random.Next(2, 5) * .25f,
                    alpha  = Game1.random.Next(2, 5) * .25f,
                    motion = new Vector2(0, (float)-Game1.random.NextDouble())
                }
                    );
            }

            Color animalColor;
            float alfaFade;

            if (!DataLoader.ModConfig.Softmode)
            {
                animalColor = Color.LightPink;
                alfaFade    = .025f;
            }
            else
            {
                animalColor = Color.White;
                alfaFade    = .050f;
            }

            location.temporarySprites.Add(
                new TemporaryAnimatedSprite
                (
                    farmAnimal.Sprite.textureName.Value
                    , farmAnimal.Sprite.SourceRect
                    , farmAnimal.position
                    , farmAnimal.FacingDirection == Game1.left
                    , alfaFade
                    , animalColor
                )
            {
                scale = 4f
            }
                );
            if (!DataLoader.ModConfig.Softmode)
            {
                location.playSound("killAnimal");
            }
            else
            {
                ICue warptSound = Game1.soundBank.GetCue("wand");
                warptSound.SetVariable("Pitch", 1800);
                warptSound.Play();
            }

            MeatController.ThrowItem(MeatController.CreateMeat(farmAnimal), farmAnimal);
            who.gainExperience(0, 5);
            Animals[meatCleaverId]     = (FarmAnimal)null;
            TempAnimals[meatCleaverId] = (FarmAnimal)null;
            return(false);
        }