import { AbstractAPIComponent } from './AbstractAPIComponent';
import { Random } from './Random';
import { PlayableCharacter, MasterCharacterList, CharacterDisplayNames } from '../MasterLists/PlayableCharacters';
/**
* API Component that manages {@link PlayableCharacter}s. This is a static class and should not be
* created using the `new` keyword. Instead, all methods should be accessed directly from the
* class name.
* @example
* const seed: number = 1337;
* const rng = new Random('./path/to/stsJar', seed);
*
* const todaysCharacter: PlayableCharacter = CharacterManager.getRandomCharacter(rng);
*/
export class CharacterManager extends AbstractAPIComponent {
/**
* Get a random {@link PlayableCharacter} using a provided random number generator
* @param {Random} rng Random number generator
* @returns {PlayableCharacter}
*/
public static getRandomCharacter(rng: Random): PlayableCharacter {
const numberOfCharacters: number = MasterCharacterList.length;
const index: number = rng.randomInt(numberOfCharacters - 1);
return MasterCharacterList[index];
}
/**
* Get the display name of a character
* @param {PlayableCharacter} character Character to get display name of
* @returns {string}
*/
public static getCharacterDisplayName(character: PlayableCharacter): string {
return CharacterDisplayNames[character];
}
}
Source