MCPcopy Index your code
hub / github.com/codecombat/codecombat / loadOpponentTeam

Method loadOpponentTeam

app/views/play/SpectateView.js:191–214  ·  view source on GitHub ↗
(myTeam)

Source from the content-addressed store, hash-verified

189 }
190
191 loadOpponentTeam (myTeam) {
192 if (myTeam !== this.session.get('team')) {
193 console.error(`Team mismatch. Expected session one to be '${myTeam}'. Got '${this.session.get('team')}'`)
194 }
195
196 let opponentSpells = []
197 for (const spellTeam in utils.teamSpells) {
198 const spells = utils.teamSpells[spellTeam]
199 if ((spellTeam === myTeam) || !myTeam) { continue }
200 opponentSpells = opponentSpells.concat(spells)
201 }
202
203 const opponentCode = (this.otherSession != null ? this.otherSession.get('code') : undefined) || {}
204 const myCode = this.session.get('code') || {}
205 for (let spell of Array.from(opponentSpells)) {
206 let thang;
207 [thang, spell] = Array.from(spell.split('/'))
208 const c = opponentCode[thang] != null ? opponentCode[thang][spell] : undefined
209 if (myCode[thang] == null) { myCode[thang] = {} }
210 if (c) { myCode[thang][spell] = c } else { delete myCode[thang][spell] }
211 }
212
213 return this.session.set('code', myCode)
214 }
215
216 onLevelStarted (e) {
217 const go = () => {

Callers 1

onLevelLoaderLoadedMethod · 0.95

Calls 3

getMethod · 0.45
errorMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected