Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/match/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Match', () => {
match.addContestant(player1)
match.addContestant(player2)

expect(match.contestants.size).toBe(2)
expect(match.size).toBe(2)
})

test('gets results of match', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/match/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export abstract class Match {
return this._contestants
}

get size(): number {
return this._contestants.size
}

get completed(): boolean {
return this._completed
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/matches/duel/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Duel', () => {
const match = Duel.create([Player.create('1', 1000), Player.create('2', 900)])
expect(match).toBeDefined()
expect(match).toBeInstanceOf(Duel)
expect(match.contestants.size).toBe(2)
expect(match.size).toBe(2)
})

test('throws error when adding more than 2 players', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/main/matches/duel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Duel extends Match {
}

addPlayer(player: Player): this {
if (this.contestants.size === DUEL_SIZE) {
if (this.size === DUEL_SIZE) {
throw new MatchError(ErrorType.MAX_PLAYERS)
}

Expand All @@ -43,7 +43,7 @@ export class Duel extends Match {
throw new MatchError(ErrorType.MATCH_COMPLETE)
}

if (this.contestants.size !== DUEL_SIZE) {
if (this.size !== DUEL_SIZE) {
throw new MatchError(ErrorType.MIN_PLAYERS)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/matches/free-for-all/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('FreeForAll', () => {
const match = FreeForAll.create([Player.create('1', 1000), Player.create('2', 900)])
expect(match).toBeDefined()
expect(match).toBeInstanceOf(FreeForAll)
expect(match.contestants.size).toBe(2)
expect(match.size).toBe(2)
})

test('calculates elo for player 1 win with 2 players', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/main/matches/free-for-all/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FreeForAll extends Match {
}

addPlayer(player: Player): this {
if (this.contestants.size === this.maxContestants) {
if (this.size === this.maxContestants) {
throw new MatchError(ErrorType.MAX_PLAYERS)
}

Expand All @@ -46,11 +46,11 @@ export class FreeForAll extends Match {
throw new MatchError(ErrorType.MATCH_COMPLETE)
}

if (this.contestants.size < this.minContestants) {
if (this.size < this.minContestants) {
throw new MatchError(ErrorType.MIN_PLAYERS)
}

if (this.contestants.size !== playerIds.length) {
if (this.size !== playerIds.length) {
throw new MatchError(ErrorType.SIZE_MISMATCH)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/matches/team-duel/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe('TeamDuel', () => {
])
expect(match).toBeDefined()
expect(match).toBeInstanceOf(TeamDuel)
expect(match.contestants.size).toBe(2)
expect(match.size).toBe(2)
})

test('adds teams to match', () => {
expect(match.contestants.size).toBe(2)
expect(match.size).toBe(2)
})

test('throws error when adding more than 2 teams to match', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/main/matches/team-duel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TeamDuel extends Match {
}

addTeam(team: Team): this {
if (this.contestants.size === DUEL_SIZE) {
if (this.size === DUEL_SIZE) {
throw new MatchError(ErrorType.MAX_TEAMS)
}

Expand All @@ -43,7 +43,7 @@ export class TeamDuel extends Match {
throw new MatchError(ErrorType.MATCH_COMPLETE)
}

if (this.contestants.size !== DUEL_SIZE) {
if (this.size !== DUEL_SIZE) {
throw new MatchError(ErrorType.MIN_TEAMS)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/matches/team-free-for-all/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe('TeamFreeForAll', () => {
])
expect(match).toBeDefined()
expect(match).toBeInstanceOf(TeamFreeForAll)
expect(match.contestants.size).toBe(3)
expect(match.size).toBe(3)
})

test('adds teams to match', () => {
expect(match.contestants.size).toBe(3)
expect(match.size).toBe(3)
})

test('calculates elo for team 1 winning', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/main/matches/team-free-for-all/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TeamFreeForAll extends Match {
}

addTeam(team: Team): this {
if (this.contestants.size === this.maxContestants) {
if (this.size === this.maxContestants) {
throw new MatchError(ErrorType.MAX_TEAMS)
}

Expand All @@ -46,11 +46,11 @@ export class TeamFreeForAll extends Match {
throw new MatchError(ErrorType.MATCH_COMPLETE)
}

if (this.contestants.size < this.minContestants) {
if (this.size < this.minContestants) {
throw new MatchError(ErrorType.MIN_TEAMS)
}

if (this.contestants.size !== teamIds.length) {
if (this.size !== teamIds.length) {
throw new MatchError(ErrorType.SIZE_MISMATCH)
}

Expand Down
Loading