public BaseUnit() { var cultureInfo = new CultureInfo("en-GB"); cultureInfo.NumberFormat.CurrencySymbol = "£"; CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; SurvivorStaticData.LoadStatics(); MissionsStaticData.LoadStatics(); Api = new EpicApi(); Api.StartVerifier().Wait(); FriendsApi = new EpicFriendListApi(); FriendsApi.StartVerifier().Wait(); Global.DIManager.BuildService(Service => { Service.AddTransient <BotContext>(); Service.AddSingleton <IJsonStringLocalizer, JsonStringLocalizer>(); Service.AddTransient <IUnitOfWork, UnitOfWork>(); Service.AddTransient <IFTNPowerRepository, FTNPowerRepository>(); Service.AddSingleton <IConfiguration>(new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) #if RELEASE .AddJsonFile("appsettings.Production.json", optional: true) #elif DEBUG .AddJsonFile("appsettings.Development.json", optional: true) #endif .AddEnvironmentVariables() .Build()); }); }
public static double GetSurvivorPower(byte SlotId, SurvivorRarity rarity, byte level, byte tier, bool IsLeaderAppropriate) { var constans = SurvivorStaticData.GetLevel_EvoluationConstants(rarity, SlotId == 0); var pw = Math.Round((int)rarity + (level - 1) * constans[0] + (tier - 1) * constans[1], MidpointRounding.AwayFromZero); if (SlotId == 0 && IsLeaderAppropriate) { pw = pw * 2; } return(pw); }
public async void User_Energy_Calculate() { do { var profile = await User_PVEQueryProfile(); IEnumerable <IGrouping <string, ISurvivorX> > survivorslots = await profile.Value.GetSurvivors(); var points = await survivorslots.CalcSurvivorFORTs(); int research = await profile.Value.CalcResearchFORTs(); var totalResources = points + research; var energy = await SurvivorStaticData.CalcEnergyByFORT(totalResources); Assert.True(energy >= 1); }while (true); }
public static Task UseFortniteApi(this IServiceProvider serviceProvider) { return(Task.Run(() => { var epicApi = serviceProvider.GetRequiredService <IEpicApi>(); return epicApi.StartVerifier() .ContinueWith((o) => { if (o.IsFaulted) { throw o.Exception; } MissionsStaticData.LoadStatics(); SurvivorStaticData.LoadStatics(); var missionService = serviceProvider.GetService <IMissionService>(); missionService?.StartWebhookTimer(); var catalogService = serviceProvider.GetService <ICatalogService>(); catalogService?.StartCatalogTimer(); }); })); }
public async Task <bool> UpdateDatabasePVEProfileAsync(KeyValuePair <string, IQueryProfile> profile, IGuildUser guser, IUserMessage msg = null, bool nameTag = false, bool IsNameLocked = false, bool PVEDecimals = true) { if (_uow.Db <BlackListUser>().Where(p => p.Id == guser.Id.ToString()).Any()) { return(false); } var svvrs = await profile.Value.GetSurvivors(); var svvrsResource = await svvrs.CalcSurvivorFORTs(); var resources = await profile.Value.CalcResearchFORTs(); var AccountPowerLevel = await SurvivorStaticData.CalcEnergyByFORT(svvrsResource + resources); var mSchematics = profile.Value.AmountOfMythicSchematics(); var frostnite2019 = profile.Value.DoneEliteFrostnite2019(); var mockPveProfile = new FortnitePVEProfile { EpicId = profile.Value.profileChanges.First().profile.accountId, PlayerName = profile.Key, AccountPowerLevel = AccountPowerLevel, NumMythicSchematics = mSchematics, EliteFortnite2019 = frostnite2019 }; if (AccountPowerLevel < 16) { mockPveProfile.Map = MapRoles.Stonewood; } else if (AccountPowerLevel < 46) { mockPveProfile.Map = MapRoles.Plankerton; } else if (AccountPowerLevel < 70) { mockPveProfile.Map = MapRoles.CannyValley; } else { mockPveProfile.Map = MapRoles.TwinePeaks; } StatAttribute stats = profile.Value.profileChanges.First().profile.stats["attributes"]; if (stats.rewards_claimed_post_max_level.HasValue) { if (stats != null) { mockPveProfile.CommanderLevel = (stats.level + stats.rewards_claimed_post_max_level.Value); } } else { if (stats != null) { mockPveProfile.CommanderLevel = stats.level; } } if (stats.collection_book != null) { mockPveProfile.CollectionBookLevel = stats.collection_book.maxBookXpLevelAchieved; } UpdateDatabaseUserProfile(mockPveProfile.EpicId, guser, msg, nameTag, GameUserMode.PVE); StoredProcedure.SP_TABLE_FortnitePVEProfile_Update(mockPveProfile); await UpdateDiscordPVEProfileAsync(mockPveProfile, nameTag, guser, msg, IsNameLocked, PVEDecimals); return(true); }
public static async void DrawMissions(this BaseModule module, KeyValuePair <bool, PriorityTable> pstate, EmbedBuilder embed, IEnumerable <IMissionX> missions, string search) { int count = 0; foreach (var mission in missions) { if (mission.MissionNameInfo.Name == "Launch the Rocket") { continue; } count++; string GroupMission = $""; if (mission.IsGroupMission) { GroupMission = $"x4"; } string itemList = ""; bool firstAlertSet = false; string time = ""; var fraction = mission.availableUntil - DateTimeOffset.UtcNow; if ((int)(fraction).TotalHours > 0) { time = $"{(int)(fraction).TotalHours}h{(int)(fraction).Minutes }m"; } else if ((int)(fraction).Minutes > 0) { time = $"{(int)(fraction).Minutes}m"; } itemList += module.ToTranslate(BotTranslationString.MA_Available, module.GetLanguage(), time); foreach (var item in mission.Items) { if (item.GetRealItemName().Key == "0") { continue; } if (item.AlertReward && firstAlertSet == false) { firstAlertSet = true; var alertNameStr = mission.MissionCategory.ToDescriptionString(); itemList += $"**{alertNameStr}:**\n"; } string amount = ""; if (item.AlertReward && item.quantity > 1) { amount = $"(**x{item.quantity:#,##0.##}**)"; } else { if (item.AlertReward == false && item.quantity == 4) { amount = $"(**x4**)"; } else if (item.AlertReward == false && item.quantity != 1) { amount = $"(**x{item.quantity}**)"; } } var rname = item.GetRealItemName(true, module.GetLanguage().ToString()); itemList += $"<:{rname.Key}:{rname.Key}> *{rname.Value}* {amount}\n"; } itemList += SurvivorStaticData.InvinsibleImage(); string mapLevel = mission.MissionLevel.ToString(); embed.AddField($":zap:{mapLevel}<:{mission.MissionNameInfo.EmojiId}:{mission.MissionNameInfo.EmojiId}>{GroupMission} {mission.WorldName.GetName()}", itemList, true); } if (count == 0) { await module.ReplyEmbedErrorAsync($"no result found {search}"); return; } var frat = 3 - (count % 3); for (int i = 0; i < frat; i++) { embed.AddField(SurvivorStaticData.InvinsibleImage(), SurvivorStaticData.InvinsibleImage(), true); } await module.ReplyEmbedAsync(null, module.ToTranslate(BotTranslationString.MA_Title, module.GetLanguage()), embed.Fields, embed.Footer, embed.Color.Value, 0, pstate); }
public static Embed ToWebhookEmbed(this IMissionX mission, GuildLanguage language = GuildLanguage.EN) { int xy = 0; EmbedBuilder embed = new EmbedBuilder(); try { if (mission.MissionNameInfo.Name == "Launch the Rocket") { return(null); } string GroupMission = $""; if (mission.IsGroupMission) { GroupMission = $"{SurvivorStaticData.Get4xGroupMissionImage()}"; } bool firstAlertSet = false; var time = mission.availableUntil.ToStringHMS(); var Translate = DIManager.Services.GetRequiredService <IJsonStringLocalizer>(); string availableTime = Translate.GetBotTranslation(BotTranslationString.MA_ExpreIn, language, time); List <string> mapRewards = new List <string>(); List <string> alertRewards = new List <string>(); string alertNameStr = ""; foreach (var item in mission.Items) { if (item.AlertReward && firstAlertSet == false) { firstAlertSet = true; alertNameStr = mission.MissionCategory.ToDescriptionString(); } string amount = ""; if (item.AlertReward && item.quantity > 1) { amount = $"(**x{item.quantity:#,##0.##}**)"; } else { if (item.AlertReward && item.quantity == 4) { amount = $"(**x4**)"; } else if (item.AlertReward && item.quantity != 1) { amount = $"(**x{item.quantity}**)"; } } var itmInfo = item.GetRealItemName(false, language.ToString()); if (item.AlertReward == false) { mapRewards.Add($"<:{itmInfo.Key}:{itmInfo.Key}> *{itmInfo.Value}* {amount}"); } else { alertRewards.Add($"<:{itmInfo.Key}:{itmInfo.Key}> *{itmInfo.Value}* {amount}"); } } string mapLevel = mission.MissionLevel.ToString(); embed.Title = $"{mapLevel}:zap: {mission.MissionNameInfo.Name} {GroupMission} <:{mission.MissionNameInfo.EmojiId}:{mission.MissionNameInfo.EmojiId}>"; embed.Description = $"**{Translate.GetBotTranslation(mission.WorldName.ToString().Replace("_", ""), language)}**"; embed.WithFooter($"{availableTime}"); embed.AddField(Translate.GetBotTranslation(BotTranslationString.MA_Rewards, language), string.Join("\n", mapRewards.ToArray()), true); embed.AddField($"**{alertNameStr}**", string.Join("\n", alertRewards.ToArray()), true); string positive_mutations = ""; string negative_mutations = ""; int p = 0, n = 0; foreach (var mutation in mission.Modifiers) { string mId = Fortnite.Static.Utils.GetImage(mutation.AssetId); if (mutation.IsPositiveMutation.Value) { n++; positive_mutations += $"<:{mId}:{mId}> "; if (n % 5 == 0) { positive_mutations += "\n"; } } else { p++; negative_mutations += $"<:{mId}:{mId}> "; if (p % 5 == 0) { negative_mutations += "\n"; } } } if (positive_mutations.Length != 0 && negative_mutations.Length != 0) { embed.AddField(Translate.GetBotTranslation(BotTranslationString.MA_NegativeMutation, language), negative_mutations, false); embed.AddField(Translate.GetBotTranslation(BotTranslationString.MA_PositiveMutation, language), positive_mutations, true); } else if (negative_mutations.Length == 0 || positive_mutations.Length != 0) { embed.AddField(Translate.GetBotTranslation(BotTranslationString.MA_PositiveMutation, language), positive_mutations, false); } else if (negative_mutations.Length != 0 || positive_mutations.Length == 0) { embed.AddField(Translate.GetBotTranslation(BotTranslationString.MA_NegativeMutation, language), negative_mutations, false); } if (mission.AnyEpic()) { embed.Color = new Color(187, 143, 206); } if (mission.AnyLegendary()) { embed.Color = new Color(248, 196, 113); } if (mission.HasVBuck()) { embed.Color = new Color(133, 193, 233); } } catch (Exception e) { Console.WriteLine(e); Console.WriteLine("-------------------------------------------"); Console.WriteLine(JsonConvert.SerializeObject(mission)); Console.WriteLine("-------------------------------------------"); } return(embed.Build()); }
public static Embed ToWebhookEmbed(this List <DailyLlama> mission) { EmbedBuilder embed = new EmbedBuilder(); var vbuck = SurvivorStaticData.AssetBot2["currency_mtxswap"].EmojiId; var tickets = SurvivorStaticData.AssetBot2["campaign_event_currency"].EmojiId; foreach (var m in mission) { var priceIcon = vbuck; if (m.GameItem) { priceIcon = tickets; } // embed.AddField($"{m.Title}", $"**{(m.Price == 0 ? "FREE" : m.Price.ToString())}** {(m.Price == 0 ? "" : $"<:{priceIcon}:{priceIcon}>")} [ **Limit:** {m.Amount} ]\n{m.Description}\n{SurvivorStaticData.InvinsibleImage()}"); } embed.Color = new Color(230, 176, 170); return(embed.Build()); }