@@ -19,7 +19,16 @@ public class Requirements
1919 { RequirementType . FAIRY , [ RequirementType . FOUR_CONTAINERS ] } ,
2020 { RequirementType . REFLECT , [ RequirementType . FOUR_CONTAINERS ] } ,
2121 { RequirementType . SPELL , [ RequirementType . FOUR_CONTAINERS ] } ,
22- } ;
22+ } ;
23+
24+ // the magic level you have to each for each spell to be considered in-logic
25+ private static readonly Dictionary < RequirementType , int > ImplicitMagicLevelRequirements = new ( )
26+ {
27+ { RequirementType . JUMP , 3 } ,
28+ { RequirementType . FAIRY , 3 } ,
29+ { RequirementType . REFLECT , 4 } ,
30+ { RequirementType . SPELL , 4 } ,
31+ } ;
2332
2433 public RequirementType [ ] IndividualRequirements { get ; private set ; }
2534 public RequirementType [ ] [ ] CompositeRequirements { get ; private set ; }
@@ -147,6 +156,73 @@ public bool AreSatisfiedBy(IEnumerable<RequirementType> requireables, bool enfor
147156 }
148157 }
149158 return individualRequirementsSatisfied || compositeRequirementSatisfied ;
159+ }
160+
161+ public bool AreSatisfiedBy ( IEnumerable < RequirementType > requireables , StatRandomizer statRoll )
162+ {
163+ if ( IndividualRequirements . Length + CompositeRequirements . Length == 0 )
164+ {
165+ return true ;
166+ }
167+ var individualRequirementsSatisfied = false ;
168+ var requirementTypes = requireables as RequirementType [ ] ?? requireables . ToArray ( ) ;
169+
170+ statRoll . AssertHasRandomized ( ) ;
171+
172+ bool StatAdjustedContainerRequirementSatisfied ( RequirementType requirement )
173+ {
174+ if ( ImplicitMagicLevelRequirements . ContainsKey ( requirement ) )
175+ {
176+ Collectable collectable = requirement . AsCollectable ( ) ! . Value ;
177+ var requiredLevel = ImplicitMagicLevelRequirements [ requirement ] ;
178+ var magicCost = statRoll . GetSpellCost ( collectable , requiredLevel ) ;
179+ var containerRequirement = MagicContainerRequirementFromCost ( magicCost ) ;
180+ return requirementTypes . Contains ( containerRequirement ) ;
181+ }
182+ else
183+ {
184+ return true ;
185+ }
186+ }
187+
188+ foreach ( var requirement in IndividualRequirements )
189+ {
190+ if ( requirementTypes . Contains ( requirement ) )
191+ {
192+ individualRequirementsSatisfied = true ;
193+ if ( ! StatAdjustedContainerRequirementSatisfied ( requirement ) )
194+ {
195+ individualRequirementsSatisfied = false ;
196+ }
197+
198+ if ( individualRequirementsSatisfied )
199+ {
200+ break ;
201+ }
202+ }
203+ }
204+
205+ bool compositeRequirementSatisfied = false ;
206+ foreach ( RequirementType [ ] compositeRequirement in CompositeRequirements )
207+ {
208+ if ( compositeRequirement . All ( i => requireables . Contains ( i ) ) )
209+ {
210+ compositeRequirementSatisfied = true ;
211+ }
212+ foreach ( RequirementType component in compositeRequirement )
213+ {
214+ if ( ! StatAdjustedContainerRequirementSatisfied ( component ) )
215+ {
216+ compositeRequirementSatisfied = false ;
217+ break ;
218+ }
219+ }
220+ if ( compositeRequirementSatisfied == true )
221+ {
222+ break ;
223+ }
224+ }
225+ return individualRequirementsSatisfied || compositeRequirementSatisfied ;
150226 }
151227
152228 public Requirements WithHardRequirement ( RequirementType requirement )
@@ -240,6 +316,29 @@ public bool HasHardRequirement(RequirementType requireable)
240316 }
241317 return true ;
242318 }
319+
320+ public static RequirementType MagicContainerRequirementFromCost ( int magicCost )
321+ {
322+ switch ( magicCost )
323+ {
324+ case <= 16 :
325+ return RequirementType . ONE_CONTAINER ;
326+ case <= 32 :
327+ return RequirementType . TWO_CONTAINERS ;
328+ case <= 48 :
329+ return RequirementType . THREE_CONTAINERS ;
330+ case <= 64 :
331+ return RequirementType . FOUR_CONTAINERS ;
332+ case <= 80 :
333+ return RequirementType . FIVE_CONTAINERS ;
334+ case <= 96 :
335+ return RequirementType . SIX_CONTAINERS ;
336+ case <= 112 :
337+ return RequirementType . SEVEN_CONTAINERS ;
338+ default :
339+ return RequirementType . EIGHT_CONTAINERS ;
340+ }
341+ }
243342}
244343
245344public class RequirementsJsonConverter : JsonConverter < Requirements >
0 commit comments