mirror of
https://github.com/ssyyhhrr/stewardle.git
synced 2025-11-08 10:33:46 -05:00
Compare commits
7 Commits
bff3c89695
...
06a7aab289
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06a7aab289 | ||
|
|
4cc1d412a3 | ||
|
|
d8d0f71d9c | ||
|
|
a10167c0a8 | ||
|
|
55f3396e2c | ||
|
|
b48dfdca67 | ||
|
|
1b1ca4a300 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
node_modules
|
||||
drivers.json
|
||||
stats.json
|
||||
.idea
|
||||
.idea
|
||||
.DS_Store
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
<!-- PROJECT LOGO -->
|
||||
<div align="center">
|
||||
<a href="https://github.com/othneildrew/Best-README-Template">
|
||||
<img src="https://sy.hr/files/alpha-wordle-icon-new-square320-v3%20%281%29%20%281%29.png" alt="Logo" width="80" height="80">
|
||||
<img src="https://raw.githubusercontent.com/ssyyhhrr/stewardle/refs/heads/main/assets/stewardle.png" alt="Logo" width="80" height="80">
|
||||
</a>
|
||||
<h3 align="center">Stewardle</h3>
|
||||
|
||||
<p align="center">
|
||||
A Wordle-inspired game designed for the web. Players must guess the randomly selected F1 driver using statistics retrieved from the Ergast API. Created with Express and Node.js.
|
||||
A Wordle-inspired game designed for the web. Players must guess the randomly selected F1 driver using statistics retrieved from the Jolpica API. Created with Express and Node.js.
|
||||
<br />
|
||||
<a href="https://stewardle.com/">View Demo</a>
|
||||
·
|
||||
@@ -42,10 +42,10 @@
|
||||
## About The Project
|
||||
|
||||
<p float="left">
|
||||
<img src="https://sy.hr/files/2022-11-06_16-11-14_SwmULV0ww8CqeuWK.png" width="300"/>
|
||||
<img src="https://raw.githubusercontent.com/ssyyhhrr/stewardle/refs/heads/main/assets/screenshot.png" width="300"/>
|
||||
</p>
|
||||
|
||||
A Wordle-inspired game designed for the web. Players must guess the randomly selected F1 driver using statistics retrieved from the Ergast API. Created with Express and Node.js.
|
||||
A Wordle-inspired game designed for the web. Players must guess the randomly selected F1 driver using statistics retrieved from the Jolpica API. Created with Express and Node.js.
|
||||
|
||||
<!-- CONTRIBUTING -->
|
||||
## Contributing
|
||||
|
||||
166
app.js
166
app.js
@@ -35,7 +35,154 @@ const flag = {
|
||||
"Indonesian": "id",
|
||||
"Italian": "it",
|
||||
"Monegasque": "mc",
|
||||
"Chinese": "cn"
|
||||
"Chinese": "cn",
|
||||
"Argentinian": "ar",
|
||||
"Andorran": "ad",
|
||||
"Emirati": "ae",
|
||||
"Afghan": "af",
|
||||
"Antiguan": "ag",
|
||||
"Anguillan": "ai",
|
||||
"Albanian": "al",
|
||||
"Armenian": "am",
|
||||
"Angolan": "ao",
|
||||
"Azerbaijani": "az",
|
||||
"Austrian": "at",
|
||||
"Bahamian": "bs",
|
||||
"Bangladeshi": "bd",
|
||||
"Barbadian": "bb",
|
||||
"Beninese": "bj",
|
||||
"Bhutanese": "bt",
|
||||
"Botswanan": "bw",
|
||||
"Bulgarian": "bg",
|
||||
"Burkinabé": "bf",
|
||||
"Burundian": "bi",
|
||||
"Cambodian": "kh",
|
||||
"Cameroonian": "cm",
|
||||
"Cape Verdean": "cv",
|
||||
"Chadian": "td",
|
||||
"Chilean": "cl",
|
||||
"Colombian": "co",
|
||||
"Costa Rican": "cr",
|
||||
"Croatian": "hr",
|
||||
"Cuban": "cu",
|
||||
"Cypriot": "cy",
|
||||
"Czech": "cz",
|
||||
"Dominican": "do",
|
||||
"Ecuadorian": "ec",
|
||||
"Egyptian": "eg",
|
||||
"Salvadoran": "sv",
|
||||
"Equatorial Guinean": "gq",
|
||||
"Eritrean": "er",
|
||||
"Estonian": "ee",
|
||||
"Ethiopian": "et",
|
||||
"Fijian": "fj",
|
||||
"Gabonese": "ga",
|
||||
"Gambian": "gm",
|
||||
"Georgian": "ge",
|
||||
"Ghanaian": "gh",
|
||||
"Gibraltarian": "gi",
|
||||
"Greek": "gr",
|
||||
"Grenadian": "gd",
|
||||
"Guatemalan": "gt",
|
||||
"Guinean": "gn",
|
||||
"Guyanese": "gy",
|
||||
"Haitian": "ht",
|
||||
"Honduran": "hn",
|
||||
"Hong Konger": "hk",
|
||||
"Hungarian": "hu",
|
||||
"Icelandic": "is",
|
||||
"Indian": "in",
|
||||
"Iranian": "ir",
|
||||
"Iraqi": "iq",
|
||||
"Israeli": "il",
|
||||
"Jamaican": "jm",
|
||||
"Jordanian": "jo",
|
||||
"Kazakh": "kz",
|
||||
"Kenyan": "ke",
|
||||
"North Korean": "kp",
|
||||
"South Korean": "kr",
|
||||
"Kuwaiti": "kw",
|
||||
"Kyrgyz": "kg",
|
||||
"Laotian": "la",
|
||||
"Latvian": "lv",
|
||||
"Lebanese": "lb",
|
||||
"Liberian": "lr",
|
||||
"Libyan": "ly",
|
||||
"Liechtensteiner": "li",
|
||||
"Lithuanian": "lt",
|
||||
"Luxembourgish": "lu",
|
||||
"Macedonian": "mk",
|
||||
"Malagasy": "mg",
|
||||
"Malawian": "mw",
|
||||
"Malaysian": "my",
|
||||
"Malian": "ml",
|
||||
"Maltese": "mt",
|
||||
"Marshallese": "mh",
|
||||
"Mauritanian": "mr",
|
||||
"Mauritian": "mu",
|
||||
"Micronesian": "fm",
|
||||
"Moldovan": "md",
|
||||
"Mongolian": "mn",
|
||||
"Montenegrin": "me",
|
||||
"Moroccan": "ma",
|
||||
"Mozambican": "mz",
|
||||
"Namibian": "na",
|
||||
"Nepalese": "np",
|
||||
"Nicaraguan": "ni",
|
||||
"Nigerien": "ne",
|
||||
"Nigerian": "ng",
|
||||
"Norwegian": "no",
|
||||
"Omani": "om",
|
||||
"Pakistani": "pk",
|
||||
"Palauan": "pw",
|
||||
"Panamanian": "pa",
|
||||
"Papua New Guinean": "pg",
|
||||
"Paraguayan": "py",
|
||||
"Peruvian": "pe",
|
||||
"Filipino": "ph",
|
||||
"Portuguese": "pt",
|
||||
"Qatari": "qa",
|
||||
"Romanian": "ro",
|
||||
"Rwandan": "rw",
|
||||
"Saint Lucian": "lc",
|
||||
"Saint Vincentian": "vc",
|
||||
"Samoan": "ws",
|
||||
"San Marinese": "sm",
|
||||
"Saudi": "sa",
|
||||
"Senegalese": "sn",
|
||||
"Serbian": "rs",
|
||||
"Seychellois": "sc",
|
||||
"Sierra Leonean": "sl",
|
||||
"Singaporean": "sg",
|
||||
"Slovak": "sk",
|
||||
"Slovenian": "si",
|
||||
"Solomon Islander": "sb",
|
||||
"Somali": "so",
|
||||
"South African": "za",
|
||||
"South Sudanese": "ss",
|
||||
"Sri Lankan": "lk",
|
||||
"Sudanese": "sd",
|
||||
"Surinamese": "sr",
|
||||
"Syrian": "sy",
|
||||
"Taiwanese": "tw",
|
||||
"Tajikistani": "tj",
|
||||
"Tanzanian": "tz",
|
||||
"Togolese": "tg",
|
||||
"Tongan": "to",
|
||||
"Trinidadian": "tt",
|
||||
"Tunisian": "tn",
|
||||
"Turkish": "tr",
|
||||
"Turkmen": "tm",
|
||||
"Tuvaluan": "tv",
|
||||
"Ugandan": "ug",
|
||||
"Ukrainian": "ua",
|
||||
"Uruguayan": "uy",
|
||||
"Uzbekistani": "uz",
|
||||
"Vanuatuan": "vu",
|
||||
"Vietnamese": "vn",
|
||||
"Yemeni": "ye",
|
||||
"Zambian": "zm",
|
||||
"Zimbabwean": "zw"
|
||||
}
|
||||
|
||||
function team(teamName, year) {
|
||||
@@ -111,7 +258,13 @@ let driver
|
||||
|
||||
let year = new Date().getFullYear()
|
||||
|
||||
axios.get("https://ergast.com/api/f1/1950/driverStandings.json?limit=1000").then(async () => {
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
axios.get("https://api.jolpi.ca/ergast/f1/1950/driverStandings.json?limit=1000").then(async () => {
|
||||
await updateDrivers()
|
||||
}).catch(() => {
|
||||
console.log("API is unreachable! Not updating drivers...")
|
||||
@@ -119,7 +272,7 @@ axios.get("https://ergast.com/api/f1/1950/driverStandings.json?limit=1000").then
|
||||
let data = fs.readFileSync(driversPath)
|
||||
drivers = JSON.parse(data)
|
||||
} else {
|
||||
throw "Ergast API is unreachable and the drivers.json cache has not been built. Please try again when the Ergast API is online."
|
||||
throw "Jolpica API is unreachable and the drivers.json cache has not been built. Please try again when the Jolpica API is online."
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
@@ -130,7 +283,7 @@ axios.get("https://ergast.com/api/f1/1950/driverStandings.json?limit=1000").then
|
||||
})
|
||||
|
||||
schedule.scheduleJob("59 23 * * *", async () => {
|
||||
axios.get("https://ergast.com/api/f1/1950/driverStandings.json?limit=1000").then(async () => {
|
||||
axios.get("https://api.jolpi.ca/ergast/f1/1950/driverStandings.json?limit=1000").then(async () => {
|
||||
await updateDrivers()
|
||||
}).catch(() => {
|
||||
console.log("API is unreachable! Not updating drivers...")
|
||||
@@ -151,7 +304,7 @@ async function updateDrivers() {
|
||||
for (let i = 2000; i <= year; i++) {
|
||||
console.log(`Scraping F1 ${i} Season...`)
|
||||
try {
|
||||
await axios.get(`http://ergast.com/api/f1/${i}/driverStandings.json?limit=1000`).then(res => {
|
||||
await axios.get(`https://api.jolpi.ca/ergast/f1/${i}/driverStandings.json?limit=1000`).then(res => {
|
||||
res.data.MRData.StandingsTable.StandingsLists[0].DriverStandings.forEach(driver => {
|
||||
if (driver.Driver.driverId in newDrivers) {
|
||||
newDrivers[driver.Driver.driverId].wins += parseInt(driver.wins)
|
||||
@@ -161,7 +314,7 @@ async function updateDrivers() {
|
||||
"firstName": driver.Driver.givenName,
|
||||
"lastName": driver.Driver.familyName,
|
||||
"code": driver.Driver.code,
|
||||
"nationality": flag[driver.Driver.nationality],
|
||||
"nationality": flag[driver.Driver.nationality.trim()],
|
||||
"constructors": [team(driver.Constructors[0].name, i)],
|
||||
"permanentNumber": driver.Driver.permanentNumber,
|
||||
"age": getAge(driver.Driver.dateOfBirth),
|
||||
@@ -174,6 +327,7 @@ async function updateDrivers() {
|
||||
} catch (e) {
|
||||
if (i !== year) throw ""
|
||||
}
|
||||
await sleep(300)
|
||||
}
|
||||
drivers = newDrivers
|
||||
|
||||
|
||||
BIN
assets/screenshot.png
Normal file
BIN
assets/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
Reference in New Issue
Block a user