diff --git a/README.md b/README.md index 46a83c6..c28f906 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ match.addPlayers( new Player('3', 800) ) -const results = match.calculate(['1', '2', '3']) +const results = match.calculate('1', '2', '3') /* [ @@ -164,7 +164,7 @@ team2.addPlayers(new Player('3', 800), new Player('4', 700)) team3.addPlayers(new Player('5', 600), new Player('6', 500)) match.addTeams(team1, team2, team3) -const results = match.calculate(['1', '2', '3']) +const results = match.calculate('1', '2', '3') /* [ @@ -291,7 +291,7 @@ new FreeForAll(options?: Options) static create(options?: Options, ...players: Player[]): FreeForAll addPlayer(player: Player): this addPlayers(...players: Player[]): this -calculate(playerIds: string[]): PlayerResult[] +calculate(...playerIds: string[]): PlayerResult[] getResults(): PlayerResult[] ``` @@ -345,7 +345,7 @@ new TeamFreeForAll(options?: Options) static create(options?: Options, ...teams: Team[]): TeamFreeForAll addTeam(team: Team): this addTeams(...teams: Team[]): this -calculate(teamIds: string[]): TeamResult[] +calculate(...teamIds: string[]): TeamResult[] getResults(): TeamResult[] ``` diff --git a/src/main/matches/free-for-all/index.test.ts b/src/main/matches/free-for-all/index.test.ts index 41d1be1..bc99eca 100644 --- a/src/main/matches/free-for-all/index.test.ts +++ b/src/main/matches/free-for-all/index.test.ts @@ -26,7 +26,7 @@ describe('FreeForAll', () => { match.addPlayers(player1, player2) - const results = match.calculate(['1', '2']) + const results = match.calculate('1', '2') expect(results).toStrictEqual([ { @@ -47,7 +47,7 @@ describe('FreeForAll', () => { match.addPlayers(player1, player2) - const results = match.calculate(['2', '1']) + const results = match.calculate('2', '1') expect(results).toStrictEqual([ { @@ -69,7 +69,7 @@ describe('FreeForAll', () => { match.addPlayers(player1, player2, player3) - const results = match.calculate(['1', '2', '3']) + const results = match.calculate('1', '2', '3') expect(results).toStrictEqual([ { @@ -95,7 +95,7 @@ describe('FreeForAll', () => { match.addPlayers(player1, player2, player3) - const results = match.calculate(['2', '3', '1']) + const results = match.calculate('2', '3', '1') expect(results).toStrictEqual([ { @@ -121,7 +121,7 @@ describe('FreeForAll', () => { match.addPlayers(player1, player2, player3) - const results = match.calculate(['3', '2', '1']) + const results = match.calculate('3', '2', '1') expect(results).toStrictEqual([ { @@ -147,7 +147,7 @@ describe('FreeForAll', () => { } const results = match.calculate( - Array.from({ length: 100 }, (_, i) => (i + 1).toString()) + ...Array.from({ length: 100 }, (_, i) => (i + 1).toString()) ) expect(results[0].elo).toBe(1016) @@ -164,7 +164,7 @@ describe('FreeForAll', () => { const match = new FreeForAll({ minPlayers: 3 }) match.addPlayers(player1, player2) - match.calculate(['1', '2']) + match.calculate('1', '2') }).toThrow(ErrorType.MIN_PLAYERS) }) @@ -175,7 +175,7 @@ describe('FreeForAll', () => { const match = new FreeForAll() match.addPlayers(player1, player2) - match.calculate(['1']) + match.calculate('1') }).toThrow(ErrorType.SIZE_MISMATCH) }) }) diff --git a/src/main/matches/free-for-all/index.ts b/src/main/matches/free-for-all/index.ts index faadb72..4b7a8b4 100644 --- a/src/main/matches/free-for-all/index.ts +++ b/src/main/matches/free-for-all/index.ts @@ -39,7 +39,7 @@ export class FreeForAll extends Match { return this } - calculate(playerIds: string[]): PlayerResult[] { + calculate(...playerIds: string[]): PlayerResult[] { if (this.completed) { throw new MatchError(ErrorType.MATCH_COMPLETE) } diff --git a/src/main/matches/team-free-for-all/index.test.ts b/src/main/matches/team-free-for-all/index.test.ts index c9b6f45..4a84c0a 100644 --- a/src/main/matches/team-free-for-all/index.test.ts +++ b/src/main/matches/team-free-for-all/index.test.ts @@ -40,7 +40,7 @@ describe('TeamFreeForAll', () => { }) test('calculates elo for team 1 winning', () => { - const results = match.calculate(['1', '2', '3']) + const results = match.calculate('1', '2', '3') expect(results).toStrictEqual([ { id: '1', @@ -85,7 +85,7 @@ describe('TeamFreeForAll', () => { }) test('calculates elo for team 2 winning', () => { - const results = match.calculate(['2', '1', '3']) + const results = match.calculate('2', '1', '3') expect(results).toStrictEqual([ { id: '1', @@ -130,7 +130,7 @@ describe('TeamFreeForAll', () => { }) test('calculates elo for team 3 winning', () => { - const results = match.calculate(['3', '2', '1']) + const results = match.calculate('3', '2', '1') expect(results).toStrictEqual([ { id: '1', @@ -184,7 +184,7 @@ describe('TeamFreeForAll', () => { team2.addPlayer(new Player('2', 900)) match.addTeams(team1, team2) - match.calculate(['1', '2']) + match.calculate('1', '2') }).toThrow(ErrorType.MIN_TEAMS) }) @@ -198,7 +198,7 @@ describe('TeamFreeForAll', () => { team2.addPlayer(new Player('2', 900)) match.addTeams(team1, team2) - match.calculate(['1']) + match.calculate('1') }).toThrow(ErrorType.SIZE_MISMATCH) }) }) diff --git a/src/main/matches/team-free-for-all/index.ts b/src/main/matches/team-free-for-all/index.ts index 711f3d6..37cd12a 100644 --- a/src/main/matches/team-free-for-all/index.ts +++ b/src/main/matches/team-free-for-all/index.ts @@ -42,7 +42,7 @@ export class TeamFreeForAll extends Match { return this } - calculate(teamIds: string[]): TeamResult[] { + calculate(...teamIds: string[]): TeamResult[] { if (this.completed) { throw new MatchError(ErrorType.MATCH_COMPLETE) }