private void newShopToolStripMenuItem_Click(object sender, EventArgs e) { using (NewShop dialog = new NewShop(this)) { dialog.ShowDialog(this); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { grd_shopinfo.DataSource = NewShop.GetShopInfo(); grd_shopinfo.DataBind(); } }
public async Task <IActionResult> AddNewShop(NewShop newshop) { await newshop.addShop(_context); // TempData TempData["Message"] = "shop"; return(RedirectToAction("Index")); }
public void RefreshStore(Hashtable hashTable) { List <int> hashKeys = new List <int>(); List <NewShopList> hashValues = new List <NewShopList>(); foreach (DictionaryEntry item in hashTable) { hashKeys.Add((int)item.Key); hashValues.Add((NewShopList)item.Value); } for (int i = 0; i < hashValues.Count; i++) { NewShopList nsl = hashValues[i]; BaseStore bs; if (m_StoreList.Count < hashValues.Count) { bs = new BaseStore(); m_StoreList.Add(bs); } else { bs = m_StoreList[i]; } bs.MStoreId = hashKeys[i]; bs.MRefreshTime = (int)nsl.lasttime; bs.MRefreshCount = nsl.refreshnum; List <NewShop> temp = nsl.shoplist.ToList <NewShop>(); for (int j = 0; j < temp.Count; j++) { NewShop ns = temp[j]; Goods gs; if (bs.MGoodsList.Count < temp.Count) { gs = new Goods(); bs.MGoodsList.Add(gs); } else { gs = bs.MGoodsList[j]; } gs.MTabelId = ns.itemid; gs.MCosId = ns.costtype; gs.MPrice = ns.price; gs.MNumbar = ns.num; gs.MIsbuy = ns.isbuy; } } }
private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e) { // Add Augmentors items to the shop's stock if (e.NewMenu is ShopMenu NewShop && IsTravellingMerchantShop(NewShop)) { if (TodaysStock == null) { TodaysStock = new Dictionary <ISalable, int[]>(); // Pick the Augmentor types that will be sold today int NumTypes = Augmentor.WeightedRound(UserConfig.ShopSettings.NumAugmentorTypesInShop); List <AugmentorConfig> ChosenTypes = new List <AugmentorConfig>(); List <AugmentorConfig> RemainingTypes = new List <AugmentorConfig>(UserConfig.AugmentorConfigs); while (ChosenTypes.Count < NumTypes && RemainingTypes.Any()) { int TotalWeight = RemainingTypes.Sum(x => x.ShopAppearanceWeight); int ChosenWeight = Augmentor.Randomizer.Next(TotalWeight); // EX: If the remaining types had weights = { 3, 6, 2 }, picks random number from 0 to 10 inclusive. // Then the first is selected if ChosenWeight is 0-2 (3/11 chance), second is selected if 3-8 (6/11 chance), third is selected if 9-10 (2/11 chance) int CurrentSum = 0; for (int i = 0; i < RemainingTypes.Count; i++) { AugmentorConfig CurrentConfig = RemainingTypes[i]; CurrentSum += CurrentConfig.ShopAppearanceWeight; if (ChosenWeight < CurrentSum) { ChosenTypes.Add(CurrentConfig); RemainingTypes.RemoveAt(i); break; } } } // Add each type to today's stock foreach (AugmentorConfig Config in ChosenTypes) { // Compute price double BasePrice = Config.BasePrice * UserConfig.GlobalPriceMultiplier; double Price = BasePrice; if (UserConfig.ShopSettings.PriceDeviationRolls > 0) { double MinMultiplier = 1.0 - UserConfig.ShopSettings.PriceDeviation; double MaxMultiplier = 1.0 + UserConfig.ShopSettings.PriceDeviation; double Multiplier = Enumerable.Range(0, UserConfig.ShopSettings.PriceDeviationRolls).Select(x => Augmentor.GetRandomNumber(MinMultiplier, MaxMultiplier)).Average(); Price = Math.Round(BasePrice * Multiplier, MidpointRounding.AwayFromZero); } // Compute quantity double BaseQuantityInStock = UserConfig.ShopSettings.BaseQuantityInStock; double YearMultiplier = 1.0 + (UserConfig.ShopSettings.YearShopStockMultiplierBonus * (Game1.Date.Year - 1)); double DesiredValue = BaseQuantityInStock * Config.ShopStockMultiplier * YearMultiplier; int QuantityInStock = Math.Max(1, Augmentor.WeightedRound(DesiredValue)); Augmentor SellableInstance = Augmentor.CreateInstance(Config.AugmentorType, 1); TodaysStock.Add(SellableInstance, new int[] { (int)Price, QuantityInStock }); } } // Add today's stock to the shop if (TodaysStock.Any()) { Dictionary <ISalable, int[]> Stock = NewShop.itemPriceAndStock; foreach (KeyValuePair <ISalable, int[]> Item in TodaysStock) { if (Item.Value[1] > 0 && !Stock.ContainsKey(Item.Key)) { Stock.Add(Item.Key, Item.Value); } } NewShop.setItemPriceAndStock(Stock); } } }