Skip to content

Commit

Permalink
fix(Granblue Fantasy): handle no alive boss (#9128)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrie25 authored Jan 8, 2025
1 parent 14fb826 commit 68337f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion websites/G/Granblue Fantasy/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"vi_VN": "Trò chơi đóng vai Nhật Bản"
},
"url": "game.granbluefantasy.jp",
"version": "1.5.1",
"version": "1.5.2",
"logo": "https://cdn.rcd.gg/PreMiD/websites/G/Granblue%20Fantasy/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/G/Granblue%20Fantasy/assets/thumbnail.jpg",
"color": "#2F4F7A",
Expand Down
12 changes: 9 additions & 3 deletions websites/G/Granblue Fantasy/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ presence.on("UpdateData", async () => {
} else if (href.includes("/#result"))
presenceData.details = "In a Quest result screen";
else if (href.includes("/#raid") || href.includes("/#raid_multi")) {
const boss = gameStatus?.boss?.param.find(x => x.alive);
const bosses = gameStatus?.boss?.param.sort(
(a, b) => parseInt(b.hpmax) - parseInt(a.hpmax)
),
boss = bosses?.find(x => x.alive) || bosses?.[0];

if (boss) {
if (boss.name.ja !== boss.name.en)
presenceData.details = `${boss.name.en} (${boss.name.ja})`;
Expand All @@ -180,8 +184,10 @@ presence.on("UpdateData", async () => {
).toFixed(2)}%]`;
}

if (turn && gameStatus?.turn)
presenceData.state += ` | Turn ${gameStatus.turn}`;
if (turn && gameStatus?.turn) {
if (!presenceData.state) presenceData.state = `Turn ${gameStatus.turn}`;
else presenceData.state += ` | Turn ${gameStatus.turn}`;
}

if (djeeta && gameStatus?.player) {
const charaAlive = gameStatus.player.param.find(x => x.leader);
Expand Down

0 comments on commit 68337f6

Please sign in to comment.