Example #1
0
        public bool SetObjectValue_User(Doer doer, string key, object objectValue, bool isAdd)
        {
            bool isBreak = false;

            if (doer is User user)
            {
                if (objectValue is string value)
                {
                    if (this.SetObjectValue_User_AddAttrEquip(user, key, value, isAdd))
                    {
                        return(true);
                    }

                    if (this.SetObjectValue_User_Missions(user, key, value, isAdd))
                    {
                        return(true);
                    }

                    if (this.SetObjectValue_User_Items(user, key, value, isAdd))
                    {
                        return(true);
                    }
                }
            }

            return(isBreak);
        }
Example #2
0
        public void SetObjectTmpValue(Doer doer, string key, object objectValue, bool isAdd)
        {
            if (StringConst.String_nil.Equals(objectValue))
            {
                doer.RemoveTmp <object>(key);
                return;
            }

            if (!isAdd)
            {
                doer.SetTmp(key, objectValue);
                return;
            }

            // add
            if (objectValue is int i)
            {
                doer.AddTmp(key, i);
                return;
            }

            if (objectValue is float f)
            {
                doer.AddTmp(key, f);
                return;
            }

            if (objectValue is string s)
            {
                doer.AddTmp(key, s);
                return;
            }
        }
Example #3
0
 public JobHostTest()
 {
     _shutdownWatcherDouble = new WebJobShutdownWatcherDouble();
     _shutdownHandleDouble  = new ShutdownHandleDouble();
     _host = new JobHost(_shutdownWatcherDouble, new ShutdownHandleDoubleFactory(_shutdownHandleDouble), default);
     _doer = new Doer();
 }
Example #4
0
        public async Task <IActionResult> Go(string login, string pwd, Themes theme)
        {
            var runner = new Doer();
            var repo   = await runner.CreateAndRewind(login, pwd);

            ViewData["Message"] = "ТЕПЕРЬ СЫН МАМИНОЙ ПОДРУГИ - ЭТО ТЫ!!!";

            return(View("Index"));
        }
Example #5
0
        public override bool Equals(object other)
        {
            if (other == null || other.GetType() != typeof(Doer))
            {
                return(false);
            }

            Doer otherDoer = (Doer)other;

            return(this.Id.Equals(otherDoer.Id) && this.Preferred == otherDoer.Preferred);
        }
Example #6
0
        static void Main(string[] args)
        {
            var doer = new Doer();

            UserInterface userInterface = new UserInterface();
            Logger        logger        = new Logger();

            doer.AfterDoSomethingWith += userInterface.AfterDoSomethingWith;
            doer.AfterDoSomethingWith += logger.AfterDoSomethingWith;
            doer.AfterDoMore          += logger.AfterDoMore;


            //doer.AfterDoSomethingWith =
            //    new MulticastNotifier<string>(

            //        new DesignPatterns.Observer.IObserver<string>[] {

            //            userInterface.AfterDoSomethingWith,
            //            logger.AfterDoSomethingWith

            //        });
            //doer.AfterDoMore =
            //    new MulticastNotifier<Tuple<string, string>>(
            //    new DesignPatterns.Observer.IObserver<Tuple<string, string>>[]
            //        {
            //            logger.AfterDoMore

            //        });



            doer.DoSomethingWith("my data");
            doer.DoMore("tail");

            // composite pattern
            //var drawing = new GraphicObject { Name = "My Drawing" };
            //drawing.Children.Add(new Circle { Color = "Red" });
            //drawing.Children.Add(new Square { Color = "Yelllow" });

            //var group = new GraphicObject();
            //drawing.Children.Add(new Circle { Color = "Blue" });
            //drawing.Children.Add(new Square { Color = "Blue" });
            //drawing.Children.Add(group);
            //Console.WriteLine(drawing);



            Console.ReadLine();
        }
Example #7
0
        static void Main(string[] args)
        {
            // Create doer object
            Doer <int> doer = new Doer <int>();

            // Populate the doer with rules
            doer
            .On(i => i % 3 == 0 && i % 5 == 0, i => Console.WriteLine("SneakyBox"))
            .On(i => i % 3 == 0, i => Console.WriteLine("Sneaky"))
            .On(i => i % 5 == 0, i => Console.WriteLine("Box"))
            .OnElse(i => Console.WriteLine(i));

            // Have some data set
            IEnumerable <int> dataSet = Enumerable.Range(1, 100);

            // Run the doer
            doer.Do(dataSet);
        }
Example #8
0
        public string GetDoerValue(Doer doer, string key, string typeString)
        {
            string result;

            if (GetDoerValue_User(doer, key, typeString, out result))
            {
                return(result);
            }
            if (GetDoerValue_Mission(doer, key, typeString, out result))
            {
                return(result);
            }
            if (GetDoerValue_Doer(doer, key, typeString, out result))
            {
                return(result);
            }
            return(DoerAttrParserUtil.ConvertValue(doer.Get <object>(key), typeString).ToString());
        }
Example #9
0
        public bool GetDoerValue_User(Doer doer, string key, string typeString, out string result)
        {
            bool isBreak = false;

            result = null;
            if (doer is User user)
            {
                if (GetDoerValue_User_Missions(user, key, typeString, out result))
                {
                    return(true);
                }
                if (GetDoerValue_User_Items(user, key, typeString, out result))
                {
                    return(true);
                }
            }

            return(isBreak);
        }
        public bool SetObjectValue_Doer(Doer doer, string key, object objectValue, bool isAdd)
        {
            bool isBreak = false;

            if (doer is Doer)
            {
                if (key.StartsWith(StringConst.String_env_dot) || key.StartsWith(StringConst.String_envt_dot))                 //获得属性所在的环境
                {
                    Doer env = doer.GetEnv();
                    if (env != null)
                    {
                        key = key.Substring(StringConst.String_env.Length);
                        DoerAttrSetter attrAttrSetter = new DoerAttrSetter(desc);
                        attrAttrSetter.SetU(env);
                        attrAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }

                    return(true);
                }

                if (key.StartsWith(StringConst.String_ownerDot) ||
                    key.StartsWith(StringConst.String_ownertDot))                     //获得属性所在的环境
                {
                    Doer owner = doer.GetOwner();
                    if (owner != null)
                    {
                        key = key.Substring(StringConst.String_owner.Length);
                        DoerAttrSetter attrAttrSetter = new DoerAttrSetter(desc);
                        attrAttrSetter.SetU(owner);
                        attrAttrSetter.SetObject(StringConst.String_u + key, objectValue, isAdd);
                    }

                    return(true);
                }
            }

            return(isBreak);
        }
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += Doer.ToLink(link, pov, this);
            if (InteractionString == "")
            {
                eventString += " bit ";
                eventString += Target.ToLink(link, pov, this);
                eventString += !string.IsNullOrWhiteSpace(InteractionAction) ? InteractionAction : ", passing on the " + Interaction + " ";
            }
            else
            {
                eventString += !string.IsNullOrWhiteSpace(InteractionAction) ? InteractionAction : " put " + Interaction + " on ";
                eventString += Target.ToLink(link, pov, this);
                eventString += !string.IsNullOrWhiteSpace(InteractionString) ? InteractionString : "";
            }
            eventString += " in ";
            eventString += Site != null?Site.ToLink(link, pov, this) : "UNKNOWN SITE";

            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
        public HfDoesInteraction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "doer_hfid": Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "target_hfid": Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "interaction": Interaction = property.Value; break;

                case "doer": if (Doer == null)
                    {
                        Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "target": if (Target == null)
                    {
                        Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "interaction_action": InteractionAction = property.Value.Replace("[IS_HIST_STRING_1:", "").Replace("[IS_HIST_STRING_2:", "").Replace("]", ""); break;

                case "interaction_string": InteractionString = property.Value.Replace("[IS_HIST_STRING_2:", "").Replace("[I_TARGET:A:CREATURE", "").Replace("]", ""); break;

                case "source": Source = property.Value; break;

                case "region": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "site": Site = world.GetSite(Convert.ToInt32(property.Value)); break;
                }
            }

            if (Target != null)
            {
                string creatureType = "";
                if (!string.IsNullOrWhiteSpace(Interaction))
                {
                    if (!Target.ActiveInteractions.Contains(Interaction))
                    {
                        Target.ActiveInteractions.Add(Interaction);
                    }
                    if (Doer != null)
                    {
                        Doer.LineageCurseChilds.Add(Target);
                        Target.LineageCurseParent = Doer;
                    }

                    if (Interaction.Contains("VAMPIRE"))
                    {
                        creatureType = "vampire";
                    }
                    if (Interaction.Contains("WEREBEAST"))
                    {
                        creatureType = "werebeast";
                    }
                    if (Interaction.Contains("SECRET"))
                    {
                        creatureType = "necromancer";
                    }
                    if (Interaction.Contains("ANIMATE"))
                    {
                        creatureType = "animated corpse";
                    }
                    if (Interaction.Contains("UNDEAD_RES"))
                    {
                        creatureType = "resurrected undead";
                    }
                }
                if (!string.IsNullOrWhiteSpace(InteractionAction) && InteractionAction.Contains(", passing on the "))
                {
                    Target.Interaction = InteractionAction.Replace(", passing on the ", "");
                    if (!string.IsNullOrEmpty(Target.Interaction))
                    {
                        creatureType = "were" + Target.Interaction.Replace(" monster curse", " ");
                    }
                }
                else if (!string.IsNullOrWhiteSpace(InteractionString) && InteractionString.Contains(" to assume the form of a "))
                {
                    Target.Interaction = InteractionString.Replace(" to assume the form of a ", "").Replace("-like", "").Replace(" every full moon", " curse");
                    if (!string.IsNullOrEmpty(Target.Interaction))
                    {
                        creatureType = "were" + Target.Interaction.Replace(" monster curse", " ");
                    }
                }

                if (!string.IsNullOrEmpty(creatureType))
                {
                    Target.CreatureTypes.Add(new HistoricalFigure.CreatureType(creatureType, this));
                }
            }
            Doer.AddEvent(this);
            Target.AddEvent(this);
            Region.AddEvent(this);
            Site.AddEvent(this);
        }
        public HfDoesInteraction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "doer_hfid": Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "target_hfid": Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "interaction": Interaction = property.Value; break;

                case "doer": if (Doer == null)
                    {
                        Doer = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "target": if (Target == null)
                    {
                        Target = world.GetHistoricalFigure(Convert.ToInt32(property.Value));
                    }
                    else
                    {
                        property.Known = true;
                    } break;

                case "interaction_action": InteractionAction = property.Value.Replace("[IS_HIST_STRING_1:", "").Replace("[IS_HIST_STRING_2:", "").Replace("]", ""); break;

                case "interaction_string": InteractionString = property.Value.Replace("[IS_HIST_STRING_2:", "").Replace("[I_TARGET:A:CREATURE", "").Replace("]", ""); break;

                case "source": Source = property.Value; break;

                case "region": Region = world.GetRegion(Convert.ToInt32(property.Value)); break;

                case "site": Site = world.GetSite(Convert.ToInt32(property.Value)); break;
                }
            }

            if (Target != null && !string.IsNullOrWhiteSpace(Interaction))
            {
                if (!Target.ActiveInteractions.Contains(Interaction))
                {
                    Target.ActiveInteractions.Add(Interaction);
                }
                if (Doer != null)
                {
                    Doer.LineageCurseChilds.Add(Target);
                    Target.LineageCurseParent = Doer;
                }
            }
            if (Target != null && !string.IsNullOrWhiteSpace(InteractionAction))
            {
                if (InteractionAction.Contains(", passing on the "))
                {
                    Target.Interaction = InteractionAction.Replace(", passing on the ", "");
                }
                else if (InteractionString.Contains(" to assume the form of a "))
                {
                    Target.Interaction = InteractionString.Replace(" to assume the form of a ", "").Replace("-like", "").Replace(" every full moon", " curse");
                }
            }
            Doer.AddEvent(this);
            Target.AddEvent(this);
            Region.AddEvent(this);
            Site.AddEvent(this);
        }
Example #14
0
 public string GetDoerTmpValue(Doer doer, string key, string typeString)
 {
     return(ConvertValue(doer.GetTmp <object>(key), typeString));
 }
Example #15
0
 void Start()
 {
     ps      = gameObject.transform.parent.gameObject.GetComponent <puzzleScript>();
     success = ps.checkSuccess;
 }