public CustomerRequestResult getResult(AlchemyItemInstance alchemyItemInstance) { var accepted = acceptedAI.Where(ai => ai.Solutions.Contains(alchemyItemInstance.type)); if (accepted.Any()) { accepted = accepted.Where(crcc => crcc.tagValidQuery.All(q => q.ResolveQuery(alchemyItemInstance.tags))); if (accepted.Any()) { var responce = accepted.ElementAt(Random.Range(0, accepted.Count() - 1)); var defaultProgression = alwaysAddDefaultProgression || !responce.requestsProgression.Any() ? DefaultProgression : new CustomerRequest[0]; return(new CustomerRequestResult() { unlockedRequests = responce.requestsProgression .Concat(defaultProgression) .ToArray(), isAccepted = true, Responce = responce.responce == "" ? defaultResponce : responce.responce }); } } return(new CustomerRequestResult() { isAccepted = false, unlockedRequests = new CustomerRequest[0], Responce = rejectionResponce }); }
public static AlchemyItemInstance[] Craft(IEnumerable <AlchemyItemInstance> inputItems, AlchemyItemInstance RejectItem) { foreach (var s in all.Where(x => x.output == null).ToArray()) { _all.Remove(s); } var satisfy = all.Where(r => r.input.Length == inputItems.Count() && r.input.Intersect(inputItems.Select(i => i.type)).Count() == r.input.Count() ); int count = satisfy.Count(); if (count > 0) { var complexity = satisfy.Max(i => i.input.Length); TagBag b = new TagBag(); foreach (var input in inputItems) { b.UnionWith(input.tags); b.UnionWith(input.type.Tags); } foreach (var s in satisfy.Where(x => x.output == null)) { Debug.LogError(s, s); } return(satisfy.Where(i => i.input.Length == complexity).Select(i => new AlchemyItemInstance() { type = i.output, tags = b }).ToArray()); } return(new AlchemyItemInstance[] { RejectItem }); }