Пример #1
0
        private List <NotificationObject> GetLongReengagementNotifs()
        {
            string             text = "notif5";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);

            if (notificationTypeVO.RepeatTime < 1)
            {
                Service.Get <StaRTSLogger>().Error("LongTermNotification has 0 repeat time");
                return(null);
            }
            List <NotificationObject> list = new List <NotificationObject>();
            string   id                = (this.notifMessageKeySuffix != null) ? ("notif_" + text + this.notifMessageKeySuffix) : ("notif_" + text);
            string   message           = this.lang.Get(id, new object[0]);
            string   inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime time              = DateTime.get_Now().AddHours((double)notificationTypeVO.RepeatTime);

            this.EnsureValidNotificationTime(notificationTypeVO, time);
            int i = 0;

            while (i <= 4383)
            {
                NotificationObject item = new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time, text, text);
                list.Add(item);
                i   += notificationTypeVO.RepeatTime;
                time = time.AddHours((double)notificationTypeVO.RepeatTime);
            }
            return(list);
        }
Пример #2
0
        private NotificationObject GetNextRaidNotification()
        {
            RaidDefenseController raidDefenseController = Service.Get <RaidDefenseController>();
            CurrentPlayer         currentPlayer         = Service.Get <CurrentPlayer>();

            if (!raidDefenseController.AreRaidsAccessible())
            {
                return(null);
            }
            uint secondsTillNextRaid = raidDefenseController.GetSecondsTillNextRaid();

            if (secondsTillNextRaid == 0u)
            {
                Service.Get <StaRTSLogger>().Error("Failed to schedule raid notif due to invalid start time: " + currentPlayer.CurrentRaid.Uid);
                return(null);
            }
            string             text = "raid_start_next";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            string             id                = "notif_" + text;
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime           time              = DateTime.get_Now().AddSeconds(secondsTillNextRaid);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time))
            {
                return(null);
            }
            return(new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time, text, text));
        }
Пример #3
0
        private NotificationObject GetLastPerkExpiredNotification()
        {
            if (!Service.IsSet <CurrentPlayer>())
            {
                return(null);
            }
            if (Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress || !(Service.Get <GameStateMachine>().CurrentState is HomeState))
            {
                return(null);
            }
            NotificationTypeVO       notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>("perk_all_slots_empty");
            List <ActivatedPerkData> playerActivePerks  = Service.Get <PerkManager>().GetPlayerActivePerks();
            uint num = 0u;

            if (playerActivePerks != null)
            {
                int count = playerActivePerks.Count;
                for (int i = 0; i < count; i++)
                {
                    uint time = ServerTime.Time;
                    uint num2 = playerActivePerks[i].EndTime - time;
                    if (playerActivePerks[i].EndTime > time && num2 > num)
                    {
                        num = num2;
                    }
                }
            }
            if (num > 0u && (ulong)num >= (ulong)((long)notificationTypeVO.MinCompletionTime))
            {
                DateTime time2 = DateTime.get_Now().AddSeconds(num);
                return(this.CreateReengagementNotification("perk_all_slots_empty", time2, false));
            }
            return(null);
        }
Пример #4
0
        private NotificationObject GetProtectionExpirationNotification()
        {
            int protectionTimeRemaining = GameUtils.GetProtectionTimeRemaining();
            int num = 1800;

            if (protectionTimeRemaining < num)
            {
                return(null);
            }
            int                num2     = protectionTimeRemaining - num;
            string             text     = "protection_expire";
            NotificationTypeVO optional = Service.StaticDataController.GetOptional <NotificationTypeVO>(text);

            if (optional == null)
            {
                return(null);
            }
            if (optional.MinCompletionTime > num2)
            {
                return(null);
            }
            DateTime time = DateTime.Now.AddSeconds((double)num2);

            return(this.CreateReengagementNotification(text, time, false));
        }
Пример #5
0
        private List <NotificationObject> GetShortReengagementNotifs()
        {
            string             text = "notif4";
            string             uid  = "notif5";
            NotificationTypeVO notificationTypeVO  = Service.StaticDataController.Get <NotificationTypeVO>(text);
            NotificationTypeVO notificationTypeVO2 = Service.StaticDataController.Get <NotificationTypeVO>(uid);

            if (notificationTypeVO.RepeatTime < 1)
            {
                return(null);
            }
            if (notificationTypeVO2.RepeatTime < 1)
            {
                return(null);
            }
            List <NotificationObject> list = new List <NotificationObject>();
            DateTime time = DateTime.Now.AddHours((double)notificationTypeVO.RepeatTime);

            this.EnsureValidNotificationTime(notificationTypeVO, time);
            string id                = (this.notifMessageKeySuffix == null) ? ("notif_" + text) : ("notif_" + text + this.notifMessageKeySuffix);
            string message           = this.lang.Get(id, new object[0]);
            string inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            int    i = 0;

            while (i < notificationTypeVO2.RepeatTime)
            {
                NotificationObject item = new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time, text, text);
                list.Add(item);
                i   += notificationTypeVO.RepeatTime;
                time = time.AddHours((double)notificationTypeVO.RepeatTime);
            }
            return(list);
        }
Пример #6
0
        private NotificationObject CreateReengagementNotification(string notifTypeKey, DateTime time, bool tryMessageSuffix)
        {
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(notifTypeKey);
            string             id                = (tryMessageSuffix && this.notifMessageKeySuffix != null) ? ("notif_" + notifTypeKey + this.notifMessageKeySuffix) : ("notif_" + notifTypeKey);
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + notifTypeKey + "_progress", new object[0]);

            return(new NotificationObject(notifTypeKey, inProgressMessage, message, notificationTypeVO.SoundName, time, notifTypeKey, notifTypeKey));
        }
Пример #7
0
        private void LogReceivedLocalNotifications()
        {
            string text = this.notificationHandler.Call <string>("GetReceivedLocalNotifications", new object[0]);

            Service.Logger.Debug("Received Notification Data: " + text);
            Dictionary <string, object> dictionary = new JsonParser(text).Parse() as Dictionary <string, object>;

            if (!dictionary.ContainsKey("receivedLocalNotifs"))
            {
                return;
            }
            StaticDataController staticDataController = Service.StaticDataController;
            DateTime             now = DateTime.Now;

            now.AddMinutes(-5.0);
            List <object> list  = dictionary["receivedLocalNotifs"] as List <object>;
            int           count = list.Count;

            for (int i = 0; i < count; i++)
            {
                IDictionary <string, object> dictionary2 = list[i] as Dictionary <string, object>;
                string text2 = dictionary2["notifId"] as string;
                long   num   = Convert.ToInt64(dictionary2["date"] as string);
                Service.Logger.Debug(string.Concat(new object[]
                {
                    "notifId: ",
                    text2,
                    " date: ",
                    num
                }));
                if (!string.IsNullOrEmpty(text2))
                {
                    NotificationTypeVO optional = staticDataController.GetOptional <NotificationTypeVO>(text2);
                    if (optional != null)
                    {
                        DateTime      t             = DateUtils.DateFromMillis(num);
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append(text2);
                        stringBuilder.Append("|");
                        stringBuilder.Append("none");
                        stringBuilder.Append("|");
                        stringBuilder.Append(optional.SoundName);
                        int num2 = DateTime.Compare(t, now);
                        if (num2 >= 0)
                        {
                            Service.DMOAnalyticsController.LogNotificationReengage(text2, true, optional.Desc, stringBuilder.ToString());
                        }
                        else
                        {
                            Service.DMOAnalyticsController.LogNotificationImpression(text2, true, optional.Desc, stringBuilder.ToString());
                        }
                    }
                }
            }
        }
Пример #8
0
        private bool CheckValidNotificationTime(NotificationTypeVO notifType, DateTime time)
        {
            bool result            = true;
            int  earliestValidTime = notifType.EarliestValidTime;
            int  latestValidTime   = notifType.LatestValidTime;

            if (time.get_Hour() < earliestValidTime)
            {
                result = false;
            }
            else if (time.get_Hour() > latestValidTime)
            {
                result = false;
            }
            return(result);
        }
Пример #9
0
        private void EnsureValidNotificationTime(NotificationTypeVO notifType, DateTime time)
        {
            int earliestValidTime = notifType.EarliestValidTime;
            int latestValidTime   = notifType.LatestValidTime;
            int num = 0;

            if (time.get_Hour() < earliestValidTime)
            {
                num = earliestValidTime - time.get_Hour();
            }
            else if (time.get_Hour() > latestValidTime)
            {
                num = 24 - time.get_Hour() + earliestValidTime;
            }
            time = time.AddHours((double)num);
        }
Пример #10
0
        private NotificationObject GetInventoryCrateExpirationNotification()
        {
            uint            time          = ServerTime.Time;
            CurrentPlayer   currentPlayer = Service.Get <CurrentPlayer>();
            InventoryCrates crates        = currentPlayer.Prizes.Crates;
            uint            num           = (uint)(GameConstants.CRATE_EXPIRATION_WARNING_NOTIF * 60);
            uint            cRATE_EXPIRATION_WARNING_NOTIF_MINIMUM = (uint)GameConstants.CRATE_EXPIRATION_WARNING_NOTIF_MINIMUM;
            CrateData       nextInventoryCrateToExpire             = GameUtils.GetNextInventoryCrateToExpire(crates, time + cRATE_EXPIRATION_WARNING_NOTIF_MINIMUM);

            if (nextInventoryCrateToExpire == null)
            {
                return(null);
            }
            uint expiresTimeStamp = nextInventoryCrateToExpire.ExpiresTimeStamp;
            uint num2             = expiresTimeStamp - time;

            if (num2 > num)
            {
                num2 -= num;
                if (num2 < num)
                {
                    num2 = num;
                }
            }
            else
            {
                num2 = 10u;
            }
            string             text = "crate_expiration_warning";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            string             id                = "notif_" + text;
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime           time2             = DateTime.get_Now().AddSeconds(num2);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            return(new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time2, text, text));
        }
Пример #11
0
        private NotificationObject GetGeneratorNotification()
        {
            if (!Service.IsSet <CurrentPlayer>() || Service.Get <CurrentPlayer>().CampaignProgress == null)
            {
                return(null);
            }
            if (Service.Get <CurrentPlayer>().FirstTimePlayer || Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress)
            {
                return(null);
            }
            ICurrencyController currencyController = Service.Get <ICurrencyController>();
            int num = currencyController.CalculateTimeUntilAllGeneratorsFull();
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>("notif6");

            if (num > notificationTypeVO.MinCompletionTime)
            {
                DateTime time = DateTime.get_Now().AddSeconds((double)num + 2.0);
                return(this.CreateReengagementNotification("notif6", time, true));
            }
            return(null);
        }
Пример #12
0
        private NotificationObject GetNextDailyCrateNotification()
        {
            if (!GameConstants.CRATE_DAILY_CRATE_ENABLED)
            {
                return(null);
            }
            if (!Service.IsSet <CurrentPlayer>() || Service.Get <CurrentPlayer>().CampaignProgress == null || Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress)
            {
                return(null);
            }
            CurrentPlayer currentPlayer      = Service.Get <CurrentPlayer>();
            uint          nextDailyCrateTime = currentPlayer.Prizes.Crates.NextDailyCrateTime;

            if (nextDailyCrateTime == 0u)
            {
                Service.Get <StaRTSLogger>().Error("Did not schedule next daily crate notif due to invalid scheduled time");
                return(null);
            }
            uint time = ServerTime.Time;
            uint num  = nextDailyCrateTime + (uint)(GameConstants.CRATE_DAILY_CRATE_NOTIF_OFFSET * 60);
            uint num2 = num - time;

            if (num2 <= 0u)
            {
                return(null);
            }
            string             text = "daily_crate_next";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            DateTime           time2 = DateTime.get_Now().AddSeconds(num2);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            if ((ulong)num2 > (ulong)((long)notificationTypeVO.MinCompletionTime))
            {
                return(this.CreateReengagementNotification(text, time2, false));
            }
            return(null);
        }
Пример #13
0
        private NotificationObject GetUnitsCompleteNotification()
        {
            if (Service.CurrentPlayer == null || Service.CurrentPlayer.CampaignProgress == null)
            {
                return(null);
            }
            if (Service.CurrentPlayer.CampaignProgress.FueInProgress || !(Service.GameStateMachine.CurrentState is HomeState))
            {
                return(null);
            }
            NotificationTypeVO notificationTypeVO = Service.StaticDataController.Get <NotificationTypeVO>("notif2");
            int num = 0;
            NodeList <SupportNode> nodeList           = Service.EntityController.GetNodeList <SupportNode>();
            ISupportController     iSupportController = Service.ISupportController;

            for (SupportNode supportNode = nodeList.Head; supportNode != null; supportNode = supportNode.Next)
            {
                SmartEntity       smartEntity  = (SmartEntity)supportNode.Entity;
                BuildingComponent buildingComp = supportNode.BuildingComp;
                string            key          = buildingComp.BuildingTO.Key;
                if (!ContractUtils.IsBuildingUpgrading(smartEntity) && !ContractUtils.IsBuildingConstructing(smartEntity) && !iSupportController.IsBuildingFrozen(key))
                {
                    Contract contract = iSupportController.FindCurrentContract(key);
                    if (contract != null && iSupportController.IsContractValidForStorage(contract))
                    {
                        int num2 = ContractUtils.CalculateRemainingTimeOfAllTroopContracts(smartEntity);
                        if (num2 > num)
                        {
                            num = num2;
                        }
                    }
                }
            }
            if (num >= notificationTypeVO.MinCompletionTime)
            {
                DateTime time = DateTime.Now.AddSeconds((double)num + 2.0);
                return(this.CreateReengagementNotification("notif2", time, true));
            }
            return(null);
        }
Пример #14
0
        private NotificationObject CreateSupportNotification(string productUid, int remainingTime, string buildingKey, string notifTypeKey, string displayName, int level)
        {
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(notifTypeKey);

            if (remainingTime >= notificationTypeVO.MinCompletionTime)
            {
                string id      = (this.notifMessageKeySuffix != null) ? ("notif_" + notifTypeKey + this.notifMessageKeySuffix) : ("notif_" + notifTypeKey);
                string message = this.lang.Get(id, new object[]
                {
                    displayName,
                    level
                });
                string inProgressMessage = this.lang.Get("notif_" + notifTypeKey + "_progress", new object[]
                {
                    displayName,
                    level
                });
                DateTime time = DateTime.get_Now().AddSeconds((double)remainingTime + 2.0);
                return(new NotificationObject(notifTypeKey, inProgressMessage, message, notificationTypeVO.SoundName, time, buildingKey, productUid));
            }
            return(null);
        }
Пример #15
0
        private NotificationObject GetSquadWarUseTurnNotification()
        {
            uint            time       = ServerTime.Time;
            SquadWarManager warManager = Service.Get <SquadController>().WarManager;

            if (warManager == null || warManager.CurrentSquadWar == null)
            {
                return(null);
            }
            SquadWarParticipantState currentParticipantState = warManager.GetCurrentParticipantState();

            if (currentParticipantState == null || currentParticipantState.TurnsLeft <= 0)
            {
                return(null);
            }
            if ((long)warManager.CurrentSquadWar.ActionEndTimeStamp - (long)((ulong)time) <= 0L)
            {
                return(null);
            }
            int num = warManager.CurrentSquadWar.ActionEndTimeStamp - GameConstants.WAR_NOTIF_ACTION_TURNS_REMINDER * 3600 - (int)time;

            if (num <= 0)
            {
                return(null);
            }
            string             text = "squadwars_action_turns_reminder";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            string             id                = "notif_" + text;
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime           time2             = DateTime.get_Now().AddSeconds((double)num);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            return(new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time2, text, text));
        }