public static Dictionary <int, bool> GenerateCalendarTaxBool(this CustomWorldDate worldDate, IEnumerable <TaxSchedule> taxSchedules)
        {
            worldDate.SetToFirstDayOfSeason();
            var filtered = taxSchedules.Where(c => c.DayCount >= worldDate.DaysCount && c.DayCount <= worldDate.DaysCount + 28);

            return(Enumerable.Range(0, 28).ToDictionary(c => worldDate.DaysCount + c, c => filtered.Any(f => f.DayCount == worldDate.DaysCount + c)));
        }
示例#2
0
        public EconomyPage(UIFramework ui, Texture2D texture, string Hovertext, TaxationService taxation) : base(ui, texture, Hovertext)
        {
            this.taxation = taxation;
            //Elements.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11233")));
            //Elements.Add(new ContentElementText(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11234")));
            Elements.Add(new ContentElementHeaderText(Util.Helper.Translation.Get("BalanceReportText")));
            Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentLotValueText")}: {taxation.LotValue.Sum}g"));
            Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentTaxBalance")}: {taxation.State?.PendingTaxAmount}g"));

            TaxSchedule     scheduledTask = null;
            CustomWorldDate date          = null;

            load();
            void load()
            {
                scheduledTask = taxation.State?.ScheduledTax.OrderBy(c => c.DayCount).FirstOrDefault(c => !c.Paid);
                date          = scheduledTask?.DayCount.ToWorldDate();
            };

            Elements.Add(new ContentElementText(() =>
            {
                load();

                return(scheduledTask != null ? Util.Helper.Translation.Get("NextScheduledTaxText") : Util.Helper.Translation.Get("NoBillsForYouText"));
            }));
            Elements.Add(new ContentElementText(() =>
            {
                return(scheduledTask != null ? $"{Game1.content.LoadString("Strings\\StringsFromCSFiles:Utility.cs.5678", date.DayOfMonth, (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.es) ? date.Season.GetLocalizedSeason().ToLower() : date.Season.GetLocalizedSeason(), date.Year)} - {scheduledTask.Sum}g" : "");
            }));


            payButton = new ClickableComponent(new Rectangle(xPositionOnScreen + 64, Game1.activeClickableMenu.height + 50, (int)Game1.dialogueFont.MeasureString("_____________").X, 96), "", "_____________");

            for (int i = 0; i < Elements.Count; ++i)
            {
                Slots.Add(new ClickableComponent(
                              new Rectangle(
                                  xPositionOnScreen + Game1.tileSize / 4,
                                  yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * (height - Game1.tileSize * 2) / 7,
                                  width - Game1.tileSize / 2,
                                  (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom),
                              i.ToString()));
            }

            this.Draw             = DrawContent;
            this.DrawHover        = DrawHoverContent;
            this.LeftClickAction += Leftclick;
        }
示例#3
0
        public void CheckIfCalendarTaxBoolIsWorkingFine()
        {
            //108scenario
            //113scenario
            //1579scenario
            //569-580
            var rd    = new Random();
            var index = rd.Next(0, 580);

            TestIfHasOnlyTwentyEightItems(index);

            var list = new List <TaxSchedule>()
            {
            };
            var resultScenarioOne = 1.ToWorldDate()
                                    .GenerateCalendarTaxBool(list);

            Assert.AreEqual(28, resultScenarioOne.Count(c => c.Value == false), "Should not exist any tax because list is empty!");


            list.Add(new TaxSchedule()
            {
                DayCount = 108
            });                                             //24day
            list.Add(new TaxSchedule()
            {
                DayCount = 85
            });                                           //1day
            list.Add(new TaxSchedule()
            {
                DayCount = 112
            });                                            //28day
            var resultScenarioTwo = 108.ToWorldDate()
                                    .GenerateCalendarTaxBool(list);

            Assert.AreEqual(3, resultScenarioTwo.Where(c => c.Value).Count(), "Should exists 3 tax registered");
            Assert.AreEqual(true, resultScenarioTwo.Any(c => c.Key == 108 && c.Value));
            Assert.AreEqual(true, resultScenarioTwo.Any(c => c.Key == 85 && c.Value));
            Assert.AreEqual(true, resultScenarioTwo.Any(c => c.Key == 112 && c.Value));


            void TestIfHasOnlyTwentyEightItems(int referenceIndex)
            {
                var referenceDate = new CustomWorldDate(referenceIndex);
                var taxes         = GenerateSomeTaxSchedule(referenceIndex, referenceDate);

                referenceDate = new CustomWorldDate(referenceIndex);
                var dict = referenceDate.GenerateCalendarTaxBool(taxes);

                Assert.AreEqual(28, dict.Count);
            }

            List <TaxSchedule> GenerateSomeTaxSchedule(int referenceIndex, CustomWorldDate referenceDate)
            {
                var taxes = new List <TaxSchedule>();

                for (int i = referenceIndex; i <= referenceIndex + 80; i++)
                {
                    if (i != referenceIndex)
                    {
                        referenceDate.AddDays(1);
                    }
                    taxes.Add(new TaxSchedule(referenceDate, new EconomyMod.TaxDetailed()));
                }
                return(taxes);
            }
        }