public TakeSilverEvent(Dictionary <byte, object> parameters) : base(parameters) { ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); try { if (parameters.ContainsKey(0)) { ObjectId = parameters[0].ObjectToLong(); } if (parameters.ContainsKey(1)) { TimeStamp = parameters[1].ObjectToLong() ?? 0; } if (parameters.ContainsKey(2)) { TargetEntityId = parameters[2].ObjectToLong(); } if (parameters.ContainsKey(3)) { var yieldPreTax = parameters[3].ObjectToLong(); YieldPreTax = FixPoint.FromInternalValue(yieldPreTax ?? 0); } if (parameters.ContainsKey(5)) { var guildTax = parameters[5].ObjectToLong(); GuildTax = FixPoint.FromInternalValue(guildTax ?? 0); } if (parameters.ContainsKey(6)) { var clusterTax = parameters[6].ObjectToLong(); ClusterTax = FixPoint.FromInternalValue(clusterTax ?? 0); } if (parameters.ContainsKey(7)) { IsPremiumBonus = parameters[7] as bool? ?? false; } if (parameters.ContainsKey(8)) { var multiplier = parameters[8].ObjectToLong(); Multiplier = FixPoint.FromInternalValue(multiplier ?? 0); } YieldAfterTax = YieldPreTax - GuildTax; ClusterYieldPreTax = FixPoint.FromFloatingPointValue(YieldPreTax.DoubleValue - (YieldPreTax.DoubleValue / Multiplier.DoubleValue)); PremiumAfterTax = ClusterYieldPreTax - ClusterTax; ClusterYieldAfterTax = FixPoint.FromFloatingPointValue((ClusterYieldPreTax.DoubleValue / Multiplier.DoubleValue) - ClusterTax.DoubleValue); } catch (Exception e) { ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod().DeclaringType, e); } }
public static FixPoint GetXmlAttributeFixPoint(XmlElement xmlElement, string attributeName, FixPoint defaultValue) { if (xmlElement.HasAttribute(attributeName)) { return(FixPoint.FromFloatingPointValue(double.Parse(xmlElement.Attributes[attributeName].InnerText, CultureInfo.InvariantCulture.NumberFormat))); } return(defaultValue); }
public UpdateFameEvent(Dictionary <byte, object> parameters) : base(parameters) { ConsoleManager.WriteLineForNetworkHandler(GetType().Name, parameters); // Array[10] exist only by Crafting... try { //Debug.Print($"----- UpdateFame (Events) -----"); //foreach (var parameter in parameters) //{ // Debug.Print($"{parameter}"); //} if (parameters.ContainsKey(1)) { var totalPlayerFame = parameters[1] as long? ?? 0; TotalPlayerFame = FixPoint.FromInternalValue(totalPlayerFame); } if (parameters.ContainsKey(3)) { GroupSize = parameters[3] as byte? ?? 0; } if (parameters.ContainsKey(4)) { Multiplier = FixPoint.FromInternalValue(parameters[4].ObjectToLong() ?? 0); } if (parameters.ContainsKey(5)) { IsPremiumBonus = parameters[5] as bool? ?? false; } if (parameters.ContainsKey(6)) { BonusFactor = parameters[6] as float? ?? 1; BonusFactorInPercent = (BonusFactor - 1) * 100; IsBonusFactorActive = (BonusFactorInPercent > 0); } if (parameters.ContainsKey(2)) { var fameWithZoneMultiplier = FixPoint.FromInternalValue(parameters[2].ObjectToLong() ?? 0); FameWithZoneMultiplier = FixPoint.FromFloatingPointValue(fameWithZoneMultiplier.DoubleValue * BonusFactor); } if (parameters.ContainsKey(9)) { SatchelFame = FixPoint.FromInternalValue(parameters[9].ObjectToLong() ?? 0); } if (parameters.ContainsKey(252)) { UsedItemType = parameters[252].ObjectToInt(); } if (FameWithZoneMultiplier.DoubleValue > 0 && Multiplier.DoubleValue > 0) { var newNormalFame = FameWithZoneMultiplier.DoubleValue / Multiplier.DoubleValue * BonusFactor; NormalFame = FixPoint.FromFloatingPointValue(newNormalFame); } double fameWithZoneAndPremium = 0; if (FameWithZoneMultiplier.DoubleValue > 0) { if (IsPremiumBonus) { fameWithZoneAndPremium = FameWithZoneMultiplier.DoubleValue * 1.5f; } else { fameWithZoneAndPremium = FameWithZoneMultiplier.DoubleValue; } } if (fameWithZoneAndPremium > 0 && FameWithZoneMultiplier.DoubleValue > 0) { var newPremiumFame = fameWithZoneAndPremium - FameWithZoneMultiplier.DoubleValue; PremiumFame = FixPoint.FromFloatingPointValue(newPremiumFame); } if (FameWithZoneMultiplier.InternalValue >= NormalFame.InternalValue) { ZoneFame = FixPoint.FromFloatingPointValue(FameWithZoneMultiplier.DoubleValue - (FameWithZoneMultiplier.DoubleValue / Multiplier.DoubleValue)); } TotalGainedFame = FameWithZoneMultiplier + PremiumFame + SatchelFame; } catch (Exception e) { ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod().DeclaringType, e); } }
public FixPoint GetLastLocalEntityGuildTax(FixPoint yieldPreTax) => FixPoint.FromFloatingPointValue(yieldPreTax.DoubleValue / 100 * _lastLocalEntityGuildTaxInPercent);
public UpdateFameEvent(Dictionary <byte, object> parameters) : base(parameters) { // Array[10] exist only by Crafting... try { //Debug.Print($"----- UpdateFame (Events) -----"); //foreach (var parameter in parameters) //{ // Debug.Print($"{parameter}"); //} if (parameters.ContainsKey(1)) { var totalPlayerFame = parameters[1] as long? ?? 0; TotalPlayerFame = FixPoint.FromInternalValue(totalPlayerFame); } if (parameters.ContainsKey(2)) { Change = FixPoint.FromInternalValue(parameters[2].ObjectToLong() ?? 0); } if (parameters.ContainsKey(3)) { GroupSize = parameters[3] as byte? ?? 0; } if (parameters.ContainsKey(4)) { Multiplier = FixPoint.FromInternalValue(parameters[4].ObjectToLong() ?? 0); } if (parameters.ContainsKey(5)) { IsPremiumBonus = parameters[5] as bool? ?? false; } if (parameters.ContainsKey(6)) { BonusFactor = parameters[6] as float? ?? 0; } if (parameters.ContainsKey(9)) { SatchelFame = FixPoint.FromInternalValue(parameters[9].ObjectToLong() ?? 0); } if (parameters.ContainsKey(252)) { UsedItemType = parameters[252].ObjectToInt(); } if (Change.DoubleValue > 0 && Multiplier.DoubleValue > 0) { var newNormalFame = Change.DoubleValue / Multiplier.DoubleValue; NormalFame = FixPoint.FromFloatingPointValue(newNormalFame); } double fameWithZoneAndPremium = 0; if (Change.DoubleValue > 0) { if (IsPremiumBonus) { fameWithZoneAndPremium = Change.DoubleValue * 1.5f; } else { fameWithZoneAndPremium = Change.DoubleValue; } } if (fameWithZoneAndPremium > 0 && Change.DoubleValue > 0) { var newPremiumFame = fameWithZoneAndPremium - Change.DoubleValue; PremiumFame = FixPoint.FromFloatingPointValue(newPremiumFame); } if (Change.InternalValue >= NormalFame.InternalValue) { ZoneFame = FixPoint.FromInternalValue(Change.InternalValue - NormalFame.InternalValue); } TotalGainedFame = NormalFame + ZoneFame + PremiumFame + SatchelFame; } catch (Exception e) { Debug.Print(e.Message); } }