Skip to content

Commit

Permalink
V0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
domhnallmorr committed Jun 30, 2024
1 parent 6e01f23 commit 65166fa
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 453 deletions.
5 changes: 3 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os
import customtkinter

from race_engine_controller import race_engine_controller

customtkinter.set_appearance_mode("System") # Modes: system (default), light, dark
customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue") # Themes: blue (default), dark-blue, green

app = customtkinter.CTk() # create CTk window like you do with the Tk window
app.title("Race Engine V0.0.8")
app.title("Race Engine V0.1.0")
controller = race_engine_controller.RaceEngineController(app)

app.after(0, lambda:app.state("zoomed"))
Expand Down
34 changes: 20 additions & 14 deletions src/race_engine_controller/race_engine_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RaceEngineController:
def __init__(self, app):
self.app = app

self.model = race_engine_model.RaceEngineModel()
self.model = race_engine_model.RaceEngineModel("UI")
self.view = race_engine_view.RaceEngineView(self, self.model.driver_names)

# self.update_timing_screen()
Expand All @@ -22,27 +22,27 @@ def start_session(self):

def simulate_session(self):

if self.model.status == "running" or self.model.status == "pre_session":
if self.model.current_session.status == "running" or self.model.current_session.status == "pre_session":

self.model.advance()
self.view.timing_screen.update_view(self.model.get_data_for_view())
self.model.current_session.advance()
self.view.timing_screen.update_view(self.model.current_session.get_data_for_view())

# GET PIT STRATEGY FROM VIEW
driver1_data = self.view.timing_screen.strategy_editor_driver1.get_data()
driver2_data = self.view.timing_screen.strategy_editor_driver2.get_data()
self.model.update_player_drivers_strategy(driver1_data, driver2_data)

self.app.after(1000, self.simulate_session)
self.app.after(1500, self.simulate_session)

if self.model.status == "post_session":
if self.model.current_session.status == "post_session":
pass #self.view.

def pause_resume(self):
if self.model.status == "running":
self.model.status = "paused"
if self.model.current_session.status == "running":
self.model.current_session.status = "paused"
self.view.timing_screen.start_btn.configure(text="Resume", image=self.view.play_icon2)
elif self.model.status == "paused":
self.model.status = "running"
elif self.model.current_session.status == "paused":
self.model.current_session.status = "running"
self.view.timing_screen.start_btn.configure(text="Pause", image=self.view.pause_icon2)
self.start_session()

Expand All @@ -57,17 +57,23 @@ def go_to_race(self):
pass

def go_to_session(self, session):
self.model.setup_session(session)
if "FP" in session:
self.model.setup_practice(20*60, session)
elif "Q" in session:
self.model.setup_qualfying(60*60, session)
elif "race" in session:
self.model.setup_race()

self.view.launch_session(session)
self.view.timing_screen.update_view(self.model.get_data_for_view())
self.view.timing_screen.update_view(self.model.current_session.get_data_for_view())

def end_session(self, session):
self.model.end_session(session)
self.model.current_session.end_session(session)
self.view.end_session(session, self.model.results[session])

def auto_simulate_session(self, session):
self.model.simulate_session(session)
self.end_session(session)

def send_player_car_out(self, driver_name, fuel_load_laps, number_laps_to_run):
self.model.send_player_car_out(driver_name, fuel_load_laps, number_laps_to_run)
self.model.current_session.send_player_car_out(driver_name, fuel_load_laps, number_laps_to_run)
7 changes: 7 additions & 0 deletions src/race_engine_model/commentary.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ def gen_leaving_pit_lane_message(driver):
f"{driver} heading out on track!"
]

return random.choice(messages)

def gen_entering_pit_lane_message(driver):
messages = [
f"{driver} dives into the pits!"
]

return random.choice(messages)
Loading

0 comments on commit 65166fa

Please sign in to comment.