Ejemplo n.º 1
0
        //Fazer Decompose

        public override void ApplyActionEffects(WorldModelDST worldModel)
        {
            worldModel.Cycle += this.Duration;

            //<OPTIMIZATION - Dict instead of chained if's>
            if (FoodIndex.ContainsKey(this.Target))
            {
                worldModel.RemoveFromPossessedItems(this.Target, 1);

                int[] foodValues = FoodIndex[this.Target];
                int   HungerVal  = foodValues[0];

                if (HungerVal > 0)
                {
                    worldModel.DecreaseHunger(foodValues[0]);
                }
                else if (HungerVal < 0)
                {
                    worldModel.IncreaseHunger(Math.Abs(foodValues[0]));
                }

                if (foodValues.Length > 1)
                {
                    int HPVal = foodValues[1];
                    if (HPVal > 0)
                    {
                        worldModel.IncreaseHP(foodValues[1]);
                    }
                    else if (HPVal < 0)
                    {
                        worldModel.DecreaseHP(Math.Abs(foodValues[1]));
                    }
                }

                if (!worldModel.Possesses(this.Target))
                {
                    worldModel.RemoveAction("Eat_" + this.Target);
                }
            }
        }