Ejemplo n.º 1
0
        private static Game DecreaseEaterHunger(Game game, DecreaseEaterHunger parameters)
        {
            var eaters       = game.eaters;
            var updatedEater = Eater.Update(EaterMsg.DecreaseHunger,
                                            eaters[parameters.eaterHash],
                                            new DecreaseHunger(parameters.value));

            eaters[parameters.eaterHash] = updatedEater;

            return(new Game(game.tick, game.food, eaters, game.chefs));
        }
Ejemplo n.º 2
0
        public void eat_then_hunger_decreases()
        {
            var eaters = new Dictionary <int, Eater>
            {
                { 1, new Eater(10) },
                { 2, new Eater(10) },
                { 3, new Eater(10) }
            };
            var parameters = new DecreaseEaterHunger(2, 1);

            game = new Game(game.tick, game.food, eaters, game.chefs);

            var result = Game.Update(GameMsg.DecreaseEaterHunger, game, parameters);

            Assert.AreEqual(10, result.eaters[1].hunger);
            Assert.AreEqual(9, result.eaters[2].hunger);
            Assert.AreEqual(10, result.eaters[3].hunger);
        }