enhance store files naming
This commit is contained in:
@ -36,7 +36,6 @@ class Player:
|
||||
decision = self.make_decision(start_response.client_data)
|
||||
|
||||
decision_counter = 0
|
||||
store_game_round_data(start_response, decision_counter, str(start_response.session_id))
|
||||
|
||||
while status not in ['gameover', 'complete']:
|
||||
payload = GameDecisionRequestDTO(
|
||||
@ -50,12 +49,19 @@ class Player:
|
||||
status = decision_response.status
|
||||
decision = self.make_decision(decision_response.client_data)
|
||||
|
||||
store_game_round_data(decision_response, decision_counter, str(start_response.session_id))
|
||||
# Handle first response from game initialization logic
|
||||
if decision_counter == 0:
|
||||
# Store start response
|
||||
store_game_round_data(decision, start_response, decision_counter, str(start_response.session_id) ,status)
|
||||
else:
|
||||
# store ongoing decision response
|
||||
store_game_round_data(decision, decision_response, decision_counter, str(start_response.session_id), status)
|
||||
|
||||
decision_counter += 1
|
||||
time.sleep(1.5)
|
||||
|
||||
|
||||
|
||||
def make_decision(self, client_data: Dict[str, Any]) -> Literal["Accept", "Reject"]:
|
||||
# Do your magic!
|
||||
|
||||
|
@ -10,7 +10,7 @@ GAME_FILES_DIR = config.GAME_FILES_DIR
|
||||
# Define padding for round numbers (e.g., 6 digits for up to 999,999 rounds)
|
||||
FOLDER_ROUND_PADDING = 6
|
||||
|
||||
def store_game_round_data(response: GameStartResponseDTO | GameDecisionResponseDTO, round_number: int, session_id: str):
|
||||
def store_game_round_data(decision: str, response: GameStartResponseDTO | GameDecisionResponseDTO, round_number: int, session_id: str, status: str):
|
||||
"""
|
||||
Logs structured response data and saves associated client files.
|
||||
"""
|
||||
@ -18,7 +18,7 @@ def store_game_round_data(response: GameStartResponseDTO | GameDecisionResponseD
|
||||
|
||||
try:
|
||||
padded_round = str(round_number).zfill(FOLDER_ROUND_PADDING)
|
||||
round_folder_name = f"{padded_round}_decision"
|
||||
round_folder_name = f"{padded_round}_decision_{decision.lower()}_{status.lower()}"
|
||||
|
||||
# Construct the directory path: base_dir / session_id / decision_XXXXXX
|
||||
round_dir = os.path.join(GAME_FILES_DIR, str(session_id), round_folder_name)
|
||||
|
Reference in New Issue
Block a user