Exemple #1
0
        public ExecutionResult Extract(Dictionary <string, object> dict)
        {
            if (!dict.ContainsKey("resource"))
            {
                return(new ExecutionResult(false, new MessageCallback(Locale.Get("resources.no_resource", this.Language), ECharacter.Knight)));
            }

            ItemDescription r = (ItemDescription)dict["resource"];

            foreach (IDependency dep in r.ExtractionDependencies)
            {
                Tuple <bool, MessageCallback> res = dep.CheckKingdom(this);
                if (!res.Item1)
                {
                    return(new ExecutionResult(false, res.Item2));
                }
            }

            Human     h = dict.Get("human") as Human ?? FindBySkill(r.Skill);
            HumanTask t = new HumanTask(h)
            {
                Destination = r.Name,
                TaskType    = ETask.Extracting,
                Repeating   = true
            };

            t.CalculateTaskTime(h, r.Difficulty, r.Skill);
            foreach (IDependency dep in r.ExtractionDependencies)
            {
                t.Use(dep.Use(this));
            }

            if (!h.AddTask(t))
            {
                return(new ExecutionResult(false, new MessageCallback(
                                               Locale.Get(string.Format("problems.dont_work", h.GetName(Language)), Language),
                                               ECharacter.Knight
                                               )));
            }
            else
            {
                return(new ExecutionResult(new MessageCallback(Locale.Get("answers.yes", this.Language))));
            }
        }
Exemple #2
0
        public ExecutionResult Build(Dictionary <string, object> dict)
        {
            if (!dict.ContainsKey("building"))
            {
                return(new ExecutionResult(false, new MessageCallback(Locale.Get("buildings.no_building", this.Language), ECharacter.Knight)));
            }
            BuildingDescription b = (BuildingDescription)dict["building"];

            foreach (IDependency dep in b.Dependencies)
            {
                Tuple <bool, MessageCallback> res = dep.CheckKingdom(this);
                if (!res.Item1)
                {
                    return(new ExecutionResult(false, res.Item2));
                }
            }

            Human h = dict.Get("human") as Human ?? FindBySkill("building");

            HumanTask t = new HumanTask(h);

            t.Destination = b.Name;
            t.TaskType    = ETask.Building;

            foreach (IDependency dep in b.Dependencies)
            {
                t.Use(dep.Use(this));
            }

            t.CalculateTaskTime(h);

            if (!h.AddTask(t))
            {
                return(new ExecutionResult(false, new MessageCallback(
                                               Locale.Get(string.Format("problems.dont_work", h.GetName(Language)), Language),
                                               ECharacter.Knight
                                               )));
            }
            else
            {
                return(new ExecutionResult(new MessageCallback(Locale.Get("answers.yes", this.Language))));
            }
        }