private string AdjustString(string str, Player player, List <Player> party) { string res = str.Replace(ThisPlayer, player.Name); if (res.Contains(RelatedPlayer)) { RelationTag relTag = (RelationTag)RequiredTags.FirstOrDefault(t => t is RelationTag); RelationTag tag = (RelationTag)player.Tags .FirstOrDefault(t => t is RelationTag && string.Compare(t.Name, relTag.Name, true) == 0); if (tag != null) { res = res.Replace(RelatedPlayer, party.FirstOrDefault(p => p.ID == tag.RelatesToID)?.Name); } } int playerRelativeIndex = 0; var restOfParty = party.Where(p => p.ID != player.ID); while (res.Contains(OtherPlayer)) { if (!res.Contains(OtherPlayer + (playerRelativeIndex + 1).ToString())) { Console.WriteLine(OtherPlayer + (playerRelativeIndex + 1).ToString()); throw new Exception($"{OtherPlayer}-tag used incorrectly, expected to find {OtherPlayer}{(playerRelativeIndex + 1)}"); } else { res = res.Replace(OtherPlayer + (playerRelativeIndex + 1).ToString(), restOfParty.ElementAt(playerRelativeIndex).Name); } playerRelativeIndex++; } return(res); }
public override void Curate(Package galleryPackage, INupkg nugetPackage, bool commitChanges) { // Make sure the target feed exists CuratedFeed feed = GetService <ICuratedFeedService>().GetFeedByName(CuratedFeedName, includePackages: true); if (feed != null && galleryPackage.Tags != null) { // Break the tags up so we can be sure we don't catch any partial matches (i.e. "foobar" when we're looking for "foo") string[] tags = galleryPackage.Tags.Split(); // Check if this package should be curated if (tags.Any(tag => RequiredTags.Contains(tag, StringComparer.OrdinalIgnoreCase))) { // It should! // But now we need to ensure that the package's dependencies are also curated if (DependenciesAreCurated(galleryPackage, feed)) { GetService <ICuratedFeedService>().CreatedCuratedPackage( feed, galleryPackage.PackageRegistration, automaticallyCurated: true, commitChanges: commitChanges); } } } }
private bool HasTags(Event @event) { var eventTags = @event.EventTags .Select(eventTag => eventTag.Tag.Name); return(RequiredTags == null || RequiredTags .All(filterTag => eventTags .Contains(filterTag))); }
} //null means that we return only cards which have no tag (we exclude all tags) public async Task CheckValidityAsync(CallContext callContext) { if (QueryValidationHelper.IsReservedGuid(UserId)) { throw new RequestInputException("Invalid user id"); } if (ExcludedDeck != Guid.Empty) { var deck = callContext.DbContext.Decks.Include(d => d.Owner).SingleOrDefault(d => d.Id == ExcludedDeck); if (deck == null) { throw new RequestInputException($"Invalid deck id '{ExcludedDeck}'"); } if (deck.Owner.Id != UserId) { throw new RequestInputException($"Deck not allowed for user '{UserId}': '{ExcludedDeck}'"); } } if (ExcludedTags != null) { foreach (var excludedTag in ExcludedTags) { if (!await callContext.DbContext.Tags.AnyAsync(t => t.Id == excludedTag)) { throw new RequestInputException($"Invalid excluded tag id '{excludedTag}'"); } } if (ExcludedTags.GroupBy(guid => guid).Where(guid => guid.Count() > 1).Any()) { throw new RequestInputException("Excluded tag list contains duplicate"); } } foreach (var requiredTag in RequiredTags) { if (!callContext.DbContext.Tags.Any(t => t.Id == requiredTag)) { throw new RequestInputException($"Invalid required tag id '{requiredTag}'"); } } if (RequiredTags.GroupBy(guid => guid).Where(guid => guid.Count() > 1).Any()) { throw new RequestInputException("Required tag list contains duplicate"); } int userSubscriptionsCount = callContext.DbContext.SearchSubscriptions.Count(s => s.UserId == UserId); if (userSubscriptionsCount >= MaxSubscriptionCount) { throw new RequestInputException($"User already has {userSubscriptionsCount} subscriptions, can not have more than {MaxSubscriptionCount}"); } }
private void LoadRequiredTags() { chkTagChessVariant.Checked = RequiredTags.Contains("Chess Variant"); chkTagDifferentArmies.Checked = RequiredTags.Contains("Different Armies"); chkTagHistoric.Checked = RequiredTags.Contains("Historic"); chkTagMultipleBoards.Checked = RequiredTags.Contains("Multiple Boards"); chkTagPopular.Checked = RequiredTags.Contains("Popular"); chkTagRandomArray.Checked = RequiredTags.Contains("Random Array"); chkTagRegional.Checked = RequiredTags.Contains("Regional"); chkTagMultiMove.Checked = RequiredTags.Contains("Multi-Move"); }
public override void Curate(Package galleryPackage, IPackage nugetPackage) { // Make sure the target feed exists CuratedFeed feed = GetService <ICuratedFeedByNameQuery>().Execute(CuratedFeedName, includePackages: false); if (feed != null && galleryPackage.Tags != null) { // Break the tags up so we can be sure we don't catch any partial matches (i.e. "foobar" when we're looking for "foo") string[] tags = galleryPackage.Tags.Split(); // Check if this package should be curated if (tags.Any(tag => RequiredTags.Contains(tag, StringComparer.OrdinalIgnoreCase))) { // It should! Add it to the curated feed GetService <ICreateCuratedPackageCommand>().Execute( feed.Key, galleryPackage.PackageRegistration.Key, automaticallyCurated: true); } } }
private void SaveRequiredTags() { RequiredTags.Clear(); if (chkTagChessVariant.Checked) { RequiredTags.Add("Chess Variant"); } if (chkTagDifferentArmies.Checked) { RequiredTags.Add("Different Armies"); } if (chkTagHistoric.Checked) { RequiredTags.Add("Historic"); } if (chkTagMultipleBoards.Checked) { RequiredTags.Add("Multiple Boards"); } if (chkTagPopular.Checked) { RequiredTags.Add("Popular"); } if (chkTagRandomArray.Checked) { RequiredTags.Add("Random Array"); } if (chkTagRegional.Checked) { RequiredTags.Add("Regional"); } if (chkTagMultiMove.Checked) { RequiredTags.Add("Multi-Move"); } }
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 static Act CreateEquipmentCheckAct(CreatureAI Agent, String Slot, EquipmentFallback Fallback, params String[] RequiredTags) { if (!Agent.Stats.CurrentClass.RequiresTools) { return(new Condition(() => true)); } if (Agent.Creature.Equipment.HasValue(out var equipment)) { return(new Sequence( new Select( new Condition(() => { // We aren't holding anything! Great. if (!equipment.GetItemInSlot(Slot).HasValue()) { return true; } if (equipment.GetItemInSlot(Slot).HasValue(out var item) && item.ResourceType.HasValue(out var res) && res.Tags.Any(t => RequiredTags.Contains(t))) { return true; } Agent.Blackboard.SetData("item-to-remove", item); return false; // We need to remove this tool! }), new UnequipAct(Agent) { BlackboardEntry = "item-to-remove" }), new Select( new Condition(() => { var equipped = equipment.GetItemInSlot(Slot); // If the equipped tool already matches. We shouldn't get here as the tool should already have been removed. if (equipped.HasValue(out var item) && item.ResourceType.HasValue(out var res)) { if (res.Tags.Any(t => RequiredTags.Contains(t))) { return true; } } // If the default is allowed, we do not already have a tool, and no tool is available - use default. // It is assumed that the enclosing act will see that the equiped item is null and properly use the default. if (Fallback == EquipmentFallback.AllowDefault && !equipment.GetItemInSlot(Slot).HasValue()) { if (!Agent.World.GetFirstStockpileContainingResourceWithMatchingTag(RequiredTags.ToList()).HasValue) { return true; } } return false; }), new Sequence( new GetAnySingleMatchingResourceAct(Agent, RequiredTags.ToList()) { BlackboardEntry = "tool-stashed" }, new EquipAct(Agent) { BlackboardEntry = "tool-stashed" } )))); } else { Debugger.RaiseDebugWarning("Encountered entity that requires tools but does not have an equipment component."); return(new Condition(() => false)); } }
private bool HasTags(EventViewModel @event) { return(RequiredTags == null || RequiredTags .All(requiredTag => @event.Tags.Contains(requiredTag))); }