55
66public static class ChallengeRequirementManager
77{
8- public static Dictionary < string , MinEffectGroup > ChallengeRequirements =
9- new Dictionary < string , MinEffectGroup > ( ) ;
10-
11- public static void AddRequirements ( string id , XElement _element )
12- {
13- if ( _element == null ) return ;
14- if ( string . IsNullOrEmpty ( id ) ) return ;
15- //
16- // MinEffectGroup minEffectGroup = null;
17- // List<IRequirement> list = null;
18- //
19- // foreach (var e in _element.Elements())
20- // {
21- // if (e.Name == "requirement")
22- // {
23- // if (minEffectGroup == null)
24- // {
25- // minEffectGroup = new MinEffectGroup();
26- // }
27- // IRequirement requirement = RequirementBase.ParseRequirement(e);
28- // if (requirement != null)
29- // {
30- // if (list == null)
31- // {
32- // list = new List<IRequirement>();
33- // }
34- // list.Add(requirement);
35- // }
36- // }
37- // }
38- // if ( list?.Count == 0) return;
39- // RequirementGroup.Op op = RequirementGroup.Op.And;
40- //
41- // minEffectGroup.Requirements = new RequirementGroup(op, list);
42- // minEffectGroup.Requirements = RequirementBase.ParseRequirementGroup(_element);
43- // if ( minEffectGroup.Requirements?.groups == null) return;
44- // // foreach (XElement childElement in _element.Elements())
45- // // {
46- // // if (childElement.Name.LocalName.EqualsCaseInsensitive("requirements"))
47- // // {
48- // // if (childElement.HasAttribute("compare_type"))
49- // // {
50- // // minEffectGroup.OrCompareRequirements = childElement.GetAttribute("compare_type").EqualsCaseInsensitive("or");
51- // // }
52- // //
53- // // minEffectGroup.Requirements.AddRange(RequirementBase.ParseRequirements(childElement));
54- // // }
55- // // else if (childElement.Name.LocalName.EqualsCaseInsensitive("requirement"))
56- // // {
57- // // minEffectGroup.Requirements.Add(RequirementBase.ParseRequirement(childElement));
58- // // }
59- // // }
60- //
61- // if (minEffectGroup.Requirements.groups.Count > 0)
62- // {
63- // ChallengeRequirements.TryAdd(id.ToLower(), minEffectGroup);
64- // }
65- }
8+
669
6710 public static bool IsValid ( string id , ChallengeClass challengeClass = null , MinEventParams minEventContext = null )
6811 {
69- // if (!ChallengeRequirements.TryGetValue(id.ToLower(), out var minEffectGroup))
70- // {
71- // return true;
72- // }
73-
12+
7413 if ( challengeClass == null )
7514 {
7615 challengeClass = ChallengeClass . GetChallenge ( id ) ;
@@ -89,45 +28,15 @@ public static bool IsValid(string id, ChallengeClass challengeClass = null, MinE
8928 if ( challengeClass . Effects ? . EffectGroups == null ) return true ;
9029 foreach ( var group in challengeClass . Effects . EffectGroups )
9130 {
92- Debug . Log ( $ "Group: { group . ToString ( ) } ") ;
9331 if ( ! group . canRun ( minEventContext ) )
9432 {
95- Debug . Log ( "Cannot Run." ) ;
9633 return false ;
9734 }
9835
9936 }
100- // if (canRun(minEffectGroup, minEventContext))
101- // return true;
37+
10238 return true ;
10339 }
10440
105- private static bool canRun ( MinEffectGroup minEffectGroup , MinEventParams pParams )
106- {
107-
108- if ( minEffectGroup . Requirements == null ) return true ;
109- return minEffectGroup . Requirements . IsValid ( pParams ) ;
110- // if (minEffectGroup.OrCompareRequirements)
111- // {
112- // foreach (var t in minEffectGroup.Requirements)
113- // {
114- // if (t.IsValid(pParams))
115- // {
116- // return true;
117- // }
118- // }
119- //
120- // return false;
121- // }
122- //
123- // for (var j = 0; j < minEffectGroup.Requirements.Count; j++)
124- // {
125- // if (!minEffectGroup.Requirements[j].IsValid(pParams))
126- // {
127- // return false;
128- // }
129- // }
130- //
131- // return true;
132- }
41+
13342}
0 commit comments