diff --git a/src/data/socket.tsx b/src/data/socket.tsx index 866fc51..b871ed2 100644 --- a/src/data/socket.tsx +++ b/src/data/socket.tsx @@ -185,6 +185,9 @@ function setupSocket(socket: Socket) setTimeout(() => (main.showRefreshAnim.value = false), 500); }); socket.on("buy", (shopIndex, teamIndex, char) => { + const oldExp = main.team.value[teamIndex]?.exp ?? 0; + const oldLevel = oldExp >= 6 ? 3 : oldExp >= 3 ? 2 : 1; + const newLevel = char.exp >= 6 ? 3 : char.exp >= 3 ? 2 : 1; main.team.value[teamIndex] = char; main.team.value[teamIndex]!.id = getCharID(); main.shop.value[shopIndex] = null; @@ -194,6 +197,11 @@ function setupSocket(socket: Socket) if (main.frozen.value.includes(shopIndex)) { main.frozen.value = main.frozen.value.filter(m => m !== shopIndex); } + if (oldLevel !== newLevel) { + if (characters[char.type].abilityType === "LevelUp") { + setTimeout(() => characters[char.type].performAbility(char), 1250); + } + } }); socket.on("move", (index, otherIndex) => { const temp = main.team.value[index]; @@ -210,8 +218,10 @@ function setupSocket(socket: Socket) main.team.value[otherIndex] = char; poof(`team-char-${index}`); poof(`team-char-${otherIndex}`); - if (characters[char.type].abilityType === "LevelUp" && oldLevel !== newLevel) { - setTimeout(() => characters[char.type].performAbility(char), 1250); + if (oldLevel !== newLevel) { + if (characters[char.type].abilityType === "LevelUp") { + setTimeout(() => characters[char.type].performAbility(char), 1250); + } } }); socket.on("stream", (enemy, outcome) => {