Exemple #1
0
 private void AddToAcolytePostQueue(WarframeAcolyte acolyte, bool notifyClient, bool acolyteHasExpired)
 {
     if (!_acolyteMessagePostQueue.Any(x => x.WarframeEvent.GUID == acolyte.GUID))
     {
         _acolyteMessagePostQueue.Add(new MessageQueueElement <WarframeAcolyte>(acolyte, notifyClient, acolyteHasExpired));
     }
 }
Exemple #2
0
        public IEnumerable <WarframeAcolyte> GetAcolytes()
        {
            JObject worldState     = _scraper.WorldState;
            var     resultAcolytes = new List <WarframeAcolyte>();

            //Find Alerts
            foreach (var jsonAcolyte in worldState["PersistentEnemies"])
            {
                WarframeAcolyte currentAcolyte = _acolytesList.Find(x => x.GUID == jsonAcolyte["_id"]["$oid"].ToString());

                //We want to know this information regardless of whether or not the acolyte has been previously discovered
                var jsonAcolyteName = jsonAcolyte["AgentType"].ToString();
                var loc             = jsonAcolyte["LastDiscoveredLocation"].ToString();

                var nodeName      = loc;
                var acolyteName   = jsonAcolyteName;
                var acolyteHealth = float.Parse(jsonAcolyte["HealthPercent"].ToString());
                var isDiscovered  = bool.Parse(jsonAcolyte["Discovered"].ToString());

                using (var unit = new UnitOfWork(new WarframeDataContext()))
                {
                    acolyteName = unit.WFEnemies.GetNameByURI(jsonAcolyteName);
                    nodeName    = unit.WFSolarNodes.GetNodeName(loc);
                }

                if (currentAcolyte == null)
                {
                    var id = jsonAcolyte["_id"]["$oid"].ToString();
                    var lastDiscoveredTime = jsonAcolyte["LastDiscoveredTime"]["$date"]["$numberLong"].ToString();
                    var regionIndex        = isDiscovered ? int.Parse(jsonAcolyte["Region"].ToString()) : -1;

                    if (acolyteHealth > .0f)
                    {
                        currentAcolyte = new WarframeAcolyte(id, acolyteName, nodeName, acolyteHealth, regionIndex, isDiscovered);
                        _acolytesList.Add(currentAcolyte);
#if DEBUG
                        Console.WriteLine("New Acolyte Event");
#endif
                    }
                }

                _acolytesList.RemoveAll(x => x.Health <= .0f);

                if ((currentAcolyte != null) && (currentAcolyte.Health > .0f))
                {
                    currentAcolyte.IsDiscovered = isDiscovered;
                    currentAcolyte.UpdateLocation(nodeName);
                    currentAcolyte.UpdateHealth(acolyteHealth);
                    resultAcolytes.Add(currentAcolyte);
                }
            }

            return(_acolytesList);
        }
        //Parse the mission information into a readable presentation
        public static string DiscordMessage(this WarframeAcolyte acolyte, bool isNotification)
        {
            var statusMessage = new StringBuilder();

            var returnMessage = new StringBuilder();

            if (!isNotification)
            {
                returnMessage.AppendLine(acolyte.Name);
                returnMessage.AppendLine($"Health: {string.Format("{0:0.00}", acolyte.Health * 100.0f)}%");
                var discoveryMessage = acolyte.IsDiscovered ? acolyte.DestinationName : "Location: Unknown";
                returnMessage.AppendLine(discoveryMessage);
            }
            else
            {
                returnMessage.AppendLine("New Acolyte");
                returnMessage.AppendLine(acolyte.Name);
                returnMessage.Append(acolyte.DestinationName);
            }

            return(returnMessage.ToString());
        }