PokéRogue
    Preparing search index...

    Function randSeedUniqueItem

    • Select a random element using an offset such that the chosen element is guaranteed to be unique from the last seedOffset selections.

      Type Parameters

      • T

        The type of items in the array

      Parameters

      • choices: readonly T[]
      • seedOffset: number
      • scene: BattleScene = globalScene

        (default globalScene); The scene to use for random seeding

      Returns T

      A random item from the array that is guaranteed to be different from the

      If the seed offset is greater than the number of choices, this will just choose a random element

      const choices = ['a', 'b', 'c', 'd'];
      const choice1 = randSeedUniqueItem(choices, 0);
      const choice2 = randSeedUniqueItem(choices, 1);
      const choice3 = randSeedUniqueItem(choices, 2);
      assert(choice2 !== choice1);
      assert(choice3 !== choice1);
      assert(choice3 !== choice2);