Skip to content

Commit

Permalink
feat(Territorial): add presence (PreMiD#6742)
Browse files Browse the repository at this point in the history
* 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
Dark_Ville and EncryptedDev authored Sep 10, 2022
1 parent edd2595 commit 57e11a5
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
35 changes: 35 additions & 0 deletions websites/T/Territorial/dist/metadata.json
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
}
]
}
56 changes: 56 additions & 0 deletions websites/T/Territorial/presence.ts
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();
});
6 changes: 6 additions & 0 deletions websites/T/Territorial/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}

0 comments on commit 57e11a5

Please sign in to comment.