private void AddToBountyPostQueue(WarframeOstronBounty bounty, bool notifyClient, bool bountyHasExpired) { if (!_ostronBountyMessagePostQueue.Any(x => x.WarframeEvent.GUID == bounty.GUID)) { _ostronBountyMessagePostQueue.Add(new MessageQueueElement <WarframeOstronBounty>(bounty, notifyClient, bountyHasExpired)); } }
public static string DiscordMessage(this WarframeOstronBounty bounty, bool isNotification) { MissionInfo info = bounty.MissionDetails; var returnMessage = new StringBuilder(); if (!isNotification) { returnMessage.AppendLine(bounty.JobType); returnMessage.AppendLine($"Enemy Level: {info.MinimumLevel}-{info.MaximumLevel}"); returnMessage.AppendLine($"{bounty.OstronStanding.Take(bounty.OstronStanding.Count).Sum()} Standing"); returnMessage.AppendLine("_____________________________"); foreach (var reward in bounty.RewardTable) { var rewardRegexMatch = new Regex("^(.+?)( X(\\d+))?$").Match(reward); var rewardQuantity = rewardRegexMatch.Groups[3].Value; var item = rewardRegexMatch.Groups[1].Value; var newRewardText = $"{rewardQuantity}{(!string.IsNullOrEmpty(rewardQuantity) ? "x" : string.Empty)}{item}"; returnMessage.AppendLine(newRewardText); } } return(returnMessage.ToString()); }
public IEnumerable <WarframeOstronBounty> GetOstronBounties() { JObject worldState = _scraper.WarframeStatusWorldState; var resultBounties = new List <WarframeOstronBounty>(); JToken ostronSyndicate = worldState["syndicateMissions"].SingleOrDefault(x => x["syndicate"].ToString() == "Ostrons"); JToken ostronSyndicateBounties = ostronSyndicate != null ? ostronSyndicate["jobs"] : null; if (ostronSyndicateBounties == null) { return(_ostronBountyList); } var bountyCycleStartTime = ostronSyndicate != null?DateTime.Parse(ostronSyndicate["activation"].ToString()).ToLocalTime() : DateTime.Now; var bountyCycleExpireTime = ostronSyndicate != null?DateTime.Parse(ostronSyndicate["expiry"].ToString()).ToLocalTime() : DateTime.Now; //Find Bounties foreach (var jsonBounty in ostronSyndicateBounties) { WarframeOstronBounty currentBounty = _ostronBountyList.Find(x => x.GUID == jsonBounty["id"].ToString()); if (currentBounty == null) { var id = jsonBounty["id"].ToString(); var loc = "Cetus (Earth)"; var rewardStr = string.Empty; var nodeName = loc; var startTime = bountyCycleStartTime; var expireTime = bountyCycleExpireTime; if (DateTime.Now < expireTime) { MissionInfo bountyInfo = new MissionInfo(string.Empty, string.Empty, 0, rewardStr, 0, int.Parse(jsonBounty["enemyLevels"][0].ToString()), int.Parse(jsonBounty["enemyLevels"][1].ToString()), false); var jobType = jsonBounty["type"].ToString(); var ostronStanding = new List <int>(); foreach (var standing in jsonBounty["standingStages"]) { ostronStanding.Add(int.Parse(standing.ToString())); } var rewards = new List <string>(); foreach (var reward in jsonBounty["rewardPool"]) { rewards.Add(reward.ToString()); } currentBounty = new WarframeOstronBounty(bountyInfo, id, nodeName, startTime, expireTime, jobType, ostronStanding, rewards); _ostronBountyList.Add(currentBounty); #if DEBUG Console.WriteLine("New Bounty Event"); #endif } } _ostronBountyList.RemoveAll(x => x.ExpireTime < DateTime.Now); if ((_ostronBountyList != null) && (bountyCycleExpireTime > DateTime.Now)) { resultBounties.Add(currentBounty); } } return(_ostronBountyList); }