Пример #1
0
        internal async Task LastKnownInfoForFATE(ushort id)
        {
            if (FFXIVHunts.hubConnection.Connected && FFXIVHunts.Joined)
            {
                FATEReport[] results = await FFXIVHunts.hubConnection.Connection.InvokeAsync("QueryFATE", id, default(CancellationToken)).ConfigureAwait(false);

                foreach (FATEReport result in results)
                {
                    TimeSpan timeSinceLastReport = FFXIVHunts.ServerTimeUtc.Subtract(result.LastReported);
                    if (timeSinceLastReport < TimeSpan.Zero)
                    {
                        timeSinceLastReport = TimeSpan.Zero;
                    }
                    ChatMessage cm = new ChatMessage();
                    if (timeSinceLastReport.TotalDays > 90.0)
                    {
                        cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIHuntNotReported, result.Name(false));
                    }
                    else if (timeSinceLastReport.TotalHours > 100.0)
                    {
                        cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIFATEDays, result.Name(false), Convert.ToUInt32(timeSinceLastReport.TotalDays));
                    }
                    else
                    {
                        cm = ChatMessage.MakePosChatMessage(FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIFATE, result.Name(false), Math.Floor(timeSinceLastReport.TotalHours), timeSinceLastReport.Minutes), result.ZoneID, result.PosX, result.PosY, "", 0);
                    }
                    if (result.Instance > 0)
                    {
                        cm.PostpendToMessage(string.Format(CultureInfo.CurrentCulture, " " + Resources.InstanceSpecifier, result.Instance));
                    }
                    await Program.mem.WriteChatMessage(cm).ConfigureAwait(false);
                }
                FATEReport[] array = null;
            }
        }
Пример #2
0
        internal async Task QueryHunt(ushort id)
        {
            if (FFXIVHunts.hubConnection.Connected && FFXIVHunts.Joined)
            {
                IOrderedEnumerable <Hunt> results = from x in await FFXIVHunts.hubConnection.Connection.InvokeAsync("QueryHunt", id, default(CancellationToken)).ConfigureAwait(false)
                                                    orderby x.LastReported
                                                    select x;

                foreach (Hunt result in results)
                {
                    TimeSpan timeSinceLastReport = FFXIVHunts.ServerTimeUtc.Subtract(result.LastReported);
                    if (timeSinceLastReport < TimeSpan.Zero)
                    {
                        timeSinceLastReport = TimeSpan.Zero;
                    }
                    ChatMessage cm         = new ChatMessage();
                    double      TotalHours = Math.Floor(timeSinceLastReport.TotalHours);
                    if (!result.LastAlive)
                    {
                        cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIHuntKilled, result.Name);
                        if (Resources.LKIHuntKilled.Contains("<time>"))
                        {
                            ChatMessage chatMessage = cm;
                            chatMessage.MessageString += cm.MessageString.Replace("<time>", string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes));
                        }
                        else if (timeSinceLastReport.TotalDays > 90.0)
                        {
                            cm.MessageString = FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKIHuntNotReported, result.Name);
                        }
                        else if (timeSinceLastReport.TotalHours > 72.0)
                        {
                            ChatMessage chatMessage2 = cm;
                            chatMessage2.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIHours, TotalHours);
                        }
                        else if (timeSinceLastReport.TotalHours < 1.0)
                        {
                            ChatMessage chatMessage3 = cm;
                            chatMessage3.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIMinutes, Math.Floor(timeSinceLastReport.TotalMinutes));
                        }
                        else
                        {
                            ChatMessage chatMessage4 = cm;
                            chatMessage4.MessageString += string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes);
                        }
                    }
                    else
                    {
                        ushort zid = FFXIVHunts.GetZoneId(result.Id);
                        cm = ChatMessage.MakePosChatMessage(FFXIVHunts.GetWorldPrepend(result.WorldId) + string.Format(CultureInfo.CurrentCulture, Resources.LKILastSeenAt, result.Name), zid, result.LastX, result.LastY, string.Format(CultureInfo.CurrentCulture, Resources.LKIHoursMinutes, TotalHours, timeSinceLastReport.Minutes), 0);
                    }
                    if (result.Instance > 0)
                    {
                        cm.PostpendToMessage(string.Format(CultureInfo.CurrentCulture, " " + Resources.InstanceSpecifier, result.Instance));
                    }
                    await Program.mem.WriteChatMessage(cm).ConfigureAwait(false);
                }
                IEnumerator <Hunt> enumerator = null;
            }
        }
Пример #3
0
        private bool PutInChat(FATEReport fate)
        {
            World world;

            if (!FFXIVHunts.Worlds.TryGetValue(fate.WorldId, out world))
            {
                return(false);
            }
            int idx = world.FATEs.IndexOf(fate);

            if (idx == -1)
            {
                return(false);
            }
            FATEReport FATEReport = world.FATEs[idx];

            FATEReport.State          = fate.State;
            FATEReport.StartTimeEpoch = fate.StartTimeEpoch;
            FATEReport.Duration       = fate.Duration;
            FATEReport.Progress       = fate.Progress;
            bool skipAnnounce = (Settings.Default.NoAnnouncementsInContent && Program.mem.GetCurrentContentFinderCondition() > 0) || (Math.Abs(fate.TimeRemaining.TotalHours) < 3.0 && fate.TimeRemaining.TotalMinutes < (double)Settings.Default.FATEMinimumMinutesRemaining) || ((fate.State == FATEState.Preparation) ? (FATEReport.lastPutInChat > Program.mem.GetServerUtcTime().AddMinutes(-10.0)) : (Math.Abs((int)(fate.Progress - FATEReport.LastReportedProgress)) < (int)Settings.Default.FATEMinimumPercentInterval && Settings.Default.FATEMinimumPercentInterval > 0));

            if (FFXIVHunts.FateNotifyCheck(FATEReport.ID) && FATEReport.lastPutInChat < Program.mem.GetServerUtcTime().AddMinutes((double)(-(double)Settings.Default.FATEInterval)) && !fate.HasEnded && !skipAnnounce)
            {
                string postpend;
                if (fate.State == FATEState.Preparation)
                {
                    postpend = Resources.PreparationState;
                }
                else if (Math.Abs(fate.TimeRemaining.TotalHours) > 3.0)
                {
                    postpend = fate.Progress.ToString() + "%";
                }
                else
                {
                    postpend = string.Format(CultureInfo.CurrentCulture, Resources.FATEPrcTimeRemaining, fate.Progress, (int)fate.TimeRemaining.TotalMinutes, fate.TimeRemaining.Seconds.ToString("D2", CultureInfo.CreateSpecificCulture(Settings.Default.LanguageCI)));
                }
                if (fate.Instance > 0)
                {
                    postpend += string.Format(CultureInfo.CurrentCulture, " " + Resources.InstanceSpecifier, fate.Instance);
                }
                ChatMessage cm = ChatMessage.MakePosChatMessage(string.Format(CultureInfo.CurrentCulture, FFXIVHunts.GetWorldPrepend(fate.WorldId) + Resources.FATEMsg, FATEReport.Name(false)), fate.ZoneID, fate.PosX, fate.PosY, " " + postpend, 0);
                Program.mem.WriteChatMessage(cm);
                this.CheckAndPlaySound(HuntRank.FATE);
                FATEReport.lastPutInChat        = Program.mem.GetServerUtcTime();
                FATEReport.LastReportedProgress = fate.Progress;
                return(true);
            }
            return(false);
        }