Beispiel #1
0
        public void Use(Actor actor, Inventory inv)
        {
            const int FOOD_EXPIRED_VOMIT_CHANCE = 25;

            actor.SpendActionPoints();
            actor.LivingEat(actor.CurrentNutritionOf(this));
            inv.Consume(this); // does the "is in inventory check"
            if (Model == Gameplay.GameItems.CANNED_FOOD)
            {
                var emptyCan = new ItemTrap(Gameplay.GameItems.EMPTY_CAN); // alpha10 { IsActivated = true };
                emptyCan.Activate(actor);                                  // alpha10
                actor.Location.Drop(emptyCan);
            }
            bool player = RogueGame.Game.ForceVisibleToPlayer(actor);

            if (player)
            {
                RogueGame.AddMessage(RogueGame.MakeMessage(actor, RogueGame.VERB_EAT.Conjugate(actor), this));
            }
            if (!IsSpoiledAt(actor.Location.Map.LocalTime.TurnCounter) || !Rules.Get.RollChance(FOOD_EXPIRED_VOMIT_CHANCE))
            {
                return;
            }
            actor.Vomit();
            if (player)
            {
                RogueGame.AddMessage(RogueGame.MakeMessage(actor, string.Format("{0} from eating spoiled food!", RogueGame.VERB_VOMIT.Conjugate(actor))));
            }
        }
        /// <summary>
        /// A new trap of the same model, un-activated, no owner, un-triggered.
        /// </summary>
        /// <returns></returns>
        public ItemTrap Clone()
        {
            ItemTrap c = new ItemTrap(TrapModel);

            return(c);
        }