//------------------------------------------------------------- public static Money operator -(Money money1, Money money2) { CurrencyTypes currencyTypeOfTwoObjects = GetCurrencyOfTwoObjects(money1, money2); double ratio = ConvertionRatio(money1.GetCurrency(), money2.GetCurrency()); return(new Money(money1.Amount - money2.Amount * ratio, currencyTypeOfTwoObjects)); }
public double Conversion(CurrencyTypes toCurrency) { if (Currency == toCurrency) return Amount; else if (Currency == CurrencyTypes.Yen) { if (toCurrency == CurrencyTypes.Dollar) return Amount/DollarToYen; else return Amount/EuroToYen; } else if (Currency == CurrencyTypes.Euro) { if (toCurrency == CurrencyTypes.Dollar) return Amount*EuroToDollar; else return Amount*EuroToYen; } else if (Currency == CurrencyTypes.Dollar) { if (toCurrency == CurrencyTypes.Euro) return Amount*DollarToEuro; else return Amount*DollarToYen; } return Amount; }
public ItemData GetWeightedRandom() { int Tier = MathHelper.WeightedRandom(tierChance).Key; EquipmentType Type = MathHelper.WeightedRandom(itemTypes).Key; CurrencyTypes cType = CurrencyTypes.NONE; //Tracer.trace("AvailableCurrencyTypes.Count: " + AvailableCurrencyTypes.Count); if (AvailableCurrencyTypes.Count > 0) { cType = AvailableCurrencyTypes[Random.Range(0, AvailableCurrencyTypes.Count - 1)]; } //Tracer.trace(cType.ToString()); List <ItemData> itemOptions = dataMan.GetItemsByLootTableFilters(Tier, Type, cType); ItemData itemData = null; if (itemOptions.Count > 0) { itemData = itemOptions[Random.Range(0, itemOptions.Count)]; } else { // No item (probably a currency choice) Tracer.traceError("No items in the tier/type list [Tier: " + Tier + "][Type: " + Type + "]"); return(null);// DataManager.Instance.itemDataList[0]; } return(itemData); }
public void Dispense(Dispense dispense) { var displayDenimonations = new DisplayDenominations(); CurrencyTypes currencyType = new CurrencyTypes(); var denomination = currencyType.FiveHundreds; if (dispense.Amount >= denomination) { var count = dispense.Amount / denomination; var remainder = dispense.Amount % denomination; if (count != 0) { displayDenimonations.Display(denomination, count); } if (remainder > 0) { _dispenser.Dispense(new Dispense { Amount = remainder }); } } else if (_dispenser != null) { _dispenser.Dispense(dispense); } }
public int GetDisenchantValue(CurrencyTypes type = CurrencyTypes.SHARDS_ITEMS_COMMON) { switch (Quality) { case ItemQuality.Magic: return(Random.Range(1, 3)); case ItemQuality.Rare: if (type == CurrencyTypes.SHARDS_ITEMS_RARE) { return(Random.Range(1, 3)); } else { return(Random.Range(3, 7)); } case ItemQuality.Unique: return(Random.Range(3, 7)); default: case ItemQuality.Common: return(Mathf.RoundToInt(Random.Range(1.5f, 7.5f) * Random.Range(1.5f, 7.5f))); } }
public void UpdateCurrency(int value, CurrencyTypes currencyType, bool isAnimateIcon) { CurrencyIcon icon = GetCurrencyLabelAndIcon(currencyType); if (icon == null || icon.label == null || icon.imageRect == null) { Tracer.traceError("MISSING-UI", "Unknown currency type, cannot update icon & label count for: " + currencyType); return; } if (icon.label.text == value.ToString()) { return; } icon.label.text = value.ToString(); if (isAnimateIcon) { //Do a subtle "bump" scale-animation to indicate value recently changed float amplitude = 0.5f; Transform trans = icon.imageRect; Sequence anim = DOTween.Sequence(); Vector2 scaleStart = new Vector2(2 - amplitude, amplitude); anim.Append(trans.DOScale(scaleStart, timeForCurrencyBump * 0.3f).SetEase(Ease.OutSine)); anim.Append(trans.DOScale(Vector2.one, timeForCurrencyBump).SetEase(Ease.OutElastic)); } }
public void BtnShardItem() { if (selectedItem == null) { return; } //selectedItem.ConvertToCommonShards(); Debug.LogError(" --- Shard Item here"); CurrencyTypes type = selectedItem.GetDisenchantType(); int value = selectedItem.GetDisenchantValue(type); CurrencyManager.Cost shards = type.ToCostObj(value); string shardInfo = shards.amount + " " + shards.type.ToString().Replace('_', ' '); string q = "Are you sure you\nwant to shard this\nitem?"; ConfirmYesNoInterface.Ask("Confirm Shards", q) .Then(answer => { if (answer != "YES") { return; } AudioManager.Instance.Play(SFX_UI.ShardsChing); DataManager.API.Currency.AddCurrency(shards) .Then(res => DataManager.API.Items.Remove(selectedItem)) .Then(res => RemoveFromInventory(selectedItem)); itemDetails.Hide(); }); }
public static bool?ShowDialog(Window owner, int gameIndex, CurrencyTypes currencyType, bool sendMode) { SendCurrencyToWindow window = new SendCurrencyToWindow(gameIndex, currencyType, sendMode); window.Owner = owner; return(window.ShowDialog()); }
public Item(string id, ItemType type, Hashtable hashItemData) { this.id = id; this.type = type; name = XMLUtils.GetString(hashItemData["Name"] as IXMLNode); textureName = XMLUtils.GetString(hashItemData["TextureName"] as IXMLNode); Hashtable costAttributes = XMLUtils.GetAttributes(hashItemData["Cost"] as IXMLNode); currencyType = (CurrencyTypes)Enum.Parse(typeof(CurrencyTypes), HashUtils.GetHashValue <string>(costAttributes, "CurrencyType", "")); cost = int.Parse(HashUtils.GetHashValue <string>(costAttributes, "Amount", "")); description = XMLUtils.GetString(hashItemData["Desc"] as IXMLNode, ""); // optional for now if (hashItemData.Contains("UnlockAtLevel")) { unlockAtLevel = XMLUtils.GetInt(hashItemData["UnlockAtLevel"] as IXMLNode, 0); } if (hashItemData.Contains("SortCategory")) { sortCategory = XMLUtils.GetInt(hashItemData["SortCategory"] as IXMLNode, 0); } if (hashItemData.Contains("Sound")) { soundUsed = XMLUtils.GetString(hashItemData["Sound"] as IXMLNode, ""); } if (hashItemData.Contains("IsSecretItem")) { isSecretItem = XMLUtils.GetBool(hashItemData["IsSecretItem"] as IXMLNode, false); } }
public AvailablePeriod(DateTime startDate, DateTime endDate, decimal amount, CurrencyTypes currency) { this.StartDate = startDate; this.EndDate = endDate; this.Amount = amount; this.Currency = currency; }
public void OfferFulfillment(MarketUser user, double value, CurrencyTypes currency) { if (currency == Currency && value > 0 && IsInMargin(value)) { Offers.Add(user, value); } }
public async Task <CurrencyValue> GetCurrencyValue(CurrencyTypes currency) { var currencyAsList = new List <CurrencyTypes> { currency }; var jsonString = await _client.GetStringAsync(BuildURL(currencyAsList)); var rootObject = JsonConvert.DeserializeObject <BankResult>(jsonString); var value = rootObject.data.dataSets[0].series._0000.observations._0[0]; var decimalValue = decimal.Parse(value); var multiplier = rootObject.data.structure.attributes.series[2].values[0].name; int multiplierInt; int.TryParse(rootObject.data.structure.attributes.series[2].values[0].id, out multiplierInt); var correctedValue = decimalValue / (decimal)Math.Pow(10, multiplierInt); DateTime observationDate; DateTime.TryParse(rootObject.data.structure.dimensions.observation[0].values[0].name, out observationDate); var returnValue = new CurrencyValue { Currency = currency, Value = decimalValue, Multiplier = multiplier, CorrectedValue = correctedValue, ObservationDate = observationDate }; return(returnValue); }
public decimal GetByType(CurrencyTypes type) { switch (type) { case CurrencyTypes.AUD: return(AUD); case CurrencyTypes.CAD: return(CAD); case CurrencyTypes.CNY: return(CNY); case CurrencyTypes.EUR: return(EUR); case CurrencyTypes.GBP: return(GBP); case CurrencyTypes.JPY: return(JPY); case CurrencyTypes.KRW: return(KRW); case CurrencyTypes.USD: return(USD); } return(0); }
public static Currency?TryCreate(string code, CurrencyTypes types) { Require.NotNull(code, nameof(code)); if (types.Contains(CurrencyTypes.Active)) { if (Codes.TryGetValue(code, out short?minorUnits)) { return(new Currency(code, minorUnits)); } } if (types.Contains(CurrencyTypes.UserDefined)) { if (UserCodes.TryGetValue(code, out short?minorUnits)) { return(new Currency(code, minorUnits)); } } // At last, we look for a withdrawn currency. if (types.Contains(CurrencyTypes.Withdrawn) && WithdrawnCodes.Contains(code)) { // For withdrawn currencies, ISO 4217 does not provide any information // concerning the minor units. See the property HasMinorCurrency for more info. return(new Currency(code, UnknownMinorUnits)); } return(null); }
protected Item(string name, int cost, CurrencyTypes currency, Category category) { Name = name; Id = Cryptography.GetStringMD5Hash(MD5.Create(), Name); Cost = cost; Currency = currency; ItemCategory = category; }
public MainPage ChangeCurrency(CurrencyTypes targetType) { CurrencyButton.Click(); IWebElement targetCurrency = driver.FindElement(By.XPath($"//a[@data-modal-header-async-url-param='changed_currency=1;selected_currency={targetType}']"), 10, 20); targetCurrency.Click(); return(this); }
private CurrencyIcon GetCurrencyLabelAndIcon(CurrencyTypes currencyType) { if (!currencyIcons.ContainsKey(currencyType)) { return(null); } return(currencyIcons[currencyType]); }
/// <summary> /// api로 환율조회 /// </summary> /// <param name="targetType"></param> /// <param name="baseType"></param> /// <returns></returns> private decimal GetExByAPI(CurrencyTypes targetType, CurrencyTypes baseType) { string reqUrl = MakeGetCurrencyURL(targetType, baseType); string responseStr = GetRequestAPI(reqUrl); LatestT responseT = JsonConvert.DeserializeObject <LatestT>(responseStr); return(GetTargetCurrency(targetType, baseType, responseT).Price); }
/// <summary> /// Constructor for specific address /// </summary> /// <param name="relatedAddress"></param> /// <param name="relatedAddressType"></param> public PriceService(string relatedAddress, CurrencyTypes relatedAddressType) { if (!string.IsNullOrEmpty(relatedAddress)) { RelatedAddress = relatedAddress; } RelatedAddressCurrency = relatedAddressType; }
public Market(ItemTypes type, CurrencyTypes currency, string name) { Name = name; PriceLevel = 100; Inflation = 1; CurrencyValue = 1; ItemType = type; ListedItems = new List <KeyValuePair <MarketUser, MarketItem> >(); }
//------------------------------------------------------------- static double ConvertionRatio(CurrencyTypes currencyType1, CurrencyTypes currencyType2) { if (currencyType1 == CurrencyTypes.EUR) { switch (currencyType2) { case CurrencyTypes.EUR: return(1); case CurrencyTypes.UAH: return(1 / EURrate); case CurrencyTypes.USD: return(USDrate / EURrate); default: throw new Exception("Unknown currency!"); } } if (currencyType1 == CurrencyTypes.UAH) { switch (currencyType2) { case CurrencyTypes.EUR: return(EURrate); case CurrencyTypes.UAH: return(1); case CurrencyTypes.USD: return(USDrate); default: throw new Exception("Unknown currency!"); } } if (currencyType1 == CurrencyTypes.USD) { switch (currencyType2) { case CurrencyTypes.EUR: return(EURrate / USDrate); case CurrencyTypes.UAH: return(USDrate); case CurrencyTypes.USD: return(1); default: throw new Exception("Unknown currency!"); } } throw new Exception("Unknown currency!"); }
/// <summary> /// Load settings. /// </summary> /// <param name="storage">Settings storage.</param> public void Load(SettingsStorage storage) { MatchRef = storage.GetValue <string>(nameof(MatchRef)); Partner = storage.GetValue <string>(nameof(Partner)); SettleCode = storage.GetValue <string>(nameof(SettleCode)); SettleDate = storage.GetValue <DateTimeOffset?>(nameof(SettleDate)); ForAccount = storage.GetValue <string>(nameof(ForAccount)); CurrencyType = storage.GetValue <CurrencyTypes>(nameof(CurrencyType)); }
private void OnChangedCurrency(int newValue, int oldValue, CurrencyTypes currencyType) { if (currencyType != CurrencyTypes.SCROLLS_IDENTIFY) { return; } UpdateButtons(); }
private void OnChangedCurrency(int newValue, int oldValue, CurrencyTypes currencyType) { if (_identifyButton == null || currencyType != CurrencyTypes.SCROLLS_IDENTIFY) { return; } _currentLootCrateItem.UpdateIdentifiedIcon(); _identifyButton.SetEnabledState(false); }
/// <summary> /// api url생성 /// </summary> /// <param name="targetType"></param> /// <param name="baseType"></param> /// <returns></returns> private static string MakeGetCurrencyURL(CurrencyTypes targetType, CurrencyTypes baseType) { StringBuilder sb = new StringBuilder(); sb.Append(ExchangeRateApiConsts.CURRENCY_API_URL); sb.Append("symbols="); sb.Append(targetType.ToString()); sb.Append("&base="); sb.Append(baseType.ToString()); return(sb.ToString()); }
public MarketOrder(Market inside, MarketUser user, MarketItem item, double desiredValue, double margin, CurrencyTypes desiredCurrency, int desiredOffers) { Market = inside; NeededItem = item; DesiredValue = desiredValue; Margin = margin; Currency = desiredCurrency; DesiredOffers = desiredOffers; Offers = new Dictionary <MarketUser, double>(); User = user; }
private void OnChangedCurrency(int newValue, int oldValue, CurrencyTypes currency) { var summonChoice = _summonButtons.Find(choice => choice.currency == currency); if (summonChoice == null) { return; } summonChoice.UpdateCounter(); }
/// <summary> /// To convert one currency to another. /// </summary> /// <param name="currencyFrom">The currency to be converted.</param> /// <param name="currencyTypeTo">The code of the target currency.</param> /// <returns>Converted currency.</returns> public static Currency Convert(this Currency currencyFrom, CurrencyTypes currencyTypeTo) { if (currencyFrom == null) { throw new ArgumentNullException(nameof(currencyFrom)); } return(new Currency { Type = currencyTypeTo, Value = currencyFrom.Value * currencyFrom.Type.Convert(currencyTypeTo) }); }
public int GetCurrencyAmount(CurrencyTypes currencyType) { foreach (CurrencyData data in currencyData) { if (data.Currency.CurrencyType == currencyType) { return(data.Amount); } } return(0); }
/// <seealso cref="TryCreate(String, CurrencyTypes)"/> public static Currency Of(string code, CurrencyTypes types) { Currency?cy = TryCreate(code, types); if (!cy.HasValue) { throw new CurrencyNotFoundException(Format.Current(Strings_Money.CurrencyNotFound_UnknownCode, code)); } return(cy.Value); }
public CurrencyData GetCurrencyData(CurrencyTypes currencyType) { foreach (CurrencyData data in currencyData) { if (data.Currency.CurrencyType == currencyType) { return(data); } } return(null); }
public double Convert(CurrencyTypes tcurrency) { if (tcurrency == Currency) { return Amount; } if (tcurrency == CurrencyTypes.Dollar) return Amount*EuroToDollarRate; else if (tcurrency == CurrencyTypes.Euro) return Amount*DollarToEuroRate; else if (Currency == CurrencyTypes.Dollar) return (Amount*DollarToEuroRate)*EuroToYenRate; return Amount*EuroToYenRate; }
/// <summary> Converts a type to the bitshares symbol. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="type"> The type. </param> /// /// <returns> type as a string. </returns> public static string ToBitsharesSymbol(CurrencyTypes type) { return type.ToString().TrimStart(kBitassetPrefix); }
/// <summary> Gets base and quote from symbol pair. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="symbolPair"> The symbol pair. </param> /// <param name="base"> [out] The base. </param> /// <param name="quote"> [out] The quote. </param> public static void GetBaseAndQuoteFromSymbolPair(string symbolPair, out CurrencyTypes @base, out CurrencyTypes quote) { @base = CurrencyHelpers.FromSymbol(symbolPair.Split('_')[0]); quote = CurrencyHelpers.FromSymbol(symbolPair.Split('_')[1]); }
/// <summary> Gets market symbol pair. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="base"> The base. </param> /// <param name="quote"> The quote. </param> /// /// <returns> The market symbol pair. </returns> public static string GetMarketSymbolPair(CurrencyTypes @base, CurrencyTypes quote) { return @base + "_" + quote; }
// 3) declare parameter constructor for properties initialization public Money(Decimal amount, CurrencyTypes currType = CurrencyTypes.UAH) { Amount = amount; CurrencyType = currType; }
public Money(double amount, CurrencyTypes currType = CurrencyTypes.UAH) : this((decimal)amount, currType) { }
public Money() { Amount = 0; CurrencyType = 0; }
public Money(int amount, CurrencyTypes type) { Amount = amount; CurrencyType = type; }
private void OnSendButtonClicked(object sender, RoutedEventArgs e) { selectedCurrency = (CurrencyTypes)Enum.Parse(typeof(CurrencyTypes), ((Button)sender).Tag as string); ((Button)sender).ContextMenu.IsOpen = true; }
private void OnSendCurrencyContextMenuOpening(object sender, ContextMenuEventArgs e) { selectedCurrency = (CurrencyTypes)Enum.Parse(typeof(CurrencyTypes), ((Button)sender).Tag as string); }
public static IBSocket SendCurrency(this IBSocket socket, CurrencyTypes? currency) { return socket.Send((currency ?? CurrencyTypes.USD).ToString()); }
public Money(CurrencyTypes curr, double amount) : this() { Currency = curr; Amount = amount; }
public Money(int _amount, CurrencyTypes _CurrencyType) { Amount = _amount; CurrencyType = _CurrencyType; }
/// <summary> Query if 'type' is bitshares asset. </summary> /// /// <remarks> Paul, 05/02/2015. </remarks> /// /// <param name="type"> The type. </param> /// /// <returns> true if bitshares asset, false if not. </returns> public static bool IsBitsharesAsset(CurrencyTypes type) { return type > CurrencyTypes.BTC; }
internal static TCurrency Get(CurrencyTypes currencyType) { return Currencies.Single(t => t.CurrencyCode == currencyType.ToString()); }
// 3) declare parameter constructor for properties initialization public Money(double amount, CurrencyTypes type) { Amount = amount; CurrencyType = type; }
// 3) declare parameter constructor for properties initialization public Money(CurrencyTypes CurType, double sum = 0.0d) { CurrencyType = CurType; Amount = sum; }
public Money(double set_Amount, CurrencyTypes set_CurrencyTypes) { Amount = set_Amount; CurrencyType = set_CurrencyTypes; }
public Money(CurrencyTypes currency, double amount) : this() { this.Currency = Currency; this.Amount = amount; }