Exemplo n.º 1
0
        public override void ApplyActionEffects(WorldModelDST worldModel)
        {
            worldModel.Cycle += this.Duration;
            worldModel.IncreaseHunger(1);

            worldModel.Walter.Position = worldModel.GetNextPosition(this.Target, "world");

            if (this.Target == "tree")
            {
                worldModel.RemoveFromWorld("tree", 1);
                worldModel.AddToPossessedItems("log", 1);
                worldModel.AddToFuel("log", 1);

                ActionDST action;
                if (worldModel.Possesses("rocks", 12))
                {
                    action = new Build("firepit");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("cutgrass", 3))
                {
                    action = new Build("campfire");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "boulder")
            {
                worldModel.RemoveFromWorld("boulder", 1);
                worldModel.AddToPossessedItems("rocks", 2);
                worldModel.AddToPossessedItems("flint", 1);

                ActionDST action;
                if (worldModel.Possesses("log", 2) && worldModel.Possesses("rocks", 12))
                {
                    action = new Build("firepit");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("twigs", 1))
                {
                    action = new Build("axe");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("twigs", 2) && worldModel.Possesses("flint", 2))
                {
                    action = new Build("pickaxe");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "log")
            {
                worldModel.RemoveFromWorld("log", 1);
                worldModel.AddToPossessedItems("log", 1);
                worldModel.AddToFuel("log", 1);

                ActionDST action;
                if (worldModel.Possesses("log", 2) && worldModel.Possesses("cutgrass", 2))
                {
                    action = new Build("campfire");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("log", 2) && worldModel.Possesses("rocks", 12))
                {
                    action = new Build("firepit");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "twigs")
            {
                worldModel.RemoveFromWorld("twigs", 1);
                worldModel.AddToPossessedItems("twigs", 1);
                worldModel.AddToFuel("twigs", 1);

                ActionDST action;
                if (worldModel.Possesses("flint", 1))
                {
                    action = new Build("axe");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("flint", 2) && worldModel.Possesses("twigs", 2))
                {
                    action = new Build("pickaxe");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "sapling")
            {
                worldModel.RemoveFromWorld("sapling", 1);
                worldModel.AddToPossessedItems("twigs", 1);
                worldModel.AddToFuel("twigs", 1);

                ActionDST action;
                if (worldModel.Possesses("flint", 1))
                {
                    action = new Build("axe");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("flint", 2) && worldModel.Possesses("twigs", 2))
                {
                    action = new Build("pickaxe");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "flint")
            {
                worldModel.RemoveFromWorld("flint", 1);
                worldModel.AddToPossessedItems("flint", 1);

                ActionDST action;
                if (worldModel.Possesses("twigs", 1))
                {
                    action = new Build("axe");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("twigs", 2) && worldModel.Possesses("flint", 2))
                {
                    action = new Build("pickaxe");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "cutgrass")
            {
                worldModel.RemoveFromWorld("cutgrass", 1);
                worldModel.AddToPossessedItems("cutgrass", 1);
                worldModel.AddToFuel("cutgrass", 1);

                ActionDST action;
                if (worldModel.Possesses("cutgrass", 3) && worldModel.Possesses("log", 2))
                {
                    action = new Build("campfire");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("cutgrass", 2) && worldModel.Possesses("twigs", 2))
                {
                    action = new Build("torch");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "grass")
            {
                worldModel.RemoveFromWorld("grass", 1);
                worldModel.AddToPossessedItems("cutgrass", 1);
                worldModel.AddToFuel("cutgrass", 1);

                ActionDST action;
                if (worldModel.Possesses("cutgrass", 3) && worldModel.Possesses("log", 2))
                {
                    action = new Build("campfire");
                    worldModel.AddAction(action);
                }
                if (worldModel.Possesses("cutgrass", 2) && worldModel.Possesses("twigs", 2))
                {
                    action = new Build("torch");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "rocks")
            {
                worldModel.RemoveFromWorld("rocks", 1);
                worldModel.AddToPossessedItems("rocks", 1);

                ActionDST action;
                if (worldModel.Possesses("log", 2) && worldModel.Possesses("rocks", 12))
                {
                    action = new Build("firepit");
                    worldModel.AddAction(action);
                }
            }
            else if (this.Target == "berrybush")
            {
                worldModel.RemoveFromWorld("berrybush", 1);
                worldModel.AddToPossessedItems("berries", 2);

                ActionDST action = new Eat("berries");
                worldModel.AddAction(action);
            }
            else if (this.Target == "carrot" || this.Target == "carrot_planted")
            {
                worldModel.RemoveFromWorld("carrot", 1);
                worldModel.AddToPossessedItems("carrot", 1);

                ActionDST action = new Eat("carrot");
                worldModel.AddAction(action);
            }
            else if (this.Target == "berries")
            {
                worldModel.RemoveFromWorld("berries", 1);
                worldModel.AddToPossessedItems("berries", 1);

                ActionDST action = new Eat("berries");
                worldModel.AddAction(action);
            }
        }