entryAt method

FeedEntry entryAt(
  1. int step
)

The entry for new-theme step step under the current filter: a hero on hero steps (every 8–12 steps, seeded), otherwise a generated theme whose seed and family come from Rng.stream(feedSeed, 'feed/step/k').

Implementation

FeedEntry entryAt(int step) {
  final families = _filter.families;
  final heroIndex = _heroIndexAt(step);
  if (heroIndex != null) {
    final order = _heroOrderIds();
    final allowed = [
      for (final id in order)
        if (families.contains(heroById(id)!.family)) id,
    ];
    if (allowed.isNotEmpty) {
      return FeedEntry.hero(allowed[heroIndex % allowed.length]);
    }
  }
  final r = Rng.stream(feedSeed, RngTag.sub(RngTag.feed, 'step', step));
  final seed = r.nextU32();
  final family = families[r.nextInt(families.length)];
  return FeedEntry.generated(seed: seed, family: family);
}