/// <summary> /// Customize your resilience settings for <see cref="Spigot"/> /// </summary> /// <param name="src">An instance of <see cref="ISpigotBuilder"/></param> /// <param name="resilienceBuilder">An action to build resilience</param> /// <returns></returns> public static ISpigotBuilder WithResilience(this ISpigotBuilder src, Action <Resilience> resilienceBuilder) { var resilience = new Resilience(); resilienceBuilder(resilience); src.Resilience = resilience; return(src); }
private static TimeSpan ComputeDuration(Mobile defender) { double seconds = DurationSeconds; Resilience song = Spellsong.GetEffectSpellsong <Resilience>(defender); if (song != null) { seconds = seconds - (song.CurseReduction * seconds / 100.0); } return(TimeSpan.FromSeconds(seconds)); }
public static double GetNaturalResistChance(Mobile m, Poison poison) { double poisoning = m.Skills.Poisoning.Value; Resilience song = Spellsong.GetEffectSpellsong <Resilience>(m); if (song != null) { poisoning += song.CurseReduction; // Guessing here. } double factor = 80.0 / (poison.Level + 1); double chance = factor * poisoning / 100.0; return(chance / 100.0); }
/// <summary> /// Search customer data based on Id (Identifier Id). /// </summary> /// <param name="accountId">The account identifier.</param> /// <param name="customerId">The customer identifier.</param> /// <param name="identifierId">The identifier identifier.</param> /// <param name="dateFrom">The date from.</param> /// <param name="dateTo">The date to.</param> /// <returns></returns> //TODO: Arrumar contrato de saida, não pode retornar o objeto do proxy wcf. Realizar mapper para um objeto de response. public async Task <getTransactionsResponse1> GetTransactionsAsync(long accountId, long customerId, long identifierId, DateTime dateFrom, DateTime dateTo) { var userContext = new extUserContextView { clientLogin = _clientUsername, clientPass = _clientPassword, channel = "U", langCode = "pt" }; getTransactionsResponse1 response = null; await Resilience.HandleAsync(async() => { const int pageNr = 1; const int pageSize = 10; response = await _comarchService.getTransactionsAsync(userContext, accountId, customerId, identifierId, null, null, dateFrom, dateTo, null, pageNr, pageSize); }, "ComarchGetTransactions"); return(response?.@return == null ? null : response); }
/// <summary> /// Adds the points asynchronous. /// </summary> /// <param name="identifierNumber">The identifier number.</param> /// <param name="firstName">The first name.</param> /// <param name="lastName">The last name.</param> /// <param name="partner">The partner.</param> /// <param name="inputPoints">The input points.</param> /// <param name="comment">The comment.</param> /// <param name="partnerTransactionNumber">The partner transaction number.</param> /// <param name="transactionDate">The transaction date.</param> /// <param name="loginPartner">The login partner.</param> /// <param name="passwordPartner">The password partner.</param> /// <param name="promotionCode">The promotion code.</param> /// <returns></returns> public async Task <processNonAirTransactionResponse1> AddPointsAsync( string identifierNumber, string firstName, string lastName, string partner, long inputPoints, string comment, string partnerTransactionNumber, DateTime transactionDate, string loginPartner, string passwordPartner, string promotionCode ) { var userContext = new extUserContextView { clientLogin = loginPartner, clientPass = passwordPartner, channel = "V", langCode = "pt" }; processNonAirTransactionResponse1 response = null; await Resilience.HandleAsync(async() => { //TODO: Usar AutoMapper para mapeamento de objetos. var transactionData = new wsNonAirTransactionRequest { identifierNo = identifierNumber, firstName = firstName, lastName = lastName, partner = partner, inputPoints = inputPoints, comment = comment, partnerTransactionNo = partnerTransactionNumber, date = transactionDate, promotionCode = promotionCode }; response = await _comarchService.processNonAirTransactionAsync(userContext, false, transactionData); }, "ComarchAddPoints"); if (response?.@return == null) { return(null); } return(response); }
public async Task <changePasswordResponse1> ChangePasswordAsync(long customerId, wsChangePasswordData changedPasswordData) { var userContext = new extUserContextView { clientLogin = _clientUsername, clientPass = _clientPassword, channel = "U", langCode = "pt" }; changePasswordResponse1 response = null; await Resilience.HandleAsync(async() => { response = await _comarchService.changePasswordAsync(userContext, customerId, changedPasswordData); }, "ComarchEnrollCustomerExtAsync"); if (response == null) { throw new Exception(); } return(response); }
public async Task <enrollCustomerExtResponse1> EnrollCustomerExtAsync(extWSRegistrationFormView customer) { var userContext = new extUserContextView { clientLogin = _clientUsername, clientPass = _clientPassword, channel = "U", langCode = "pt" }; enrollCustomerExtResponse1 response = null; await Resilience.HandleAsync(async() => { response = await _comarchService.enrollCustomerExtAsync(userContext, customer); }, "ComarchEnrollCustomerExtAsync"); if (response?.@return == null) { throw new Exception(); } return(response); }
public async Task <getBalanceResponse1> GetBalanceAsync(long customerId) { var userContext = new extUserContextView { clientLogin = _clientUsername, clientPass = _clientPassword, channel = "U", langCode = "pt" }; getBalanceResponse1 response = null; await Resilience.HandleAsync(async() => { response = await _comarchService.getBalanceAsync(userContext, customerId); }, "ComarchGetBalanceAsync"); if (response?.@return == null) { throw new Exception(); } return(response); }
/// <summary> /// Debit the points asynchronous. /// </summary> /// <param name="identifierNumber">The identifier number.</param> /// <param name="prn">The prn number.</param> /// <param name="origin">The origin.</param> /// <param name="destination">The destination.</param> /// <param name="Points">The points fro debit.</param> /// <param name="comment">The comment.</param> /// <param name="partnerTransactionNumber">The partner transaction number.</param> /// <param name="transactionDate">The transaction date.</param> /// <param name="loginPartner">The login partner.</param> /// <param name="passwordPartner">The password partner.</param> /// <returns></returns> public async Task <processDirectAirRedemptionResponse1> RedemptionPointsAsync( string identifierNumber, string prn, string origin, string destination, long inputPoints, string comment, string partnerTransactionNumber, DateTime departureDate ) { var userContext = new extUserContextView { clientLogin = _clientUsername, clientPass = _clientPassword, langCode = "pt" }; processDirectAirRedemptionResponse1 response = null; await Resilience.HandleAsync(async() => { var transactionData = new extWSDirectAirRedemptionView { identifierNo = identifierNumber, partnerTransactionNo = partnerTransactionNumber, departureDate = departureDate, pnrNo = prn, origin = origin, destination = destination, points = inputPoints, comment = comment, pointsSpecified = true }; response = await _comarchService.processDirectAirRedemptionAsync(userContext, false, true, transactionData); }, "ComarchRedemptionPoints"); if (response?.@return == null) { return(null); } return(response); }
public async Task <reverseTransactionResponse1> CancelTransactionAsync( long transactionId, string partner, string partnerTransactionNumber, string comment, string loginPartner, string passwordPartner ) { var userContext = new extUserContextView { clientLogin = loginPartner, clientPass = passwordPartner, channel = "W", langCode = "pt" }; reverseTransactionResponse1 response = null; var useLoan = false; await Resilience.HandleAsync(async() => { response = await _comarchService.reverseTransactionAsync(userContext, transactionId, partner, partnerTransactionNumber, comment, useLoan); }, "ComarchCancelTransaction"); if (response?.@return == null) { return(null); } return(response); }
/// <summary> /// Checks the <paramref name="resilience"/> to determine which resilience /// policies are enabled and adds to the <paramref name="httpClientBuilder" /> /// as appropriate. /// </summary> /// <param name="httpClientBuilder">The <see cref="IHttpClientBuilder"/> to add the policy to.</param> /// <param name="resilience">The <see cref="Resilience"/> instance with the settings for the service.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="httpClientBuilder"/> or <paramref name="resilience"/> are null.</exception> public virtual void AddResiliencePolicy(IHttpClientBuilder httpClientBuilder, Resilience resilience) { httpClientBuilder.IsNull("httpClientBuilder"); resilience.IsNull("resilience"); // Check if retry is enabled for the service if (resilience.EnableRetry) { httpClientBuilder.AddPolicyHandlerFromRegistry(ResiliencePolicy.DefaultRetry); } // Check if circuit breaking is enabled for the service if (resilience.EnableCircuitBreaking) { httpClientBuilder.AddPolicyHandlerFromRegistry(ResiliencePolicy.DefaultCircuitbreaker); } }
public override Dictionary <string, string> GetCharacterDisplayCalculationValues() { Dictionary <string, string> dict = new Dictionary <string, string>(); dict["Miss"] = Miss.ToString("F2") + "%"; dict["Dodge"] = Dodge.ToString("F2") + "%"; dict["Parry"] = Parry.ToString("F2") + "%"; dict["Armor Damage Reduction"] = (ArmorDamageReduction * 100.0f).ToString("F2") + "%"; dict["Magic Damage Reduction"] = (MagicDamageReduction * 100.0f).ToString("F2") + "%" + string.Format("*Arcane: {0:0}\n", BasicStats.ArcaneResistance) + string.Format("Fire: {0:0}\n", BasicStats.FireResistance) + string.Format("Frost: {0:0}\n", BasicStats.FrostResistance) + string.Format("Nature: {0:0}\n", BasicStats.NatureResistance) + string.Format("Shadow: {0:0}", BasicStats.ShadowResistance); dict["Total Avoidance"] = (Miss + Parry + Dodge).ToString("F2") + "%"; // Another duplicate math location. dict["Burst Time"] = String.Format("{0:0.0} sec", BurstTime); dict["Reaction Time"] = String.Format("{0:0.0} sec", ReactionTime); dict["Health"] = BasicStats.Health.ToString("F0"); dict["Armor"] = BasicStats.Armor.ToString("F0"); dict["Strength"] = BasicStats.Strength.ToString("F0"); dict["Agility"] = BasicStats.Agility.ToString("F0"); dict["Stamina"] = BasicStats.Stamina.ToString("F0"); dict["Hit Rating"] = BasicStats.HitRating.ToString("F0"); dict["Haste Rating"] = BasicStats.HasteRating.ToString("F0"); dict["Crit Rating"] = BasicStats.CritRating.ToString("F0"); dict["Physical Crit"] = (BasicStats.PhysicalCrit * 100f).ToString("F2"); dict["Expertise"] = Expertise.ToString("F0"); dict["Attack Power"] = BasicStats.AttackPower.ToString("F0"); dict["Armor Penetration"] = (BasicStats.ArmorPenetration * 100f).ToString("F2") + "%"; dict["Armor Penetration Rating"] = BasicStats.ArmorPenetrationRating.ToString("F0"); dict["DPS"] = DPS.ToString("F0"); dict["Rotation Time"] = String.Format("{0:0.00} sec", (RotationTime / 1000)); dict["Total Threat"] = TotalThreat.ToString("F0"); #region Rune Strike Limit dict["RS Limited"] = ""; if (RSLimit == (int)RSState.Good) { dict["RS Limited"] = "none"; } else { if (1 == (RSLimit & (int)RSState.TimeStarved)) { dict["RS Limited"] += "Swing Starved "; } if (1 == (RSLimit & (int)RSState.RPStarved)) { dict["RS Limited"] += "RP Starved "; } } #endregion #region Ability Costs dict["Blood"] = Blood.ToString("F0"); dict["Frost"] = Frost.ToString("F0"); dict["Unholy"] = Unholy.ToString("F0"); dict["Death"] = Death.ToString("F0"); dict["Runic Power"] = RP.ToString("F0"); #endregion dict["Overall Points"] = OverallPoints.ToString("F1"); dict["Mitigation Points"] = String.Format("{0:0.0}", (Mitigation * MitigationWeight)); // Modified Mitigation. dict["Survival Points"] = String.Format("{0:0.0}", (Survival * SurvivalWeight)) + string.Format("*Physical:{0:0.0}\n", (PhysicalSurvival * SurvivalWeight)) + string.Format("Bleed:{0:0.0}\n", (BleedSurvival * SurvivalWeight)) + string.Format("Magic:{0:0.0}", (MagicSurvival * SurvivalWeight)); // Modified Survival dict["Threat Points"] = String.Format("{0:0.0}", (Threat * ThreatWeight)); // Modified Threat dict["Crit"] = Crit.ToString("F2"); dict["Defense"] = Defense.ToString("F0"); dict["Resilience"] = Resilience.ToString("F0"); dict["Defense Rating"] = DefenseRating.ToString("F0"); dict["Defense Rating needed"] = DefenseRatingNeeded.ToString("F0"); dict["Target Miss"] = (TargetMiss * 100.0f).ToString("F1") + "%"; dict["Target Dodge"] = (TargetDodge * 100.0f).ToString("F1") + "%"; dict["Target Parry"] = (TargetParry * 100.0f).ToString("F1") + "%"; return(dict); }