public void Init() { sourceFile = TestContext.CurrentContext.TestDirectory + @"/res/test-xlrp-store-content.xlsx"; settings = JsonHelpers.DeserializeFile( TestContext.CurrentContext.TestDirectory + @"/res/test-settings.json"); procGenSettings = settings["Procedurally Generate Store Contents"] .ToObject <ProcGenStoreContentFeatureSettings>(); }
public List <ProcGenStoreItem> GenerateItemsForStore(Shop.ShopType shopType, string starSystemName, string ownerName, DateTime currentDate, List <string> planetTags, List <ProcGenStoreContentFeatureSettings.PlanetTagModifier> planetTagModifiers, ProcGenStoreContentFeatureSettings settings) { _logger.Debug($"Generating shop inventory for [{starSystemName} - {shopType.ToString()} - {ownerName}]..."); var potentialInventoryItems = IdentifyPotentialInventoryItems(shopType, ownerName, planetTags, currentDate, settings); _logger.Debug( $"Potential Inventory Items = {string.Join("\r\n", potentialInventoryItems.Select(item => $"[{item.StoreItem.Id}] - Bonus [{item.BracketBonus}]"))}"); var storeInventory = ProduceStoreInventoryFromPotentialItemList(shopType, ownerName, currentDate, settings, planetTagModifiers, potentialInventoryItems); _logger.Debug( $"Final Inventory Items = \r\n{string.Join("\r\n", storeInventory.Select(item => $"{item.Id} @ {item.Quantity} units"))}"); return(storeInventory); }
public (bool result, int bracketBonus) IsValidForAppearance(DateTime currentDate, string ownerValueName, Shop.ShopType shopType, List <string> planetTags, ProcGenStoreContentFeatureSettings settings) { // Check tags... if (RequiredTags.Any()) { // Check at least one required tag is present... // Unless we're populating a black market, and they're configured to circumvent required restrictions... if (RequiredTags.Any() && !planetTags.Any(s => RequiredTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRequiredPlanetTags)) { return(false, 0); } } if (RestrictedTags.Any() && planetTags.Any(s => RestrictedTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRestrictedPlanetTags)) { return(false, 0); } if (MinAppearanceDate.HasValue && MinAppearanceDate > currentDate) { return(false, 0); } if (!Purchasable) { return(false, 0); } return(true, 0); }
public (bool result, int bracketBonus) IsValidForAppearance(DateTime currentDate, string ownerValueName, Shop.ShopType shopType, List <string> planetTags, ProcGenStoreContentFeatureSettings settings) { // Check tags... if (RequiredPlanetTags.Any()) { // Check at least one required tag is present... // Unless we're populating a black market, and they're configured to circumvent required restrictions... if (RequiredPlanetTags.Any() && !planetTags.Any(s => RequiredPlanetTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRequiredPlanetTags)) { return(false, 0); } } if (RestrictedPlanetTags.Any() && planetTags.Any(s => RestrictedPlanetTags.Contains(s)) && !(shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventRestrictedPlanetTags)) { return(false, 0); } var wasPrototypedByOwner = PrototypeDate != null && ownerValueName == PrototypeFaction; var wasProducedByOwner = ProductionDate != null && ownerValueName == ProductionFaction; var wentExtinct = ExtinctionDate != null; var wasReintroduced = ReintroductionDate != null || CommonDate != null; var wasReintroducedByOwner = wasReintroduced && ownerValueName == ReintroductionFaction; var isNowCommon = CommonDate == null ? false : currentDate >= CommonDate; // Careful... if it has no reintro details, we're inferring it was made common without having reintro, hence order of testing is important... if (wentExtinct && currentDate >= ExtinctionDate) { if (isNowCommon) { return(true, 0); } if (wasReintroduced && currentDate >= ReintroductionDate) { if (wasReintroducedByOwner) { return(true, 2); } if (shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions) { return(true, 0); } } // Went extinct, and was either never reintroduced by the owner, or never went common (Skipped reintro) return(false, 0); } // Check prototype and production parameters... if (PrototypeDate == null && ProductionDate == null) { if (CommonDate == null) { return(true, 0); } // Never went extinct, has no prototype or production date. If it's now common, return true with a bracket roll bonus, else fall through to false. return(isNowCommon, 2); } if (PrototypeDate != null) { if (currentDate < PrototypeDate) { // Before it was ever prototyped... return(false, 0); } if (ProductionDate != null && currentDate >= ProductionDate) { // It was prototyped and subsequently produced, or it went common if (!isNowCommon) { // Not common yet, not produced by owner, but black market stores can circumvent that requirement... if (!wasProducedByOwner && shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions) { return(true, 0); } // Not common yet, but produced by owner... return(wasProducedByOwner, 2); } // It's now common return(true, 2); } // We're in the prototype period, the item was not produced by the owner, but blackmarkets can circumvent that (maybe)... if (!wasPrototypedByOwner && shopType == Shop.ShopType.BlackMarket && settings.BlackMarketSettings.CircumventFactionRestrictions) { return(true, 0); } // We're in the prototype period, return true if the owner of the store is the prototype agent... return(wasPrototypedByOwner, 2); } // No valid periods or matching owners... return(false, 0); }
private List <ProcGenStoreItem> ProduceStoreInventoryFromPotentialItemList(Shop.ShopType shopType, string ownerName, DateTime currentDate, ProcGenStoreContentFeatureSettings settings, List <ProcGenStoreContentFeatureSettings.PlanetTagModifier> planetTagModifiers, List <(ProcGenStoreItem StoreItem, int BracketBonus)> potentialInventoryItems)