/// @param cost /// The cost to display /// /// @return The formatted cost string /// public static string LocaliseColouredCost(this CurrencyItem cost) { if (m_cachedBankService == null) { m_cachedBankService = GlobalDirector.Service <BankService>(); } string costString = string.Empty; if (k_currencies.Contains(cost.m_currencyID) == true) { costString = cost.LocaliseCost(); } else { if (cost.IsFree() == true) { costString = k_free.LocaliseGame(); } else { int current = Math.Min(m_cachedBankService.GetBalance(cost.m_currencyID), cost.m_value); string currentString = TextUtils.GetFormattedCurrencyString(current); string formatID = k_costFail; if (m_cachedBankService.CanAfford(cost) == true) { formatID = k_costSuccess; } costString = string.Format(formatID.LocaliseGame(), cost.m_currencyID, TextUtils.GetFormattedCurrencyString(cost.m_value), currentString); } } return(costString); }
public ActionResult GetCurrencyItem(string name) { var model = new CurrencyItem(); var query = from b in dB.BaseItems.AsQueryable() where b.ReleaseState == "released" && b.ItemClass == "StackableCurrency" && !b.ItemName.Contains("Fossil") && !b.ItemName.Contains("Essence") && !b.ItemName.Contains("Remnant") && b.ItemName != "Enchant" && b.ItemName == name select new CurrencyItem() { ItemName = b.ItemName, VisualIdentity = b.VisualIdentity, Tags = b.Tags, DropLevel = b.DropLevel, Properties = b.Properties }; model = query.FirstOrDefault(); SetImgSrc(model); SetType(model); SetProperties(model); return(View("GetCurrencyItem", model)); }
public Offer ScaledTo(Offer buyer) { if (Selling.Amount >= buyer.Buying) { _logger.Trace("Trying to call ScaleTo() on an offer that is already valid."); return(this); } var sellerAmount = Selling.Amount; var buyerAmount = buyer.Buying.Amount; var sellerBuyingAmount = Buying.Amount; var i = 1; do { sellerAmount = buyerAmount + i++; sellerBuyingAmount = sellerAmount * (Buying / Selling); }while (sellerBuyingAmount % 1 != 0); _logger.Trace($"Created new ratio of {sellerBuyingAmount} : {sellerAmount}"); var buying = new CurrencyItem(Buying, sellerBuyingAmount); var selling = new CurrencyItem(Selling, sellerAmount); _logger.Trace($"Scaled {Buying.Amount}:{Selling.Amount} to {buying.Amount}:{selling.Amount}"); return(new Offer(this, buying, selling)); }
public static List <CurrencyItem> getCE() //amazon-i url ning vastu saab List<AmazonItem> { List <CurrencyItem> ce2 = new List <CurrencyItem>(); try { string csv = readWebPage("http://rss.timegenie.com/forex.txt"); string[] rows = csv.Split('\n'); foreach (string row in rows) { if (row.Equals("")) { continue; } CurrencyItem ci = new CurrencyItem(); string[] cols = row.Split('|'); ci.CurrencyCode = cols[0]; ci.FullName = cols[1]; ci.exchangeRate = cols[2]; ce2.Add(ci); } } catch (Exception e) { err2 += e.ToString() + "\n<br />"; return(ce2); } return(ce2); }
public PartialViewResult CurrencyPartial() { List <Currency> currensies = service.GetAllCurrency().Where(c => c.CurrencyID != 1).ToList(); CurrencyModel model = new CurrencyModel(); foreach (var currency in currensies) { var item = new CurrencyItem() { Name = currency.Name, BankBuys = Math.Round(currency.Rate * 1.003) + "р", BankCells = Math.Round(currency.Rate) + "р" }; model.Rates.Add(item); } foreach (var currency in currensies) { foreach (var crossCurrency in currensies) { if (currency.CurrencyID != crossCurrency.CurrencyID) { model.CrossRates.Add(currency.ShortName + "/" + crossCurrency.ShortName, Math.Round(currency.Rate / crossCurrency.Rate, 3).ToString()); } } } return(PartialView("CurrencyPartial", model)); }
/// @param reward /// The reward to spawn /// @param position /// The position to spawn at /// @param callback /// The function to call when the ceremony is done /// public static void BankRewardScreen(CurrencyItem reward, Vector3 position, Action callback = null) { if (s_instance.Count > 0 && reward.m_value > 0) { s_instance.GetLast().SpawnRewardScreen(reward, position, true, callback); } }
public async Task CreateAsyncShouldNotCallCreateOnListingViewModelFactoryIfCancellationRequested() { // arrange var itemListingsQueryResult = new ItemListingsQueryResult { Result = new List <ListingResult> { new ListingResult(), new ListingResult() }, }; var item = new CurrencyItem(); var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; this.listingViewModelFactoryMock.Setup(x => x.CreateAsync(itemListingsQueryResult.Result[0], It.IsAny <Item>(), It.IsAny <CancellationToken>())) .Callback(() => cancellationTokenSource.Cancel()); // act ItemListingsViewModel result = await this.itemListingsViewModelFactory.CreateAsync(item, itemListingsQueryResult, cancellationToken); // assert this.listingViewModelFactoryMock.Verify(x => x.CreateAsync(It.IsAny <ListingResult>(), It.IsAny <Item>(), It.IsAny <CancellationToken>()), Times.Once); }
/// @param reward /// The reward to spawn /// @param position /// The position to spawn at /// @param callback /// The function to call when the ceremony is done /// public static void SpawnRewardWorld(CurrencyItem reward, Vector3 position, Action callback = null) { if (s_instance.Count > 0 && reward.m_value > 0) { s_instance.GetLast().SpawnRewardWorld(reward, position, false, callback); } }
public void CoinValueServiceReturnsCorrectValueForMinAndMaxEntries() { ICurrency currency = new USDCurrency(); ICoinValueService coinService = new CoinValueService(currency); CurrencyItem firstCoin = currency.GetItems()[0]; CoinValueViewModel coin; //Max weight coin = coinService.GetCoinValue(firstCoin.MaxWeight, AverageBetweenTwoValues(firstCoin.MinSize, firstCoin.MaxSize)); Assert.True(coin.IsValidCoin); Assert.True(coin.CoinValue == firstCoin.Value); //Min weight coin = coinService.GetCoinValue(firstCoin.MinWeight, AverageBetweenTwoValues(firstCoin.MinSize, firstCoin.MaxSize)); Assert.True(coin.IsValidCoin); Assert.True(coin.CoinValue == firstCoin.Value); //Max size coin = coinService.GetCoinValue(AverageBetweenTwoValues(firstCoin.MaxWeight, firstCoin.MinWeight), firstCoin.MaxSize); Assert.True(coin.IsValidCoin); Assert.True(coin.CoinValue == firstCoin.Value); //Min size coin = coinService.GetCoinValue(AverageBetweenTwoValues(firstCoin.MaxWeight, firstCoin.MinWeight), firstCoin.MinSize); Assert.True(coin.IsValidCoin); Assert.True(coin.CoinValue == firstCoin.Value); }
public static bool IsPriceCorrect(string strPrice) { if (string.IsNullOrEmpty(strPrice)) { return(false); } #if NO string strError = ""; CurrencyItem item = null; // 解析单个金额字符串。例如 CNY10.00 或 -CNY100.00/7 int nRet = PriceUtil.ParseSinglePrice(strPrice, out item, out strError); if (nRet == -1) { return(false); } return(true); #endif if (VerifyPrice(strPrice).Count > 0) { return(false); } return(true); }
private void UIButtonSave_Click(object sender, RoutedEventArgs e) { var currencyRates = new List <string>(); var currencyNames = new List <string>(); var currencyShortNames = new List <string>(); var currencyIds = new List <string>(); CurrencyItem ci = null; foreach (var el in UICurrences.Children) { ci = (el as CurrencyItem); if (!OpOp.Verifier.CheckCurrencyCoef(ci.Coef)) { UIMessage.TextMessage = OpOp.StringSource.CurrencyCoefStructureError(); return; } currencyRates.Add(ci.Coef); currencyNames.Add(ci.NameCurrency); currencyShortNames.Add(ci.ShortNameCurrency); currencyIds.Add(ci.IdCurrency); } OpOp.EditCurrencies.CurrenciesId = currencyIds; OpOp.EditCurrencies.CurrenciesRates = currencyRates; OpOp.EditCurrencies.CurrenciesNames = currencyNames; OpOp.EditCurrencies.CurrenciesShortNames = currencyShortNames; OpOp.EditCurrencies.Execute(); UIMessage.TextMessage = OpOp.EditCurrencies.Information; UICurrences.Children.Clear(); EditCurrency_Loaded(null, null); }
public bool CurrencyIsUpdated(CurrencyItem ex) { var config = new Utils().ReadTokensConnsettings(); bool dataVerification; string strConnectionString = config.GetSection("Conn:DB").Value; string sql = "SELECT COUNT(1) FROM Currencies WHERE isoCode = @isoCode " + "AND [name] = @name " + "AND [type] = @type"; using (IDbConnection conn = new SqlConnection(strConnectionString)) { var vParams = new DynamicParameters(); vParams.Add("@isoCode", ex.simbolo); vParams.Add("@name", ex.nomeFormatado); vParams.Add("@type", ex.tipoMoeda); if (conn.State == ConnectionState.Closed) { conn.Open(); } dataVerification = conn.Query <bool>(sql, vParams).FirstOrDefault(); } return(dataVerification); }
// Workaround method to set individual item properties after the fact // Select statement in the query does not support GetValueOrDefault unfortunately. private void SetProperties(CurrencyItem currency) { currency.Description = (string)currency.Properties.GetValueOrDefault("description", ""); currency.Directions = (string)currency.Properties.GetValueOrDefault("directions", ""); currency.StackSize = (int)currency.Properties.GetValueOrDefault("stack_size", 0); currency.CurrencyTabStackSize = (int)currency.Properties.GetValueOrDefault("stack_size_currency_tab", 0); }
// Slightly messy determination of currency type, utilizing name contents private void SetType(CurrencyItem currency) { if (currency.ItemName.Contains("Bestiary") || currency.ItemName.Contains(" Net") || currency.ItemName.Contains("Imprint")) { currency.ItemClass = "Bestiary"; } else if (currency.ItemName.Contains("Splinter of") || currency.ItemName.Contains("Blessing of")) { currency.ItemClass = "Breach"; } else if (currency.ItemName.Contains("Timeless")) { currency.ItemClass = "Legion"; } else if (currency.ItemName.Contains("Oil")) { currency.ItemClass = "Blight"; } else if (currency.ItemName.Contains("Vial")) { currency.ItemClass = "Incursion"; } else if ((currency.ItemName.Contains("Cartographer") || currency.ItemName.Contains("Unshaping")) && !currency.ItemName.Contains("Chisel")) { currency.ItemClass = "Atlas"; } else if (currency.ItemName == "Prophecy" || currency.ItemName == "Silver Coin") { currency.ItemClass = "Prophecy"; } else { currency.ItemClass = "Currency"; } }
private void UIButtonAddCurrencyItem_Click(object sender, RoutedEventArgs e) { var ci = new CurrencyItem { }; ci.ButtonRemove += UIButtonRemoveCurrency_Click; UICurrences.Children.Add(ci); }
public void Constructor() { var i = new CurrencyItem(CurrencyUnit.GBP, CurrencyUnit.EUR, 1.1m); Assert.AreEqual(i.Unit, CurrencyUnit.GBP); Assert.AreEqual(i.Base, CurrencyUnit.EUR); Assert.AreEqual(i.Rate, 1.1m); }
public static GetAllCurrenciesResponseModel MapToViewModel(CurrencyItem rateItem) { return(new GetAllCurrenciesResponseModel { Currency = rateItem.Currency, Value = rateItem.Value }); }
// 进行汇率计算 public CurrencyItem Exchange(CurrencyItem item) { CurrencyItem result = new CurrencyItem(); result.Value = Convert.ToDecimal(Convert.ToDouble(item.Value) * this.Target.Value / this.Source.Value); result.Prefix = this.Target.Prefix; result.Postfix = this.Target.Postfix; return(result); }
public void Clone() { var i1 = new CurrencyItem(CurrencyUnit.GBP, CurrencyUnit.EUR, 0.9m) { Stamp = new DateTime(2019, 1, 1), Description = "abc" }; Assert.AreEqual(i1, i1.Clone()); }
public void MapToQueryRequestShouldReturnExchangeQueryRequestWithChaosAsHave() { var item = new CurrencyItem(); var result = this.itemToExchangeQueryRequestMapper.MapToQueryRequest(item) as ExchangeQueryRequest; Assert.NotNull(result); Assert.That(result.Exchange.Have, Has.Count.EqualTo(1)); Assert.That(result.Exchange.Have, Has.One.EqualTo("chaos")); }
/// @param currencyItem /// The currency to display /// /// @return The formatted currency string /// public static string LocaliseFullName(this CurrencyItem currencyItem) { string textID = currencyItem.m_currencyID; if (currencyItem.m_value > 1) { var pluralID = string.Format(k_pluralFormat, currencyItem.m_currencyID); textID = pluralID; } return(textID.LocaliseGame()); }
public void GainExperienceFlatRate(CurrencyItem soul) { currentXp += soul.currencyValue; if (currentXp >= requiredXp) { LevelUp(currentXp -= requiredXp); } // Updates UI and any listeners playerEventChannel.ExperienceGained(soul.currencyValue); }
//private void RefreshUI() //{ // int i = 0; // for(; i < items.Count && i < itemSlots.Length; i++) // { // itemSlots[i].item = items[i]; // } // for(; i < itemSlots.Length; i++) // { // itemSlots[i].item = null; // } //} public bool AddItem(CurrencyItem _itemToAdd) { for (int i = 0; i < currencySlots.Length; i++) { if (currencySlots[i].currencyType == _itemToAdd.currencyType) { return(true); } } return(false); }
/// @param currencyItem /// The currency to display /// /// @return The formatted currency string /// public static string LocaliseFullNameAmount(this CurrencyItem currencyItem) { string textID = currencyItem.m_currencyID; if (currencyItem.m_value > 1) { var pluralID = string.Format(k_pluralFormat, currencyItem.m_currencyID); textID = pluralID; } return(string.Format(k_costFormat, TextUtils.GetFormattedCurrencyString(currencyItem.m_value), textID.LocaliseGame())); }
private void DoOnUpdatedCurrency(CurrencyItem aCurrencyItem) { try { this.SynchronizingObject?.Invoke(OnUpdatedCurrency, new object[] { this, aCurrencyItem }); } catch (Exception e) { DoErrorHandler(e); } }
public static CurrencyItem GetCurrencyItem(this Currency currency) { CurrencyItem ci = new CurrencyItem { Currency = currency, IsoCode = currency.ToString().ToUpper(), Symbol = CurrencyCodeMapper.IsoCodeToSymbol(currency.ToString().ToUpper()) }; return(ci); }
public void MapToQueryRequestShouldCallGetIdOnStaticItemDataService() { var item = new CurrencyItem { Name = "Scroll of Wisdom" }; this.itemToExchangeQueryRequestMapper.MapToQueryRequest(item); this.staticDataServiceMock.Verify(x => x.GetId(item.Name)); }
public void AddItem(CurrencyItem _currencyToAdd) { for (int i = 0; i < currencySlots.Length; i++) { if (currencySlots[i].currencyType == _currencyToAdd.currencyType) { currencySlots[i].currencyAmount += _currencyToAdd.currencyValue; currencySlots[i].currencyAmountText.SetText( currencySlots[i].currencyAmount.ToString()); } } }
public void EqualsFail() { var i1 = new CurrencyItem(CurrencyUnit.GBP, CurrencyUnit.EUR, 0.9m) { Stamp = new DateTime(2019, 1, 1), Description = "abc" }; var i2 = new CurrencyItem(CurrencyUnit.GBP, CurrencyUnit.USD, 0.7m) { Stamp = new DateTime(2019, 1, 1), Description = "abc" }; Assert.AreNotEqual(i1, i2); }
public void Constructor1TimeUnitWithAmountWithCurrencyItem() { var PricePerHour = new UnitPrice(2, 20, CurrencyUnit.EUR, TimeSpanUnit.Hour); var GbpToEuroRate = new CurrencyItem(CurrencyUnit.GBP, CurrencyUnit.EUR, 0.9m); var NumberOfHours = 5; var PriceOfFiveHours = new ItemPrice(PricePerHour, NumberOfHours, GbpToEuroRate); Assert.AreEqual(PriceOfFiveHours.CurrencyUnit, CurrencyUnit.GBP); Assert.AreEqual(PriceOfFiveHours.CurrencyRate, 0.9m); Assert.AreEqual(PriceOfFiveHours.Amount, 5); Assert.AreEqual(PriceOfFiveHours.ExclVAT, 9); Assert.AreEqual(PriceOfFiveHours.VAT, 1.8m); }
protected int GetCellCurrencyIndex(Excel.Range cell, CurrencyItem[] currencies) { int index = -1; string firstFormat = (string)cell.NumberFormat; //Search a match on lcid var lcidMatch = Regex.Match(firstFormat, @"\[\$[^-]+-([0-9A-F]+)\]|").Groups[1]; if (lcidMatch.Success) { int lcid = int.Parse(lcidMatch.Value, NumberStyles.HexNumber); index = currencies.Length; while (--index != -1 && currencies[index].LCID != lcid) { } if (index != -1) return index; } //Search a match on code var codeMath = Regex.Match(firstFormat, @"\[\$([A-Z]+)\]").Groups[1]; if (codeMath.Success) { string code = codeMath.Value; index = currencies.Length; while (--index != -1 && currencies[index].Code != code) { } if (index != -1) return index; } //Search a match on symbole string firstText = (string)cell.Text; var symbole = Regex.Match(firstText, @"^[^\d\+-]+|[^\d\+-]+$").Value.Trim(); if (symbole != string.Empty) { index = currencies.Length; while (--index != -1 && currencies[index].Symbole != symbole) { } } return index; }