Skip to content

Commit 2e0448c

Browse files
committed
On the "Project_Zomboid" module, on its sub-class "Create_Survival_Diary_File", I have made the following changes:
I moved the date definition of the diary file to a new method called "Define_Date". I created the new root method "Define_Date_Dictionary", so as not to repeat the method code in two different places. Now the "Define_Date" method checks whether the diary's current day is the month's last day. If so, it utilizes the new root method "Verify_Diary_Date" to verify the date. The method verifies whether the current month is the last month of the year. If so, it moves to the next diary year, and changes the month to the first, modifying the year and month folder. If not, it moves to the next diary month, modifying only the month folder. In either case, it resets the day to the first, as the month is modified in both cases.
1 parent a6022af commit 2e0448c

File tree

8 files changed

+100
-60
lines changed

8 files changed

+100
-60
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-04-16 00:55:16-03:00",
13+
"Object": "2024-04-18 12:36:01-03:00",
1414
"Time": 0,
15-
"Time text": "00:55",
15+
"Time text": "12:36",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2024-04-16 01:35:16-03:00",
26+
"Object": "2024-04-18 13:16:01-03:00",
2727
"Time": 40,
28-
"Time text": "01:35",
28+
"Time text": "13:16",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2024-04-16 03:55:16-03:00",
39+
"Object": "2024-04-18 15:36:01-03:00",
4040
"Time": 3,
41-
"Time text": "03:55",
41+
"Time text": "15:36",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module Files/Project_Zomboid/Texts.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
"en": "Select a survivor to survive as them",
1212
"pt": "Selecione um sobrevivente para sobreviver como ele"
1313
},
14-
"the_class_a_survivor": {
14+
"the_class_used_a_survivor": {
1515
"en": "The class used a predefined survivor",
1616
"pt": "A classe utilizou um sobrevivente pré-definido"
1717
},
1818
"this_survival_diary_file_was_created": {
1919
"en": "This survivor diary file was created",
2020
"pt": "Este arquivo de diário de sobrevivente foi criado"
21-
},
22-
"kentucky_united_states": {
23-
"pt": "Kentucky, Estados Unidos",
24-
"en": "Kentucky, United States"
2521
}
2622
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"testing": true,
3-
"verbose": true,
2+
"testing": false,
3+
"verbose": false,
44
"user_information": false,
55
"Has active switches": false
66
}

Modules/Diary_Slim/Write_On_Diary_Slim/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def Write(self):
492492
Write_On_Diary_Slim_Module(dictionary)
493493

494494
# Open the current Diary Slim file
495-
self.System.Open(self.diary_slim["Current year"]["Current Diary Slim file"])
495+
self.System.Open(self.diary_slim["Current year"]["Current Diary Slim file"], verbose = False)
496496

497497
# Show a five dash space separator
498498
print()

Modules/Diary_Slim/Write_On_Diary_Slim_Module/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ def __init__(self, dictionary = {}):
2525
}
2626

2727
# Get the keys and values from the "dictionary" parameter
28+
self.Update_Dictionary(dictionary)
2829

30+
# Write the text to the current Diary Slim
31+
self.Write()
32+
33+
def Update_Dictionary(self, dictionary):
2934
# Get the "Text" key
3035
if "Text" in dictionary:
3136
self.dictionary["Texts"]["To write"] = dictionary["Text"]
@@ -55,8 +60,6 @@ def __init__(self, dictionary = {}):
5560
if key in dictionary:
5661
self.dictionary[key] = dictionary[key]
5762

58-
self.Write()
59-
6063
def Write(self):
6164
# If the time string is empty, get a time string from the current date
6265
if self.dictionary["Time string"] == "":

Modules/Project_Zomboid/Create_Survival_Diary_File/__init__.py

+24-18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def __init__(self):
2323
# Select the survivor
2424
self.Select_A_Survivor()
2525

26+
# Define the "Date" dictionary
27+
self.Define_Date()
28+
2629
# Update the information about the survivor (dates, survival day, files)
2730
self.Update_Information()
2831

@@ -58,28 +61,31 @@ def Select_A_Survivor(self):
5861

5962
self.dictionary["City"] = self.project_zomboid["Cities"]["Dictionary"][city]
6063

61-
def Update_Information(self):
62-
# Define the "dates" variable for easier typing
63-
self.dates = self.dictionary["Survivor"]["Diary"]
64-
65-
# Add one to the day number
66-
self.dates["Numbers"]["Day"] += 1
64+
def Define_Date(self):
65+
# Define the "diary" variable for easier typing
66+
self.diary = self.dictionary["Survivor"]["Diary"]
6767

68-
# Add one to the survival day number
69-
self.dates["Numbers"]["Survival day"] += 1
68+
# Define the "Date" dictionary
69+
self.dictionary = self.Define_Date_Dictionary(self.dictionary)
7070

71-
# Update the "Survivor.json" file with the root "Update_Dictionary"
72-
self.Update_Dictionary(self.dictionary["Survivor"])
71+
# If the current day is not the same as the number of days in the month
72+
if int(self.diary["Numbers"]["Day"]) != self.dictionary["Date"]["Units"]["Month days"]:
73+
# Add one to the day number
74+
self.diary["Numbers"]["Day"] += 1
7375

74-
# ---------- #
76+
# If the current day is the same as the number of days in the month
77+
# (Last day of month)
78+
if int(self.diary["Numbers"]["Day"]) == self.dictionary["Date"]["Units"]["Month days"]:
79+
# Verify the survivor diary date
80+
self.dictionary = self.Verify_Diary_Date(self.dictionary)
7581

76-
# Define the date
77-
day = str(self.dates["Numbers"]["Day"])
78-
month = self.Text.Add_Leading_Zeroes(self.dates["Numbers"]["Month"])
79-
year = str(self.dates["Numbers"]["Year"])
82+
# Add one to the survival day number
83+
self.diary["Numbers"]["Survival day"] += 1
8084

81-
self.dictionary["Date"] = self.Date.From_String(day + "/" + month + "/" + year, format = "%d/%m/%Y")
85+
# Update the "Survivor.json" file with the root "Update_Dictionary" method
86+
self.Update_Dictionary(self.dictionary["Survivor"])
8287

88+
def Update_Information(self):
8389
# Define the "File" dictionary
8490
self.dictionary["File"] = {}
8591

@@ -88,7 +94,7 @@ def Update_Information(self):
8894

8995
# Define the list of items of the file name template
9096
items = [
91-
str(self.dates["Numbers"]["Survival day"]), # The survival day
97+
str(self.diary["Numbers"]["Survival day"]), # The survival day
9298
self.dictionary["Date"]["Texts"]["Day name"][self.user_language], # The day name in the user language
9399
self.dictionary["Date"]["Formats"]["DD-MM-YYYY"] # And the "Day-Month-Year" format of the current date
94100
]
@@ -103,7 +109,7 @@ def Update_Information(self):
103109
"\n\n"
104110

105111
# Define the number name of the day
106-
day_number_name = self.Date.language_texts["number_names, type: list"][self.dates["Numbers"]["Day"]].capitalize()
112+
day_number_name = self.Date.language_texts["number_names, type: list"][self.diary["Numbers"]["Day"]].capitalize()
107113

108114
# Define the list of items of the diary template
109115
items = [

Modules/Project_Zomboid/Project_Zomboid/__init__.py

+61-2
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def Create_The_Survivor_Dictionaries(self):
360360
numbers = survivor["Diary"]["Numbers"]
361361

362362
year = str(numbers["Year"])
363-
month = self.Text.Add_Leading_Zeroes(numbers["Month"])
363+
month = str(self.Text.Add_Leading_Zeroes(numbers["Month"]))
364364
day = str(numbers["Day"])
365365

366366
# Define the "Date" dictionary
@@ -486,4 +486,63 @@ def Update_Dictionary(self, dictionary, copy = True):
486486
dictionary["Diary"].pop("Folders")
487487

488488
# Update the dictionary JSON file with the updated dictionary
489-
self.JSON.Edit(json_file, dictionary)
489+
self.JSON.Edit(json_file, dictionary)
490+
491+
def Define_Date_Dictionary(self, dictionary):
492+
# Define the "diary" variable
493+
diary = dictionary["Survivor"]["Diary"]
494+
495+
# Define the "Date" dictionary
496+
day = str(diary["Numbers"]["Day"])
497+
month = str(self.Text.Add_Leading_Zeroes(diary["Numbers"]["Month"]))
498+
year = str(diary["Numbers"]["Year"])
499+
500+
dictionary["Date"] = self.Date.From_String(day + "/" + month + "/" + year, format = "%d/%m/%Y")
501+
502+
return dictionary
503+
504+
def Verify_Diary_Date(self, dictionary):
505+
# Define the "diary" variable
506+
diary = dictionary["Survivor"]["Diary"]
507+
508+
# If the current month is the last month
509+
if diary["Numbers"]["Month"] == 12:
510+
# Add one to the year number
511+
diary["Numbers"]["Year"] += 1
512+
513+
# Reset the month number to one
514+
diary["Numbers"]["Month"] = 1
515+
516+
# Define and create the year folder
517+
diary["Folders"]["Year"] = {
518+
"root": diary["Folders"]["root"] + str(diary["Numbers"]["Year"]) + "/"
519+
}
520+
521+
self.Folder.Create(diary["Folders"]["Year"]["root"])
522+
523+
# If the current month is not the last month
524+
else:
525+
# Add one to the month number
526+
diary["Numbers"]["Month"] += 1
527+
528+
# Reset the day number to one
529+
diary["Numbers"]["Day"] = 1
530+
531+
# Re-define the "Date" dictionary
532+
self.dictionary = self.Define_Date_Dictionary(self.dictionary)
533+
534+
# Get the month name with number in the user language
535+
month_name_with_number = self.dictionary["Date"]["Texts"]["Month name with number"][self.user_language]
536+
537+
# Define and create the month folder
538+
diary["Folders"]["Year"]["Month"] = {
539+
"root": diary["Folders"]["Year"]["root"] + month_name_with_number + "/"
540+
}
541+
542+
self.Folder.Create(diary["Folders"]["Year"]["Month"]["root"])
543+
544+
# Make a shortcut to the month folder
545+
diary["Folders"]["Month"] = diary["Folders"]["Year"]["Month"]
546+
547+
# Return the dictionary
548+
return dictionary

Modules/Utility/Text/__init__.py

-24
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,6 @@ def Copy(self, text, verbose = True):
9898

9999
self.Verbose(self.language_texts["copied_text"], "[" + text + "]", verbose = verbose)
100100

101-
def Old_From_List(self, list_, break_line = True, separator = "", and_text = True):
102-
string = ""
103-
104-
i = 0
105-
for item in list_:
106-
string += item
107-
108-
if i != len(list_) - 1:
109-
if separator != "":
110-
string += separator
111-
112-
if break_line == True:
113-
string += "\n"
114-
115-
if (
116-
i == len(list_) - 2 and
117-
and_text == True
118-
):
119-
string += self.Language.language_texts["and"] + " "
120-
121-
i += 1
122-
123-
return string
124-
125101
def From_List(self, list_, language = None, lower = False, break_line = False, and_text = True, or_text = False, quotes = False):
126102
text = ""
127103

0 commit comments

Comments
 (0)