12 lines
272 B
TypeScript
12 lines
272 B
TypeScript
|
import { FixIndex } from './Util'
|
||
|
|
||
|
export function RandomIndex(count: number, exclude?: number): number
|
||
|
{
|
||
|
let index = Math.floor(Math.random() * count)
|
||
|
if (index === count)
|
||
|
index = 0
|
||
|
if (index === exclude)
|
||
|
index = FixIndex(index + 1, count)
|
||
|
return index
|
||
|
}
|