rpsls
Version:
The canonical rock-paper-scissors-lizard-spock library.
40 lines (39 loc) • 1.33 kB
TypeScript
export default class RockPaperScissorsLizardSpock {
/** Constant for a tie outcome, 0 */
static TIE: number;
/** Constant for a player 1 victory, 1 */
static PLAYER1: number;
/** Constant for a player 2 victory, 2 */
static PLAYER2: number;
/** Constant for a rock move, 0. */
static ROCK: number;
/** Constant for a paper move, 1. */
static PAPER: number;
/** Constant for a scissors move, 2. */
static SCISSORS: number;
/** Constant for a lizard move, 3. */
static LIZARD: number;
/** Constant for a spock move, 4. */
static SPOCK: number;
/**
* Return the string representation of the given move.
*/
static getMoveName(move: number): string;
/**
* Return an object containing the outcome and result of player one's (p1) move vs player two's move (p2).
* The outcome property of the returned object will be TIE, PLAYER1, or PLAYER2.
* The result property of the returned object will be a string that describes the outcome.
*/
static play(p1: number, p2: number): {
outcome: number;
result: string;
method?: string;
winner?: number;
loser?: number;
};
/**
* Verify whether a move is valid.
* If not, throw an error.
*/
private static _validateMove(move);
}