Skip to content

Commit 4bd1391

Browse files
committed
In the "Date" utility module I created the new method "Create_Time_Format".
It takes a dictionary of time units and creates its time format from it. Example: 1 hour, 30 minutes, and seconds would be 01:30:04. I also added several comments to the "Difference" method to make it easier to understand. I removed the old "Time_Text" method, which performed the function of the two methods "Make_Time_Text" and "Create_Time_Format", and was obsolete.
1 parent 5080ded commit 4bd1391

File tree

12 files changed

+457
-236
lines changed

12 files changed

+457
-236
lines changed

Module files/Food_Time/Times.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"Will be hungry": 3
1111
},
1212
"Ate": {
13-
"Object": "2024-07-10 17:48:22-03:00",
13+
"Object": "2024-07-31 16:43:40-03:00",
1414
"Time": 0,
15-
"Time text": "17:48",
15+
"Time text": "16:43",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2024-07-10 18:28:22-03:00",
26+
"Object": "2024-07-31 17:23:40-03:00",
2727
"Time": 40,
28-
"Time text": "18:28",
28+
"Time text": "17:23",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2024-07-10 20:48:22-03:00",
39+
"Object": "2024-07-31 19:43:40-03:00",
4040
"Time": 3,
41-
"Time text": "20:48",
41+
"Time text": "19:43",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module files/GamePlayer/Texts.json

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@
115115
"en": "Write a description for the gaming session",
116116
"pt": "Escrever uma descrição para a sessão de jogatina"
117117
},
118+
"gaming_session_description": {
119+
"en": "Gaming session description",
120+
"pt": "Descrição da sessão de jogatina"
121+
},
118122
"post_on_the_social_networks": {
119123
"en": "Post on the Social Networks",
120124
"pt": "Postar nas Redes Sociais"

Module files/Utility/Language/Texts.json

+4
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@
14531453
"en": "Description",
14541454
"pt": "Descrição"
14551455
},
1456+
"description_in_{}": {
1457+
"en": "Description in {}",
1458+
"pt": "Descrição em {}"
1459+
},
14561460
"steam, title()": {
14571461
"en": "Steam",
14581462
"pt": "Steam"

Modules/GamePlayer/Register/__init__.py

+121-29
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ def __init__(self, dictionary = {}):
1919
},
2020
"Diary Slim": {
2121
"Text": "",
22-
"Clean text": ""
22+
"Clean text": "",
23+
"Descriptions": {},
24+
"Write description": False
2325
},
2426
"States": {
2527
"Post on the Social Networks": False
@@ -29,14 +31,19 @@ def __init__(self, dictionary = {}):
2931
# Define the media variable to make typing the media dictionary easier
3032
self.game = self.dictionary["Game"]
3133

34+
# Check the game status
3235
self.Check_Game_Status()
3336

3437
if (
3538
self.game["States"]["Re-playing"] == False and
3639
self.game["States"]["Completed game"] == True
3740
):
41+
# Check the game dates
3842
self.Check_Game_Dates()
3943

44+
# Ask the user if it wants to write a description for the gaming session
45+
self.Ask_For_Gaming_Session_Description()
46+
4047
# Database related methods
4148
self.Register_In_JSON()
4249
self.Create_Entry_File()
@@ -45,8 +52,10 @@ def __init__(self, dictionary = {}):
4552
# Diary Slim related methods
4653
self.Define_Diary_Slim_Text()
4754

55+
# Post the gaming session on the social networks
4856
self.Post_On_Social_Networks()
4957

58+
# Write the information about the session on Diary Slim
5059
self.Write_On_Diary_Slim()
5160

5261
# Show the information about the game session
@@ -83,6 +92,50 @@ def Type_Entry_Information(self):
8392
# Get the dictionary from the "Play" class with the session and time related keys
8493
self.dictionary = self.Play.dictionary
8594

95+
def Ask_For_Gaming_Session_Description(self):
96+
# Ask the user if it wants to write a description for the gaming session
97+
print()
98+
print(self.separators["5"])
99+
100+
self.dictionary["Entry"]["Diary Slim"]["Write description"] = self.Input.Yes_Or_No(self.language_texts["write_a_description_for_the_gaming_session"])
101+
102+
# If the user wants to write a description
103+
if self.dictionary["Entry"]["Diary Slim"]["Write description"] == True:
104+
# Define the keyword parameters dictionary
105+
parameters = {
106+
"line_options_parameter": {
107+
"print": True,
108+
"next_line": False,
109+
"show_finish_text": True
110+
}
111+
}
112+
113+
# Iterate through the small languages list
114+
for language in self.languages["small"]:
115+
# If the language is not the first one
116+
if language != self.languages["small"][0]:
117+
# Enumerate the lines
118+
parameters["line_options_parameter"]["enumerate"] = True
119+
parameters["line_options_parameter"]["enumerate_text"] = False
120+
121+
# Get the last description
122+
last_description = list(self.dictionary["Entry"]["Diary Slim"]["Descriptions"].values())[0]
123+
124+
# Define the number of needed lines as the number of lines of the previous description
125+
parameters["length"] = last_description["length"]
126+
127+
# Get the translated language in the user language
128+
translated_language = self.languages["full_translated"][language][self.user_language]
129+
130+
# Define the type text
131+
type_text = self.Language.language_texts["description_in_{}"] + ":"
132+
133+
# Format it
134+
type_text = type_text.format(translated_language)
135+
136+
# Ask the user to type a session description
137+
self.dictionary["Entry"]["Diary Slim"]["Descriptions"][language] = self.Input.Lines(type_text, **parameters)
138+
86139
def Register_In_JSON(self):
87140
self.game_type = self.dictionary["Type"]["Type"]["en"]
88141

@@ -257,6 +310,9 @@ def Create_Entry_File(self):
257310
#
258311
# Session duration:
259312
# [Session duration]
313+
#
314+
# Session description:
315+
# [Session description]
260316
#
261317
# File name:
262318
# [Number. Type (Time)]
@@ -299,12 +355,16 @@ def Define_File_Text(self, language_parameter = None):
299355

300356
full_language = self.languages["full"][language]
301357

358+
# ---------- #
359+
302360
# Define the entry text lines
303361
lines = [
304362
self.Language.texts["number, title()"][language] + ": " + str(self.dictionaries["Sessions"]["Numbers"]["Total"]),
305363
self.Language.texts["type_number"][language] + ": " + str(self.dictionaries["Game type"][self.game_type]["Numbers"]["Total"])
306364
]
307365

366+
# ---------- #
367+
308368
# Add the entry title lines
309369
if language_parameter != "General":
310370
text = self.Language.texts["title, title()"][language]
@@ -314,6 +374,8 @@ def Define_File_Text(self, language_parameter = None):
314374

315375
lines.append("\n" + text + ":" + "\n" + "{}")
316376

377+
# ---------- #
378+
317379
# If the game has sub-games
318380
# And the sub-game title is not the same as the game title
319381
if (
@@ -325,16 +387,36 @@ def Define_File_Text(self, language_parameter = None):
325387

326388
lines.append(text + ":" + "\n" + "{}")
327389

390+
# ---------- #
391+
328392
# Add the rest of the lines
329393
lines.extend([
330394
self.Language.texts["type, title()"][language] + ":" + "\n" + self.dictionary["Type"]["Type"][language] + "\n",
331395
self.Language.texts["platform, title()"][language] + ":" + "\n" + self.game["Platform"][language] + "\n",
332396
self.Date.texts["times, title()"][language] + ":" + "\n" + "{}",
333-
self.Language.texts["session_duration"][language] + ":" + "\n" + "{}",
334-
self.Language.texts["entry, title()"][language] + ":" + "\n" + self.dictionary["Entry"]["Name"]["Normal"]
397+
self.Language.texts["session_duration"][language] + ":" + "\n" + "{}"
335398
])
336399

337-
# Add states texts lines
400+
# ---------- #
401+
402+
# If the user wrote a description for the gaming session
403+
if self.dictionary["Entry"]["Diary Slim"]["Write description"] == True:
404+
# Define the description text
405+
text = self.texts["gaming_session_description"][language] + ":" + "\n" + "{}"
406+
407+
# Add it to the list of lines
408+
lines.append(text)
409+
410+
# ---------- #
411+
412+
# Add the entry name
413+
entry = self.Language.texts["entry, title()"][language] + ":" + "\n" + self.dictionary["Entry"]["Name"]["Normal"]
414+
415+
lines.append(entry)
416+
417+
# ---------- #
418+
419+
# Add the states text lines
338420
if self.dictionary["States"]["Texts"] != {}:
339421
text = "\n" + self.Language.texts["states, title()"][language] + ":" + "\n"
340422

@@ -348,9 +430,13 @@ def Define_File_Text(self, language_parameter = None):
348430

349431
lines.append(text)
350432

433+
# ---------- #
434+
351435
# Define items to be added to file text format
352436
items = []
353437

438+
# ---------- #
439+
354440
# Add the entry titles to the items list
355441
titles = []
356442

@@ -375,6 +461,8 @@ def Define_File_Text(self, language_parameter = None):
375461

376462
items.append(self.Text.From_List(titles, break_line = True) + "\n")
377463

464+
# ---------- #
465+
378466
# If the game has sub-games
379467
# And the sub-game title is not the same as the game title
380468
if (
@@ -394,9 +482,9 @@ def Define_File_Text(self, language_parameter = None):
394482

395483
items.append(times)
396484

397-
# Add session duration to items list
398-
session_duration = self.dictionary["Entry"]["Session duration"]["Text"][language] + "\n"
485+
# ---------- #
399486

487+
# Add the session duration to the list of items
400488
if language_parameter != "General":
401489
session_duration = self.dictionary["Entry"]["Session duration"]["Text"][language] + "\n"
402490

@@ -411,7 +499,31 @@ def Define_File_Text(self, language_parameter = None):
411499

412500
items.append(session_duration)
413501

414-
# Define language entry text
502+
# ---------- #
503+
504+
# If the user wrote a description for the gaming session
505+
if self.dictionary["Entry"]["Diary Slim"]["Write description"] == True:
506+
# Get the description in the current language
507+
if language_parameter != "General":
508+
description = self.dictionary["Entry"]["Diary Slim"]["Descriptions"][language]["string"] + "\n"
509+
510+
# If the language parameter is "General"
511+
if language_parameter == "General":
512+
# Create the descriptions text in all languages
513+
description = ""
514+
515+
for language in self.languages["small"]:
516+
text = self.dictionary["Entry"]["Diary Slim"]["Descriptions"][language]["string"] + "\n"
517+
518+
if text not in description:
519+
description += text
520+
521+
# Add the description to the list of items
522+
items.append(description)
523+
524+
# ---------- #
525+
526+
# Define the language entry text
415527
file_text = self.Text.From_List(lines, break_line = True)
416528

417529
return file_text.format(*items)
@@ -589,30 +701,10 @@ def Define_Diary_Slim_Text(self):
589701

590702
self.dictionary["Entry"]["Diary Slim"]["Clean text"] = self.dictionary["Entry"]["Diary Slim"]["Text"]
591703

592-
# Ask the user if it wants to write a description for the gaming session
593-
print()
594-
print(self.separators["5"])
595-
596-
self.dictionary["Entry"]["Diary Slim"]["Write description"] = self.Input.Yes_Or_No(self.language_texts["write_a_description_for_the_gaming_session"])
597-
704+
# If the user wants to write a description
598705
if self.dictionary["Entry"]["Diary Slim"]["Write description"] == True:
599-
# Define the type text
600-
type_text = self.Language.language_texts["description, title()"] + ":"
601-
602-
# Define the keyword parameters dictionary
603-
parameters = {
604-
"line_options_parameter": {
605-
"print": True,
606-
"next_line": False,
607-
"show_finish_text": True
608-
}
609-
}
610-
611-
# Ask the user to type a session description
612-
self.dictionary["Entry"]["Diary Slim"]["Description"] = self.Input.Lines(type_text, **parameters)
613-
614706
# Add the session description to the "Diary Slim" text
615-
self.dictionary["Entry"]["Diary Slim"]["Text"] += "\n\n" + self.dictionary["Entry"]["Diary Slim"]["Description"]["string"]
707+
self.dictionary["Entry"]["Diary Slim"]["Text"] += "\n\n" + self.dictionary["Entry"]["Diary Slim"]["Descriptions"][self.user_language]["string"]
616708

617709
# If there are states, add the texts to the Diary Slim text
618710
if self.dictionary["States"]["States"] != {}:

0 commit comments

Comments
 (0)