Example #1
0
 private void FillCombos()
 {
     if (Facture.Season.ToString() != null)
     {
         Season = new SeasonModel();
         Season = Season.Get(Facture.Season);
         for (int i = 0; i < Seasons.Count(); i++)
         {
             if (Season.Id == Seasons[i].Id)
             {
                 SelectedSeason = i;
                 break;
             }
         }
     }
     else
     {
         SelectedSeason = null;
     }
     Customer = new CustomerModel();
     Customer = Customer.Get(Facture.Customer);
     for (int i = 0; i < Customers.Count(); i++)
     {
         if (Customer.Id == Customers[i].Id)
         {
             SelectedCustomer = i;
             break;
         }
     }
 }
            public bool check(GameLocation loc)
            {
                bool ret = true;

                if (Children.Count > 0)
                {
                    if (ChildrenCombine != "and")
                    {
                        ret = false;
                    }

                    int totalMet = 0;
                    foreach (var child in Children)
                    {
                        bool childCheck = child.check(loc);
                        if (childCheck)
                        {
                            ++totalMet;
                        }

                        switch (ChildrenCombine)
                        {
                        case "and": ret = ret && childCheck; break;

                        case "or": ret = ret || childCheck; break;

                        case "xor": ret = ret ^ childCheck; break;
                        }
                    }

                    if (ChildrenCombine.StartsWith("atleast"))
                    {
                        ret = totalMet >= int.Parse(ChildrenCombine.Substring(7));
                    }
                    else if (ChildrenCombine.StartsWith("exactly"))
                    {
                        ret = totalMet == int.Parse(ChildrenCombine.Substring(7));
                    }
                    else if (ChildrenCombine != "and" && ChildrenCombine != "or" && ChildrenCombine != "xor")
                    {
                        throw new ArgumentException("Bad ChildrenCombine: " + ChildrenCombine);
                    }
                }
                else if (MinTimeOfDay != -1 && Game1.timeOfDay < MinTimeOfDay)
                {
                    ret = false;
                }
                else if (MaxTimeOfDay != -1 && Game1.timeOfDay > MaxTimeOfDay)
                {
                    ret = false;
                }
                else if (Seasons != null && Seasons.Count() > 0 && !Seasons.Contains(Game1.currentSeason))
                {
                    ret = false;
                }
                else if (Locations != null && Locations.Count() > 0 && !Locations.Contains(loc.Name))
                {
                    ret = false;
                }
                else if (Game1.random.NextDouble() >= Math.Max(0.15, (Math.Min(0.5, loc.map.Layers[0].LayerWidth * loc.map.Layers[0].LayerHeight / ChancePerTile))))
                {
                    ret = false;
                }
                else if (RequireDarkOut && !Game1.isDarkOut())
                {
                    ret = false;
                }
                else if (!AllowRain && Game1.isRaining)
                {
                    ret = false;
                }

                if (Not)
                {
                    ret = !ret;
                }
                return(ret);
            }