@workadventure/quests
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ let r = "https://admin.workadventu.re"; | ||
} | ||
function a() { | ||
function n() { | ||
const e = WA.player.userRoomToken; | ||
@@ -15,33 +15,33 @@ if (e === void 0) | ||
async function d(e) { | ||
const t = new URL(`/api/quests/${e}`, r); | ||
t.search = new URLSearchParams({ room: WA.room.id }).toString(); | ||
const o = await fetch(t, { | ||
const o = new URL(`/api/quests/${e}`, r); | ||
o.search = new URLSearchParams({ room: WA.room.id }).toString(); | ||
const t = await fetch(o, { | ||
method: "GET", | ||
headers: { | ||
Authorization: a() | ||
Authorization: n() | ||
} | ||
}); | ||
if (!o.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${o.status} ${o.statusText}.`); | ||
return await o.json(); | ||
if (!t.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${t.status} ${t.statusText}.`); | ||
return await t.json(); | ||
} | ||
async function l(e) { | ||
const t = new URL(`/api/quests/${e}/leaderboard`, r); | ||
t.search = new URLSearchParams({ room: WA.room.id }).toString(); | ||
const o = await fetch(t, { | ||
async function h(e) { | ||
const o = new URL(`/api/quests/${e}/leaderboard`, r); | ||
o.search = new URLSearchParams({ room: WA.room.id }).toString(); | ||
const t = await fetch(o, { | ||
method: "GET", | ||
headers: { | ||
Authorization: a() | ||
Authorization: n() | ||
} | ||
}); | ||
if (!o.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${o.status} ${o.statusText}.`); | ||
return await o.json(); | ||
if (!t.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${t.status} ${t.statusText}.`); | ||
return await t.json(); | ||
} | ||
function w(e) { | ||
const t = new URL(`/quests/${e}/leaderboard`, r); | ||
return t.search = new URLSearchParams({ room: WA.room.id, token: a() }).toString(), t; | ||
const o = new URL(`/quests/${e}/leaderboard`, r); | ||
return o.search = new URLSearchParams({ room: WA.room.id, token: n() }).toString(), o; | ||
} | ||
async function h(e, t) { | ||
const o = new URL(`/api/quests/${e}/level-up`, r), n = await fetch(o, { | ||
async function l(e, o) { | ||
const t = new URL(`/api/quests/${e}/level-up`, r), a = await fetch(t, { | ||
method: "POST", | ||
@@ -51,9 +51,9 @@ headers: { | ||
"Content-Type": "application/json", | ||
Authorization: a() | ||
Authorization: n() | ||
}, | ||
body: JSON.stringify({ xp: t }) | ||
body: JSON.stringify({ xp: o }) | ||
}); | ||
if (!n.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${n.status} ${n.statusText}.`); | ||
const s = await n.json(); | ||
if (!a.ok) | ||
throw new Error(`An error occurred. HTTP Code: ${a.status} ${a.statusText}.`); | ||
const s = await a.json(); | ||
return s.awardedBadges.length > 0 && (async () => { | ||
@@ -66,6 +66,6 @@ for (const i of s.awardedBadges) | ||
} | ||
async function u(e, t) { | ||
const o = new URL(`/quests/${e}/badge/${t}/congratulations`, r); | ||
o.search = new URLSearchParams({ token: a() }).toString(), await WA.ui.website.open({ | ||
url: o.toString(), | ||
async function u(e, o) { | ||
const t = new URL(`/quests/${e}/badge/${o}/congratulations`, r); | ||
t.search = new URLSearchParams({ token: n() }).toString(), await WA.ui.website.open({ | ||
url: t.toString(), | ||
position: { | ||
@@ -82,14 +82,9 @@ vertical: "middle", | ||
}); | ||
const n = new URL("/audio/clapping.mp3", r); | ||
WA.sound.loadSound(n.toString()).play({ | ||
loop: !1, | ||
volume: 1 | ||
}); | ||
} | ||
export { | ||
l as getLeaderboard, | ||
h as getLeaderboard, | ||
w as getLeaderboardURL, | ||
d as getQuest, | ||
h as levelUp, | ||
l as levelUp, | ||
c as setQuestBaseUrl | ||
}; |
{ | ||
"name": "@workadventure/quests", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Utility functions to create quests for WorkAdventure", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
8483
-2.55%148
-3.9%