Created
May 1, 2018 21:16
-
-
Save philgruneich/38d2f6e9de26977f8c05a359bb9e1086 to your computer and use it in GitHub Desktop.
CSM: calculate how much training will require to reach limits before 28yo on transfer list
This file contains hidden or 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
Array.from(document.querySelectorAll('article.player')).forEach((player) => { | |
const age = +player.querySelector('.general .first-col li:nth-child(2)').textContent.substr(5, 2); | |
const rx = /(\d+)[^\d]*(\d+)?/; | |
const skills = player.querySelector('.skills-bar'); | |
const aim = skills.querySelector('li:first-child .visual').textContent.trim().match(rx); | |
const handling = skills.querySelector('li:nth-child(3) .visual').textContent.trim().match(rx); | |
const quickness = skills.querySelector('li:nth-child(5) .visual').textContent.trim().match(rx); | |
const determination = skills.querySelector('li:nth-child(6) .visual').textContent.trim().match(rx); | |
const awareness = skills.querySelector('li:nth-child(7) .visual').textContent.trim().match(rx); | |
let player_skills = { | |
aim: {value: aim[1], limit: aim[2] || aim[1]}, | |
handling: {value: handling[1], limit: handling[2] || handling[1]}, | |
quickness: {value: quickness[1], limit: quickness[2] || quickness[1]}, | |
determination: {value: determination[1], limit: determination[2] || determination[1]}, | |
awareness: {value: awareness[1], limit: awareness[2] || awareness[1]} | |
}; | |
player_skills.aim.train = player_skills.aim.limit - player_skills.aim.value; | |
player_skills.handling.train = player_skills.handling.limit - player_skills.handling.value; | |
player_skills.quickness.train = player_skills.quickness.limit - player_skills.quickness.value; | |
player_skills.determination.train = player_skills.determination.limit - player_skills.determination.value; | |
player_skills.awareness.train = player_skills.awareness.limit - player_skills.awareness.value; | |
const TOP_5 = ((player_skills.aim.train + player_skills.handling.train + player_skills.quickness.train + player_skills.determination.train + player_skills.awareness.train) / (28 - age)).toFixed(2); | |
const TOP_3 = ((player_skills.quickness.train + player_skills.determination.train + player_skills.awareness.train) / (28 - age)).toFixed(2); | |
let top5li = document.createElement('li'); | |
top5li.textContent = `T5/Season: ${TOP_5}`; | |
let top3li = document.createElement('li'); | |
top3li.textContent = `T3/Season: ${TOP_3}`; | |
player.querySelector('.options ul').appendChild(top5li); | |
player.querySelector('.options ul').appendChild(top3li) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment