MCPcopy Create free account
hub / github.com/codecombat/codecombat / constructor

Method constructor

app/views/ladder/LadderPlayModal.js:297–319  ·  view source on GitHub ↗
(level, team, otherTeam, session, league)

Source from the content-addressed store, hash-verified

295
296class ChallengersData {
297 constructor (level, team, otherTeam, session, league) {
298 let score
299 this.level = level
300 this.team = team
301 this.otherTeam = otherTeam
302 this.session = session
303 this.league = league
304 _.extend(this, Backbone.Events)
305 if (this.league) {
306 score = _.find(this.session?.get('leagues'), { leagueID: this.league.id })?.stats?.totalScore || 10
307 } else {
308 score = this.session?.get('totalScore') || 10
309 }
310 for (const player of [
311 { type: 'easyPlayer', order: 1, scoreOffset: score - 5 },
312 { type: 'mediumPlayer', order: 1, scoreOffset: score },
313 { type: 'hardPlayer', order: -1, scoreOffset: score + 5 }
314 ]) {
315 const playerResource = (this[player.type] = new LeaderboardCollection(this.level, this.collectionParameters({ order: player.order, scoreOffset: player.scoreOffset })))
316 playerResource.fetch({ cache: false })
317 this.listenToOnce(playerResource, 'sync', this.challengerLoaded)
318 }
319 }
320
321 collectionParameters (parameters) {
322 parameters.team = this.otherTeam

Callers

nothing calls this directly

Calls 3

collectionParametersMethod · 0.95
getMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected