Skip to content

Commit

Permalink
Merge pull request #22 from Soraclee/dev
Browse files Browse the repository at this point in the history
Correction pour la récupération de la dernière saison de jeu
  • Loading branch information
Soraclee authored Jul 12, 2023
2 parents a094380 + a3c4a22 commit 41b593e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ hr {
padding: 5px;
color: #fff;
border-radius: 5px 5px 0px 0px;
max-width: 185px;
}

.pregame .top-title p {
Expand Down
39 changes: 39 additions & 0 deletions public/js/checkPlayerData.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,42 @@ async function infosPlayer(pseudo) {

return infosPlayerJson;
}

function formattedDate() {
// Obtenez la date actuelle
var date = new Date();

// Obtenez les composants de date nécessaires
var year = date.getFullYear();
var month = (date.getMonth() + 1).toString().padStart(2, "0");
var day = date.getDate().toString().padStart(2, "0");

// Formattez la date selon le format souhaité
var formattedDate = year + "-" + month + "-" + day + "T00:00:00Z";

return formattedDate;
}

async function getActNow() {
let acts = await fetch(`https://valorant-api.com/v1/seasons`);

let actsJson = await acts.json();

let actnow = null;

for (let i = 0; i < actsJson["data"].length; i++) {
if (actsJson["data"][i]["type"] == "EAresSeasonType::Act") {
console.log(actsJson["data"][i]);
if (
actsJson["data"][i]["startTime"] < formattedDate() &&
actsJson["data"][i]["endTime"] > formattedDate()
) {
console.log(formattedDate() + " En cours");
actnow = actsJson["data"][i]["uuid"];
console.log(actnow);
}
}
}

return actnow;
}
16 changes: 15 additions & 1 deletion views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ block content
pregameAgentInfos = resultAgent.data;
}

function getSeasonsAvailable(seasons) {
let seasonsAvailable = [];

for (const [key, value] of Object.entries(seasons)) {
if(!value.error) {
seasonsAvailable.push(value);
}
}

return seasonsAvailable;
}

setInterval(updateSubjectPlayer, 10000)

async function updateDisplay() {
Expand All @@ -69,7 +81,9 @@ block content

// Update Display

let last_season = dataPlayer.by_season[Object.keys(dataPlayer.by_season)[Object.keys(dataPlayer.by_season).length - 1]]
let allSeasonsAvailable = getSeasonsAvailable(dataPlayer.by_season)

let last_season = allSeasonsAvailable[allSeasonsAvailable.length - 1]

if(dataPlayer.current_data.elo != null) {
document.querySelector('.overlay-background').style.backgroundImage = `url(${infosPlayerData.card.wide})`
Expand Down

0 comments on commit 41b593e

Please sign in to comment.