Exemplo n.º 1
0
        public static bool CheckIfIncidentIsOnCooldown(StoreIncident incident, string username, bool separateChannel = false)
        {
            if (!ToolkitSettings.EventsHaveCooldowns)
            {
                return(false);
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            bool maxed = component.IncidentsInLogOf(incident.abbreviation) >= incident.eventCap;

            if (maxed)
            {
                float days = component.DaysTillIncidentIsPurchaseable(incident);
                Toolkit.client.SendMessage($"@{username} {incident.label.CapitalizeFirst()} is maxed, wait " + days + $" day{(days != 1 ? "s" : "")} to purchase.", separateChannel);
            }

            return(maxed);
        }
        public static bool CheckIfIncidentIsOnCooldown(StoreIncident incident, string username, bool separateChannel = false)
        {
            if (!ToolkitSettings.EventsHaveCooldowns)
            {
                return(false);
            }

            Store_Component component = Current.Game.GetComponent <Store_Component>();

            bool maxed = component.IncidentsInLogOf(incident.abbreviation) >= incident.eventCap;

            if (maxed)
            {
                Log.Message("StoreIncident max per day reached for " + incident.label);
                client.SendMessage($"@{username} " + "TwitchToolkitEventOnCooldown".Translate(), separateChannel);
            }

            return(maxed);
        }
Exemplo n.º 3
0
        public static bool CheckIfCarePackageIsOnCooldown(string username, bool separateChannel = false)
        {
            if (!ToolkitSettings.MaxEvents)
            {
                return(false);
            }

            Store_Component        component = Current.Game.GetComponent <Store_Component>();
            StoreIncidentVariables incident  = DefDatabase <StoreIncidentVariables> .GetNamed("Item");

            if (component.IncidentsInLogOf(incident.abbreviation) >= ToolkitSettings.MaxCarePackagesPerInterval)
            {
                float daysTill = component.DaysTillIncidentIsPurchaseable(incident);
                Toolkit.client.SendMessage($"@{username} care packages are on cooldown, wait " + daysTill + $" day{(daysTill != 1 ? "s" : "")}.", separateChannel);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public float DaysTillIncidentIsPurchaseable(StoreIncident incident)
        {
            Store_Component component = Current.Game.GetComponent <Store_Component>();

            List <int> associateLogIDS = new List <int>();

            bool onCooldownByKarmaType;
            bool onCooldownByIncidentCap;

            float ticksTillExpires        = -1;
            float daysTillCooldownExpires = -1;

            if (incident.defName == "Item")
            {
                if (ToolkitSettings.MaxEvents)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByKarmaType = logged >= ToolkitSettings.MaxCarePackagesPerInterval;
                }

                if (ToolkitSettings.EventsHaveCooldowns)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByIncidentCap = logged >= incident.eventCap;
                }

                foreach (KeyValuePair <int, string> pair in abbreviationHistory)
                {
                    if (pair.Value == incident.abbreviation)
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }
            }
            else
            {
                if (ToolkitSettings.MaxEvents)
                {
                    int logged = component.KarmaTypesInLogOf(incident.karmaType);
                    onCooldownByKarmaType = Purchase_Handler.CheckTimesKarmaTypeHasBeenUsedRecently(incident);
                }

                if (ToolkitSettings.EventsHaveCooldowns)
                {
                    int logged = component.IncidentsInLogOf(incident.abbreviation);
                    onCooldownByIncidentCap = logged >= incident.eventCap;
                }

                foreach (KeyValuePair <int, string> pair in abbreviationHistory)
                {
                    if (pair.Value == incident.abbreviation)
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }

                foreach (KeyValuePair <int, string> pair in karmaHistory)
                {
                    if (pair.Value == incident.karmaType.ToString())
                    {
                        associateLogIDS.Add(pair.Key);
                    }
                }
            }

            foreach (int id in associateLogIDS)
            {
                float ticksAgo            = Find.TickManager.TicksGame - tickHistory[id];
                float daysAgo             = ticksAgo / GenDate.TicksPerDay;
                float ticksTillExpiration = (ToolkitSettings.EventCooldownInterval * GenDate.TicksPerDay) - ticksAgo;
                if (ticksTillExpires == -1 || ticksAgo < ticksTillExpiration)
                {
                    ticksTillExpires        = ticksAgo;
                    daysTillCooldownExpires = ticksTillExpiration / GenDate.TicksPerDay;
                }
            }

            return((float)Math.Round(daysTillCooldownExpires, 1));
        }