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

Method loadPlayerThangTypes

ozaria/engine/cinematic/Loader.js:50–80  ·  view source on GitHub ↗

* Loads the player thangType from the global `me` object if accessible. * Has a side effect of storing the players thangType by original as a resource. * * If an admin or player doesn't have a hero, falls back to a default.

()

Source from the content-addressed store, hash-verified

48 * If an admin or player doesn't have a hero, falls back to a default.
49 */
50 loadPlayerThangTypes () {
51 const original = (me.get('ozariaUserOptions') || {}).cinematicThangTypeOriginal || HERO_THANG_ID
52 const avatar = (store.getters['me/getCh1Avatar'] || {}).cinematicThangTypeId || AVATAR_THANG_ID
53 const avatarPet = (store.getters['me/getCh1Avatar'] || {}).cinematicPetThangId || AVATAR_THANG_ID
54
55 this.loadingThangTypes.set(
56 original,
57 (async () => {
58 const attr = await getThangTypeOriginal(original)
59 this.loadedThangTypes.set(original, new ThangType(attr))
60 })()
61 )
62
63 // TODO: We don't always need to load this. Currently a convenient solution.
64 // This will not scale as we add more runtime dependent thangTypes.
65 this.loadingThangTypes.set(
66 avatar,
67 (async () => {
68 const attr = await getThangTypeOriginal(avatar)
69 this.loadedThangTypes.set(avatar, new ThangType(attr))
70 })()
71 )
72
73 this.loadingThangTypes.set(
74 avatarPet,
75 (async () => {
76 const attr = await getThangTypeOriginal(avatarPet)
77 this.loadedThangTypes.set(avatarPet, new ThangType(attr))
78 })()
79 )
80 }
81
82 /**
83 * Queues up the background objects

Callers 1

loadAssetsMethod · 0.95

Calls 3

getThangTypeOriginalFunction · 0.90
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected