internal void DisplayShop() { if (ConditionChecking.CheckConditions(ShopPack.When)) { //get animal stock each time to refresh requirement checks UpdateShopAnimalStock(); ModEntry.SourceLocation = Game1.currentLocation; Game1.activeClickableMenu = new PurchaseAnimalsMenu(ShopAnimalStock); } else if (ShopPack.ClosedMessage != null) { Game1.activeClickableMenu = new DialogueBox(ShopPack.ClosedMessage); } }
public void DisplayShop() { ModEntry.monitor.Log($"Atempting to open the shop \"{ShopName}\""); if (ConditionChecking.CheckConditions(OpenConditions)) { int currency = 0; switch (StoreCurrency) { case "festivalScore": currency = 1; break; case "clubCoins": currency = 2; break; } var ShopMenu = new ShopMenu(ItemPriceAndStock, currency: currency); if (CategoriesToSellHere != null) { ShopMenu.categoriesToSellHere = CategoriesToSellHere; } if (Portrait != null) { ShopMenu.portraitPerson = new NPC { Portrait = Portrait }; } if (Quote != null) { ShopMenu.potraitPersonDialogue = Game1.parseText(Quote, Game1.dialogueFont, 304); } Game1.activeClickableMenu = ShopMenu; } else if (ClosedMessage != null) { Game1.activeClickableMenu = new DialogueBox(ClosedMessage); } }
public void UpdateItemPriceAndStock() { ModEntry.monitor.Log($"Generating stock for {ShopName}", LogLevel.Debug); //list of all items from this ItemStock ItemPriceAndStock = new Dictionary <ISalable, int[]>(); foreach (ItemStock Inventory in ItemStocks) { if (Inventory.When != null && !ConditionChecking.CheckConditions(Inventory.When)) { continue; } if (Inventory.ItemType != "Seed" && !ObjectInfoSource.ContainsKey(Inventory.ItemType)) { ModEntry.monitor.Log($" \"{Inventory.ItemType}\" is not a valid ItemType. Some items will not be added.", LogLevel.Warn); continue; } int CurrencyItemID = GetIndexByName(Inventory.StockItemCurrency, Game1.objectInformation); int CurrencyItemStack = Inventory.StockCurrencyStack; Dictionary <ISalable, int[]> ItemStockInventory = new Dictionary <ISalable, int[]>(); //StockPrice overrides ShopPrice int Price = Inventory.StockPrice; if (Price == -1) { Price = ShopPrice; } //add in all items specified by index if (Inventory.ItemIDs != null) { foreach (var ItemID in Inventory.ItemIDs) { AddItem(Inventory.ItemType, Inventory.IsRecipe, ItemID, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } //add in all items specified by name if (Inventory.ItemNames != null) { foreach (var ItemName in Inventory.ItemNames) { AddItem(Inventory.ItemType, Inventory.IsRecipe, ItemName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } if (Inventory.JAPacks != null && ModEntry.JsonAssets != null) { //add in all items from specified JA packs foreach (var JAPack in Inventory.JAPacks) { ModEntry.monitor.Log($"Adding objects from JA pack {JAPack}", LogLevel.Trace); if (Inventory.ItemType == "Seed") { //add seeds var ObjectData = Game1.objectInformation; var CropData = ModEntry.helper.Content.Load <Dictionary <int, string> >(@"Data/Crops", ContentSource.GameContent); var attemptToGetPack = ModEntry.JsonAssets.GetAllCropsFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string ItemName in attemptToGetPack) { var CropID = ModEntry.JsonAssets.GetCropId(ItemName); foreach (KeyValuePair <int, string> kvp in CropData) { //find the crop id in crop information to get seed id Int32.TryParse(kvp.Value.Split('/')[2], out int id); if (CropID == id) { AddItem("Object", false, kvp.Key, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } } } else { ModEntry.monitor.Log($"No Crops from {JAPack} could be found. No seeds are added.", LogLevel.Trace); } //add tree saplings var FruitTreeData = ModEntry.helper.Content.Load <Dictionary <int, string> >(@"Data/fruitTrees", ContentSource.GameContent); attemptToGetPack = ModEntry.JsonAssets.GetAllFruitTreesFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string ItemName in attemptToGetPack) { var TreeID = ModEntry.JsonAssets.GetFruitTreeId(ItemName); foreach (KeyValuePair <int, string> kvp in FruitTreeData) { //find the tree id in fruitTrees information to get sapling id Int32.TryParse(kvp.Value.Split('/')[0], out int id); if (TreeID == id) { AddItem("Object", Inventory.IsRecipe, kvp.Key, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } } } else { ModEntry.monitor.Log($"No Trees from {JAPack} could not be found. No saplings are added.", LogLevel.Trace); } } else if (Inventory.ItemType == "Object") { //add all other objects from the JA pack var attemptToGetPack = ModEntry.JsonAssets.GetAllObjectsFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string ItemName in attemptToGetPack) { AddItem(Inventory.ItemType, Inventory.IsRecipe, ItemName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } else { ModEntry.monitor.Log($"No Objects from {JAPack} could be found. No items are added.", LogLevel.Trace); } } else if (Inventory.ItemType == "BigCraftable") { var attemptToGetPack = ModEntry.JsonAssets.GetAllBigCraftablesFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string CraftableName in attemptToGetPack) { AddItem(Inventory.ItemType, Inventory.IsRecipe, CraftableName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } else { ModEntry.monitor.Log($"No BigCraftable from {JAPack} could be found. No items are added.", LogLevel.Trace); } } else if (Inventory.ItemType == "Hat") { var attemptToGetPack = ModEntry.JsonAssets.GetAllHatsFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string HatName in attemptToGetPack) { AddItem(Inventory.ItemType, false, HatName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } else { ModEntry.monitor.Log($"No Hats from {JAPack} could be found. No items are added.", LogLevel.Trace); } } else if (Inventory.ItemType == "Weapon") { var attemptToGetPack = ModEntry.JsonAssets.GetAllWeaponsFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string WeaponName in attemptToGetPack) { AddItem(Inventory.ItemType, false, WeaponName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } else { ModEntry.monitor.Log($"No Weapons from {JAPack} could be found. No items are added.", LogLevel.Trace); } } else if (Inventory.ItemType == "Clothing") { var attemptToGetPack = ModEntry.JsonAssets.GetAllClothingFromContentPack(JAPack); if (attemptToGetPack != null) { foreach (string ClothingName in ModEntry.JsonAssets.GetAllClothingFromContentPack(JAPack)) { AddItem(Inventory.ItemType, false, ClothingName, Price, Inventory.Stock, ItemStockInventory, CurrencyItemID, CurrencyItemStack); } } else { ModEntry.monitor.Log($"No Clothing from {JAPack} could be found. No items are added.", LogLevel.Trace); } } } } //randomly reduce the ItemStock's inventory to the specified MaxNumItemsSoldInItemStock RandomizeStock(ItemStockInventory, Inventory.MaxNumItemsSoldInItemStock); AddToItemPriceAndStock(ItemStockInventory); } //randomly reduce store's entire inventory to the specified MaxNumItemsSoldInStore RandomizeStock(ItemPriceAndStock, MaxNumItemsSoldInStore); }