Skip to content

Commit

Permalink
fix(Granblue Fantasy): remove largeImageText & fix getting boss hp (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrie25 authored Jan 10, 2025
1 parent 997c8b6 commit e3740b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 36 deletions.
8 changes: 1 addition & 7 deletions 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.2",
"version": "1.5.3",
"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 Expand Up @@ -55,12 +55,6 @@
"icon": "fas fa-image",
"value": false
},
{
"id": "profile",
"title": "Show profile detaiils",
"icon": "fad fa-user",
"value": false
},
{
"id": "button",
"title": "Show profile button",
Expand Down
46 changes: 17 additions & 29 deletions websites/G/Granblue Fantasy/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ presence.on("UpdateData", async () => {
largeImageKey:
"https://cdn.rcd.gg/PreMiD/websites/G/Granblue%20Fantasy/assets/logo.png",
startTimestamp: browsingTimestamp,
largeImageText: "Granblue Fantasy",
},
{ href } = document.location,
[health, turn, djeeta, profile, button] = await Promise.all([
[health, turn, djeeta, button] = await Promise.all([
presence.getSetting<number>("health"),
presence.getSetting<number>("turn"),
presence.getSetting<boolean>("djeeta"),
presence.getSetting<boolean>("profile"),
presence.getSetting<boolean>("button"),
]);
let userData = await presence.getPageVariable<UserData>(
Expand Down Expand Up @@ -171,17 +169,15 @@ presence.on("UpdateData", async () => {
"Starting battle...";
}

if (health === 0) {
presenceData.state = `At ${
document.querySelectorAll(".btn-enemy-gauge.prt-enemy-percent.alive")[0]
.textContent
}`;
} else if (health === 1 && boss) {
const hp = parseInt(boss.hp);
presenceData.state = `${hp.toLocaleString()} [${(
(hp * 100) /
parseInt(boss.hpmax)
).toFixed(2)}%]`;
if (boss) {
const hp = parseInt(boss.hp),
percentage = (hp * 100) / parseInt(boss.hpmax);
if (health === 0) presenceData.state = `At ${Math.ceil(percentage)}%`;
else if (health === 1) {
presenceData.state = `${hp.toLocaleString()} [${percentage.toFixed(
2
)}%]`;
}
}

if (turn && gameStatus?.turn) {
Expand All @@ -195,9 +191,6 @@ presence.on("UpdateData", async () => {
presenceData.smallImageKey = ElementIcons[charaAlive.attr];
presenceData.smallImageText = ElementsNames[charaAlive.attr];
presenceData.largeImageKey = `${userData.imgUri}/sp/assets/leader/raid_normal/${charaAlive.pid}.jpg`;
presenceData.largeImageText = `${charaAlive.name} | ${
charaAlive.hp
} [${((charaAlive.hp * 100) / charaAlive.hpmax).toFixed(2)}%]`;
}
}
} else if (href.includes("/#party/index/0/npc/0"))
Expand Down Expand Up @@ -338,18 +331,13 @@ presence.on("UpdateData", async () => {
else if (href.includes("#frontier/alchemy"))
presenceData.details = "In Alchemy Lab";

if (userData?.userId) {
if (profile && presenceData.largeImageText === "Granblue Fantasy")
presenceData.largeImageText = `UID: ${userData.userId} | Rank ${userData.userRank}`;

if (button) {
presenceData.buttons = [
{
label: "Profile",
url: `${userData.baseUri}/#profile/${userData.userId}`,
},
];
}
if (userData?.userId && button) {
presenceData.buttons = [
{
label: "Profile",
url: `${userData.baseUri}/#profile/${userData.userId}`,
},
];
}

presence.setActivity(presenceData);
Expand Down

0 comments on commit e3740b3

Please sign in to comment.