Skip to content

Commit

Permalink
Merge pull request #317 from IUrreta/bug-nationality
Browse files Browse the repository at this point in the history
Bug nationality
  • Loading branch information
IUrreta authored Aug 2, 2024
2 parents 380cf2f + b100b2f commit 507127f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
30 changes: 18 additions & 12 deletions back/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def fetch_staff(self, game_year):
retirement = self.fetch_driverRetirement(id)
race_formula = self.fetch_raceFormula(id)
team_future = self.fetch_for_future_contract(id)
country_code = self.fetch_nationality(id)
country_code = self.fetch_nationality(id, game_year)
if race_formula[0] == None:
race_formula = (4,)
data_dict = {i: result[i] for i in range(len(result))}
Expand Down Expand Up @@ -344,7 +344,7 @@ def fetch_info(self, game_year):
superlicense = self.fetch_superlicense(id)
team_future = self.fetch_for_future_contract(id)
driver_code = self.fetch_driverCode(id)
country_code = self.fetch_nationality(id)
country_code = self.fetch_nationality(id, game_year)
data_dict = {i: result[i] for i in range(len(result))}
data_dict["driver_number"] = driver_number[0]
data_dict["wants1"] = driver_number[1]
Expand All @@ -368,18 +368,24 @@ def fetch_info(self, game_year):

return formatted_tuples

def fetch_nationality(self, driverID):
code = self.cursor.execute(f"SELECT CountryID FROM Staff_BasicData WHERE StaffID = {driverID}").fetchone()[0]
nationality = self.cursor.execute(f"SELECT Name FROM Countries WHERE CountryID = {code}").fetchone()[0]
expr = r'(?<=\[Nationality_)[^\]]+'
result = re.search(expr, nationality)
if result:
nat = result.group(0)
nat_name = re.sub(r'(?<!^)([A-Z])', r' \1', nat)
def fetch_nationality(self, driverID, game_year):
if game_year == "24":
code = self.cursor.execute(f"SELECT CountryID FROM Staff_BasicData WHERE StaffID = {driverID}").fetchone()[0]
nationality = self.cursor.execute(f"SELECT Name FROM Countries WHERE CountryID = {code}").fetchone()[0]
expr = r'(?<=\[Nationality_)[^\]]+'
result = re.search(expr, nationality)
if result:
nat = result.group(0)
nat_name = re.sub(r'(?<!^)([A-Z])', r' \1', nat)
nat_code = countries_dict.get(nat_name, "")
return nat_code
else:
return ""
elif game_year == "23":
nationality = self.cursor.execute(f"SELECT Nationality FROM Staff_BasicData WHERE StaffID = {driverID}").fetchone()[0]
nat_name = re.sub(r'(?<!^)([A-Z])', r' \1', nationality)
nat_code = countries_dict.get(nat_name, "")
return nat_code
else:
return ""

def fetch_driverCode(self, driverID):
code = self.cursor.execute(f"SELECT DriverCode FROM Staff_DriverData WHERE StaffID = {driverID}").fetchone()
Expand Down
2 changes: 1 addition & 1 deletion launcher/version.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.12
2.1.14
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Database Editor F1 Manager",
"version": "2.1.12",
"version": "2.1.14",
"description": "A tool that will let you edit your save file from F1 Manager games",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 507127f

Please sign in to comment.