stormAt function

WorldStorm? stormAt(
  1. List<WorldStorm> storms,
  2. String touchpoint,
  3. String method,
  4. int callIndex,
)

The storm that fires for touchpoint's method on call callIndex (1-based), or null when the schedule is silent there. A storm with a null method matches every method of the touchpoint; a method-scoped storm fires only on its method (how mid-flow storms stay surgical). When several storms overlap, the LAST declared wins (later entries refine earlier ones — the manifest reads as an ordered schedule).

Implementation

WorldStorm? stormAt(
  List<WorldStorm> storms,
  String touchpoint,
  String method,
  int callIndex,
) {
  WorldStorm? firing;
  for (final storm in storms) {
    final methodMatch = storm.method == null || storm.method == method;
    if (storm.touchpoint == touchpoint &&
        methodMatch &&
        storm.firesOn(callIndex)) {
      firing = storm;
    }
  }
  return firing;
}