forked from PreMiD/Presences
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Territorial): add presence (PreMiD#6742)
* feat(Territorial): add presence * feat(Territorial): add presence * chore(Territorial): remove comments * style(Territorial): fix style * Update websites/T/Territorial/presence.ts fix(Territorial): remove enum assets Co-Authored-By: Rhys Rakoff <64903135+EncryptedDev@users.noreply.github.com> * Update websites/T/Territorial/presence.ts Co-authored-by: Rhys Rakoff <64903135+EncryptedDev@users.noreply.github.com> * Update websites/T/Territorial/presence.ts Co-authored-by: Rhys Rakoff <64903135+EncryptedDev@users.noreply.github.com> Co-authored-by: Rhys Rakoff <64903135+EncryptedDev@users.noreply.github.com>
- Loading branch information
1 parent
edd2595
commit 57e11a5
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.7", | ||
"author": { | ||
"name": "Dark_Ville", | ||
"id": "638080361179512853" | ||
}, | ||
"service": "Territorial", | ||
"description": { | ||
"en": "Territorial.io is a strategy io game where players fight to expand their nations. Defend your territory, expand, and conquer the map in games of up to 500 players." | ||
}, | ||
"url": [ | ||
"territorial.io", | ||
"www.territorial.io" | ||
], | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/8vXevly.png", | ||
"thumbnail": "https://i.imgur.com/cAQAQkB.jpg", | ||
"color": "#07283C", | ||
"category": "games", | ||
"tags": [ | ||
"territorial", | ||
"games" | ||
], | ||
"settings": [ | ||
{ | ||
"id": "buttons", | ||
"if": { | ||
"privacy": false | ||
}, | ||
"title": "Show Buttons", | ||
"icon": "fas fa-compress-arrows-alt", | ||
"value": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const presence = new Presence({ | ||
clientId: "1014903980410802237", | ||
}), | ||
browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
presence.on("UpdateData", async () => { | ||
const presenceData: PresenceData = { | ||
largeImageKey: "https://i.imgur.com/8vXevly.png", | ||
startTimestamp: browsingTimestamp, | ||
}, | ||
{ href } = document.location, | ||
buttons = await presence.getSetting<boolean>("buttons"), | ||
context = document | ||
.querySelector<HTMLCanvasElement>("#canvasA") | ||
.getContext("2d"); | ||
let tryOne: number; | ||
const start = context.getImageData(100, 550, 400, 60).data[0]; | ||
if (start === 57 || start === 27 || start === 45) { | ||
tryOne = Number(context.getImageData(810, 140, 400, 60).data[0]); | ||
tryOne === 55 | ||
? (presenceData.details = "Viewing clans leaderboard") | ||
: tryOne === 4 | ||
? (presenceData.details = "Viewing players leaderboard") | ||
: context.getImageData(810, 80, 400, 60).data[0] === 68 | ||
? (presenceData.details = "Viewing clans leaderboard") | ||
: (tryOne = context.getImageData(780, 160, 400, 60).data[0]) === 254 || | ||
tryOne === 8 | ||
? (presenceData.details = "Viewing emoji menu") | ||
: (tryOne = context.getImageData(1380, 60, 400, 60).data[0]) === 8 || | ||
tryOne === 56 | ||
? (presenceData.details = "Viewing options") | ||
: (tryOne = context.getImageData(1400, 80, 400, 60).data[0]) === 94 || | ||
tryOne === 46 | ||
? (presenceData.details = "Viewing options") | ||
: (tryOne = context.getImageData(500, 220, 400, 60).data[0]) === 14 || | ||
tryOne === 6 | ||
? (presenceData.details = "Viewing color options") | ||
: (tryOne = context.getImageData(500, 60, 400, 60).data[0]) === 14 || | ||
tryOne === 6 | ||
? (presenceData.details = "Viewing color options") | ||
: (presenceData.details = "Viewing main menu"); | ||
|
||
presenceData.buttons = [{ label: "View Menu", url: href }]; | ||
} else if ( | ||
context.getImageData(1020, 540, 400, 60).data[0] === 255 || | ||
context.getImageData(1116, 502, 400, 60).data[0] === 255 | ||
) | ||
presenceData.details = "The game has ended"; | ||
else { | ||
presenceData.details = "Playing the game"; | ||
presenceData.buttons = [{ label: "Play", url: href }]; | ||
} | ||
if (!buttons) delete presenceData.buttons; | ||
if (presenceData.details) presence.setActivity(presenceData); | ||
else presence.setActivity(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/" | ||
} | ||
} |