Skip to content

Commit

Permalink
Merge pull request #354 from IUrreta/main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
IUrreta authored Aug 23, 2024
2 parents b0ab889 + 7d0a76c commit 41364cb
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 48 deletions.
57 changes: 31 additions & 26 deletions back/scripts/car_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,33 +379,36 @@ def update_items_for_design_dict(self, design_dict, team_id):
self.conn.commit()

def fit_loadouts_dict(self, loadouts_dict, team_id):
print(loadouts_dict)
for part in loadouts_dict:
design_1 = loadouts_dict[part][0]
design_2 = loadouts_dict[part][1]
fitted_design_1 = self.cursor.execute(f"SELECT DesignID, ItemID FROM Parts_CarLoadout WHERE TeamID = {team_id} AND PartType = {part} AND LoadoutID = 1").fetchone()
if fitted_design_1[0] is not None:
self.cursor.execute(f"UPDATE Parts_Items SET AssociatedCar = NULL WHERE ItemID = {fitted_design_1[1]}")
fitted_design_1 = fitted_design_1[0]

if fitted_design_1 != design_1:
items_1 = self.cursor.execute(f"SELECT ItemID FROM Parts_Items WHERE DesignID = {design_1} AND BuildWork = {standard_buildwork_per_part[int(part)]} AND AssociatedCar IS NULL").fetchall()
if not items_1:
item_1 = self.create_new_item(design_1, int(part))
else:
item_1 = items_1[0][0]
self.add_part_to_loadout(design_1, int(part), team_id, 1, item_1)

fitted_design_2 = self.cursor.execute(f"SELECT DesignID, ItemID FROM Parts_CarLoadout WHERE TeamID = {team_id} AND PartType = {part} AND LoadoutID = 2").fetchone()
if fitted_design_2[0] is not None:
self.cursor.execute(f"UPDATE Parts_Items SET AssociatedCar = NULL WHERE ItemID = {fitted_design_2[1]}")
fitted_design_2 = fitted_design_2[0]
if fitted_design_2 != design_2:
items_2 = self.cursor.execute(f"SELECT ItemID FROM Parts_Items WHERE DesignID = {design_2} AND BuildWork = {standard_buildwork_per_part[int(part)]} AND AssociatedCar IS NULL").fetchall()
if not items_2:
item_2 = self.create_new_item(design_2, int(part))
else:
item_2 = items_2[0][0]
self.add_part_to_loadout(design_2, int(part), team_id, 2, item_2)
if design_1 is not None:
if fitted_design_1[0] is not None:
self.cursor.execute(f"UPDATE Parts_Items SET AssociatedCar = NULL WHERE ItemID = {fitted_design_1[1]}")
fitted_design_1 = fitted_design_1[0]

if fitted_design_1 != design_1:
items_1 = self.cursor.execute(f"SELECT ItemID FROM Parts_Items WHERE DesignID = {design_1} AND BuildWork = {standard_buildwork_per_part[int(part)]} AND AssociatedCar IS NULL").fetchall()
if not items_1:
item_1 = self.create_new_item(design_1, int(part))
else:
item_1 = items_1[0][0]
self.add_part_to_loadout(design_1, int(part), team_id, 1, item_1)

if design_2 is not None:
fitted_design_2 = self.cursor.execute(f"SELECT DesignID, ItemID FROM Parts_CarLoadout WHERE TeamID = {team_id} AND PartType = {part} AND LoadoutID = 2").fetchone()
if fitted_design_2[0] is not None:
self.cursor.execute(f"UPDATE Parts_Items SET AssociatedCar = NULL WHERE ItemID = {fitted_design_2[1]}")
fitted_design_2 = fitted_design_2[0]
if fitted_design_2 != design_2:
items_2 = self.cursor.execute(f"SELECT ItemID FROM Parts_Items WHERE DesignID = {design_2} AND BuildWork = {standard_buildwork_per_part[int(part)]} AND AssociatedCar IS NULL").fetchall()
if not items_2:
item_2 = self.create_new_item(design_2, int(part))
else:
item_2 = items_2[0][0]
self.add_part_to_loadout(design_2, int(part), team_id, 2, item_2)

self.conn.commit()

Expand Down Expand Up @@ -507,14 +510,16 @@ def overwrite_performance_team(self, team_id, performance, custom_team=None, yea
self.conn.commit()

def change_expertise_based(self,part, stat, new_value, team_id, type="existing", old_design=None):
day_season = self.cursor.execute("SELECT Day, CurrentSeason FROM Player_State").fetchone()
if type == "existing":
current_value = self.cursor.execute(f"SELECT MAX(Value) FROM Parts_Designs_StatValues WHERE PartStat = {stat} AND DesignID IN (SELECT MAX(DesignID) FROM Parts_Designs WHERE PartType = {part} AND TeamID = {team_id})").fetchone()[0]
current_value = self.cursor.execute(f"SELECT MAX(Value) FROM Parts_Designs_StatValues WHERE PartStat = {stat} AND DesignID IN (SELECT MAX(DesignID) FROM Parts_Designs WHERE PartType = {part} AND TeamID = {team_id} AND ValidFrom = {day_season[1]})").fetchone()[0]
elif type == "new":
current_value = self.cursor.execute(f"SELECT Value FROM Parts_Designs_StatValues WHERE PartStat = {stat} AND DesignID = {old_design}").fetchone()[0]
if current_value == 0:
current_value = 1
current_expertise = self.cursor.execute(f"SELECT Expertise FROM Parts_TeamExpertise WHERE TeamID = {team_id} AND PartType = {part} AND PartStat = {stat}").fetchone()[0]
new_expertise = (float(new_value) * float(current_expertise)) / float(current_value)
# current_expertise = self.cursor.execute(f"SELECT Expertise FROM Parts_TeamExpertise WHERE TeamID = {team_id} AND PartType = {part} AND PartStat = {stat}").fetchone()[0]
# new_expertise = (float(new_value) * float(current_expertise)) / float(current_value)
new_expertise = current_value / 0.8
# print(f"Old value for {part} {stat}: {current_value}, old expertise: {current_expertise}")
# print(f"New value for {part} {stat}: {new_value}, new expertise: {new_expertise}")
self.cursor.execute(f"UPDATE Parts_TeamExpertise SET Expertise = {new_expertise} WHERE TeamID = {team_id} AND PartType = {part} AND PartStat = {stat}")
Expand Down
20 changes: 10 additions & 10 deletions front/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ <h3 class="modal-title bold-font">Custom configuration</h3>
</div>
<div class="team-change mt-2">
<div class="bold-font logo-and-name" style="width: 33%;">
<img src="../assets/images/alphatauri.png" class="alphataurilogo non-changable">
<div class="team-name">ALPHA TAURI</div>
<img src="../assets/images/alphatauri.png" class="alphataurilogo non-changable" id="alphaModalLogo">
<div class="team-name" id="alphaModalName">ALPHA TAURI</div>
</div>
<div style="font-size: 35px; width: 33%; text-align: center;"><i class="bi bi-arrow-right"></i></div>
<div class="team-change-button" id="alphaTauriReplaceButton">
Expand All @@ -365,7 +365,7 @@ <h3 class="modal-title bold-font">Custom configuration</h3>
<div>ALPHA TAURI</div>
</a>
<a class="dropdown-item bold-font visarbborder-down" href="#" data-value="visarb">
<img src="../assets/images/visarb.png" class="hugologo">
<img src="../assets/images/visarb.png" class="visarblogo">
<div>VISA CASHAPP RB</div>
</a>
<a class="dropdown-item bold-font hugoborder-down" href="#" data-value="hugo">
Expand All @@ -377,7 +377,7 @@ <h3 class="modal-title bold-font">Custom configuration</h3>
<div class="ms-2">TOYOTA</div>
</a>
<a class="dropdown-item bold-font porscheborder-down" href="#" data-value="porsche">
<img src="../assets/images/porsche.png" class="ferrarilogo">
<img src="../assets/images/porsche.png" class="porschelogo">
<div class="ms-2">PORSCHE</div>
</a>
<a class="dropdown-item bold-font brawnborder-down" href="#" data-value="brawn">
Expand Down Expand Up @@ -428,8 +428,8 @@ <h3 class="modal-title bold-font">Custom configuration</h3>
</div>
<div class="team-change mt-2">
<div class="bold-font logo-and-name" style="width: 33%;">
<img src="../assets/images/alfaromeo.png" class="alfalogo non-changable">
<div class="team-name">ALFA ROMEO</div>
<img src="../assets/images/alfaromeo.png" class="alfalogo non-changable" id="alfaModalLogo">
<div class="team-name" id="alfaModalName">ALFA ROMEO</div>
</div>
<div style="font-size: 35px; width: 33%; text-align: center;"><i class="bi bi-arrow-right"></i></div>
<div class="team-change-button" id="alfaReplaceButton">
Expand Down Expand Up @@ -615,9 +615,9 @@ <h3 class="modal-title bold-font">Performance info</h3>
<div class="modal-body custom-body">
<div style="gap: 7px;">
The performance shown in the graphs as well as in the parts editor is the <span
class="important-text bold-font">OPTIMAL </span> car performance
class="important-text bold-font">LATEST DESIGNS's </span> car performance
from that team, which does <span class="important-text bold-font">NOT </span>mean that the parts fitted in
the car are the best possible.
the car are the last ones designed. Drops in performance will most likely be because of <span class="important-text bold-font"> WEIGHT</span>.
</div>
<div class="mt-2" style="gap: 7px;">
The <span class="important-text bold-font">OVERALL </span> stat is an approximation of the car's
Expand Down Expand Up @@ -3539,14 +3539,14 @@ <h3 class="modal-title bold-font">Comparison data selection</h3>
<li class="nav-item">
<a class="nav-link bold-font categoryPills generalPills active" data-bs-toggle="pill"
data-section=".teams-section" href="#" id="teamsPill">
<div class="basic-label bold-font">CARS</div>
<div class="basic-label bold-font">Cars</div>
<div class="pill-line"></div>
</a>
</li>
<li class="nav-item">
<a class="nav-link bold-font categoryPills generalPills" data-bs-toggle="pill"
data-section=".engines-section" href="#" id="enginesPill">
<div class="basic-label bold-font">ENGINES</div>
<div class="basic-label bold-font">Engines</div>
<div class="pill-line"></div>
</a>
</li>
Expand Down
24 changes: 21 additions & 3 deletions front/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ document.addEventListener('DOMContentLoaded',function () {
"alfa": "../assets/images/alfaromeo.png","audi": "../assets/images/audi.png","sauber": "../assets/images/sauber.png","stake": "../assets/images/kick.png"
}
const logos_classes_configs = {
"visarb": "hugologo","toyota": "toyotalogo","hugo": "hugologo","alphatauri": "alphataurilogo",
"visarb": "visarblogo","toyota": "toyotalogo","hugo": "hugologo","alphatauri": "alphataurilogo",
"porsche": "porschelogo","brawn": "brawnlogo",
"alpine": "alpinelogo","renault": "ferrarilogo","andretti": "andrettilogo","lotus": "lotuslogo",
"alfa": "alfalogo","audi": "audilogo","sauber": "sauberlogo","stake": "alfalogo"
Expand Down Expand Up @@ -725,7 +725,6 @@ document.addEventListener('DOMContentLoaded',function () {
document.getElementById("year23").classList.remove("activated")
document.getElementById("year24").classList.add("activated")
document.getElementById("drs24").classList.remove("d-none")
document.getElementById("teamChanges").classList.add("d-none")
document.getElementById("drs24").dataset.attribute = "3"
game_version = 2024
max_races = 24;
Expand All @@ -743,7 +742,6 @@ document.addEventListener('DOMContentLoaded',function () {
document.getElementById("year23").classList.add("activated")
document.getElementById("drs24").classList.add("d-none")
document.getElementById("drs24").dataset.attribute = "-1"
document.getElementById("teamChanges").classList.remove("d-none")
if (32 in combined_dict) {
delete combined_dict[32]
}
Expand All @@ -759,6 +757,7 @@ document.addEventListener('DOMContentLoaded',function () {
elem.classList.remove("d-none")
})
}
replace_modal_teams(game_version)
}

function manage_custom_team(nameColor) {
Expand Down Expand Up @@ -1164,6 +1163,7 @@ document.addEventListener('DOMContentLoaded',function () {
elem.classList.remove("alphataurilogo")
elem.classList.remove("toyotalogo")
elem.classList.remove("hugologo")
elem.classList.remove("visarblogo")
elem.classList.remove("ferrarilogo")
elem.classList.remove("brawnlogo")
elem.classList.add(logos_classes_configs[info])
Expand Down Expand Up @@ -1199,6 +1199,7 @@ document.addEventListener('DOMContentLoaded',function () {
elem.classList.remove("alphataurilogo")
elem.classList.remove("toyotalogo")
elem.classList.remove("hugologo")
elem.classList.remove("visarblogo")
elem.classList.remove("ferrarilogo")
elem.classList.remove("brawnlogo")
elem.classList.add("alphataurilogo")
Expand Down Expand Up @@ -1396,6 +1397,23 @@ document.addEventListener('DOMContentLoaded',function () {
root.style.setProperty(oldVar,newVal);
}

function replace_modal_teams(version){
if (version === 2024) {
document.getElementById("alphaModalLogo").src = logos_configs["visarb"]
document.getElementById("alphaModalLogo").className = "visarblogo non-changable"
document.getElementById("alphaModalName").textContent = pretty_names["visarb"]
document.getElementById("alfaModalLogo").src = logos_configs["stake"]
document.getElementById("alfaModalName").textContent = pretty_names["stake"]
}
else if (version === 2023) {
document.getElementById("alphaModalLogo").src = logos_configs["alphatauri"]
document.getElementById("alphaModalLogo").className = "alphataurilogo non-changable"
document.getElementById("alphaModalName").textContent = pretty_names["alphatauri"]
document.getElementById("alfaModalLogo").src = logos_configs["alfa"]
document.getElementById("alfaModalName").textContent = pretty_names["alfa"]
}
}

document.querySelector("#configButton").addEventListener("click",function () {
//wait 0.1 seconds to show the modal
setTimeout(function () {
Expand Down
16 changes: 11 additions & 5 deletions front/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6769,6 +6769,7 @@ input::-webkit-inner-spin-button {
padding-top: 10px;
overflow: hidden;
white-space: nowrap;
text-transform: uppercase;
}


Expand Down Expand Up @@ -7279,13 +7280,14 @@ input::-webkit-inner-spin-button {
.brawnlogo{
width: 40px;
height: 40px;
padding: 15px 0;
padding: 16px 0px;
padding-left: 4px;
}

.audilogo{
width: 40px;
height: 40px;
padding: 12px 0;
padding: 12px 2px;
}

.sauberlogo{
Expand All @@ -7300,6 +7302,12 @@ input::-webkit-inner-spin-button {
padding: 5px 0;
}

.visarblogo{
height: 40px;
width: 40px;
padding: 5px 2px;
}

.toyotalogo{
width: 40px;
height: 40px;
Expand Down Expand Up @@ -7329,9 +7337,7 @@ input::-webkit-inner-spin-button {
.alphataurilogo, #atlogo {
width: 40px;
height: 40px;
padding-bottom: 12px;
padding-left: 10px;
padding-top: 12px;
padding: 12px 4px;
}

.williamslogo, #wilogo {
Expand Down
2 changes: 1 addition & 1 deletion launcher/version.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.3
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.2.2",
"version": "2.2.3",
"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 41364cb

Please sign in to comment.