Skip to content

Commit 257aed1

Browse files
committed
On the "Stories" module, on its sub-class "Create_New_Story", I completely reworked it to improve its methods.
The method "Type_Story_Information" is now much better. It creates the story dictionary with the new format used by the root class. Asking for story titles in all supported languages, and story information. Such as creation date, writing status, synopsis in supported languages, and the author of the story. Now there is a file called "Information items" in the stories database folder. It is read by the new root method "Define_Information_Items". Which defines the texts, formats, and methods of information items. The information item "Creation date" forces information to be in the format of hours, minutes, days, month, and year. The synopsis is requested in all supported languages, with various lines in the synopsis for each language. The new root methods "Select_Status" and "Select_Author" are used to select their respective information items. These methods are defined in each information item dictionary, by the root method "Define_Information_Items". Then the method "Type_Story_Information" creates all story information dictionaries, such as readers, pack, and writing, among others. The new method "Create_Story_Folders" creates the story's root folder. And also the sub-folders and files, using the root method "Create_Story_Sub_Folders". The new method "Update_Files" writes story information to the synopsis files and authors file. And also on the files of creation date, readers, chapters, Wattpad, writing, and the story file in JSON. Then the new method "Add_To_Stories_List" adds the story to the stories list and dictionary, and story titles lists. After that, the sub-class "Show_Story_Information" is imported as a module and is executed, showing information about the newly added story.
1 parent d77170d commit 257aed1

File tree

14 files changed

+827
-273
lines changed

14 files changed

+827
-273
lines changed

Module Files/Food_Time/Times.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"Will be hungry": 3
1111
},
1212
"Ate": {
13-
"Object": "2024-04-23 20:59:33-03:00",
13+
"Object": "2024-04-25 22:58:19-03:00",
1414
"Time": 0,
15-
"Time text": "20:59",
15+
"Time text": "22:58",
1616
"Unit": {
1717
"en": "hours",
1818
"pt": "horas"
@@ -23,9 +23,9 @@
2323
}
2424
},
2525
"Can drink water": {
26-
"Object": "2024-04-23 21:39:33-03:00",
26+
"Object": "2024-04-25 23:38:19-03:00",
2727
"Time": 40,
28-
"Time text": "21:39",
28+
"Time text": "23:38",
2929
"Unit": {
3030
"en": "minutes",
3131
"pt": "minutos"
@@ -36,9 +36,9 @@
3636
}
3737
},
3838
"Will be hungry": {
39-
"Object": "2024-04-23 23:59:33-03:00",
39+
"Object": "2024-04-26 01:58:19-03:00",
4040
"Time": 3,
41-
"Time text": "23:59",
41+
"Time text": "01:58",
4242
"Unit": {
4343
"en": "hours",
4444
"pt": "horas"

Module Files/Stories/Texts.json

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"story_title_in": {
3+
"en": "Story title in",
4+
"pt": "Título da história em"
5+
},
26
"chapter, title()": {
37
"en": "Chapter",
48
"pt": "Capítulo"
@@ -99,13 +103,13 @@
99103
"en": "The last chapter",
100104
"pt": "O último capítulo"
101105
},
102-
"story_title_in_{}": {
103-
"en": "Story title in {}",
104-
"pt": "Título da história em {}"
106+
"type_the_information_of_the_story": {
107+
"en": "Type the information of the story",
108+
"pt": "Digite as informações da história"
105109
},
106-
"story_synopsis_in_{}": {
107-
"en": "Story synopsis in {}",
108-
"pt": "Sinopse da história em {}"
110+
"story_synopsis_in": {
111+
"en": "Story synopsis in",
112+
"pt": "Sinopse da história em"
109113
},
110114
"writing_modes, type: list": {
111115
"en": [
@@ -341,26 +345,6 @@
341345
"en": "You finished copying the chapter titles of this story",
342346
"pt": "Você terminou de copiar os títulos de capítulo desta história"
343347
},
344-
"first_track": {
345-
"en": "First track",
346-
"pt": "Primeira faixa"
347-
},
348-
"information_items, type: list": {
349-
"en": [
350-
"Title",
351-
"Author",
352-
"Creation date",
353-
"Status",
354-
"Synopsis"
355-
],
356-
"pt": [
357-
"Título",
358-
"Autor",
359-
"Data de criação",
360-
"Status",
361-
"Sinopse"
362-
]
363-
},
364348
"status, type: list": {
365349
"en": [
366350
"Writing",
@@ -379,12 +363,24 @@
379363
"Em pausa"
380364
]
381365
},
366+
"writing_status": {
367+
"en": "Writing status",
368+
"pt": "Status de escrita"
369+
},
382370
"writing_statuses": {
383371
"en": "Writing statuses",
384-
"pt": "Estados de escrita"
372+
"pt": "Status de escrita"
385373
},
386374
"select_a_writing_status": {
387375
"en": "Select a writing status",
388-
"pt": "Selecione um estado de escrita"
376+
"pt": "Selecione um status de escrita"
377+
},
378+
"do_you_want_to_add_more_authors": {
379+
"en": "Do you want to add more authors",
380+
"pt": "Você quer adicionar mais autores"
381+
},
382+
"select_an_additional_author": {
383+
"en": "Select an additional author",
384+
"pt": "Selecione um autor adicional"
389385
}
390386
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"testing": false,
3-
"verbose": true,
3+
"verbose": false,
44
"user_information": false,
55
"Has active switches": false
66
}

Modules/Diary_Slim/Diary_Slim/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ def Define_Story_Information(self):
433433
self.story = {
434434
"Titles": {},
435435
"Chapters": {
436-
"Number": 0,
436+
"Numbers": {
437+
"Total": 0
438+
},
437439
"List": []
438440
},
439441
"Status": {
@@ -455,10 +457,8 @@ def Define_Story_Information(self):
455457
# Get the "Titles" dictionary from the "Titles.json" file
456458
self.story["Titles"] = self.JSON.To_Python(self.diary_slim["Folders"]["Story"]["Titles"])
457459

458-
# If the number of chapters is 0 (zero)
459-
if self.story["Chapters"]["Number"] == 0:
460-
# Define the number of chapters as the number of Diary Slims
461-
self.story["Chapters"]["Number"] = self.history["Numbers"]["Diary Slims"]
460+
# Define the number of chapters as the number of Diary Slims
461+
self.story["Chapters"]["Numbers"]["Total"] = self.history["Numbers"]["Diary Slims"]
462462

463463
# Update the "Story.json" file with the updated "Story" dictionary
464464
self.JSON.Edit(self.diary_slim["Folders"]["Story"]["Story"], self.story)

Modules/Diary_Slim/Write_On_Diary_Slim/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,16 @@ def Define_Item_Variables(self):
251251
# That means the user must type the data (string)
252252
# And not select it (from a list of options)
253253
if "Options" not in self.dictionary["Text"]:
254-
# Ask the user to type the data in the user language
255-
self.dictionary["Text"]["Data"][self.user_language] = self.Input.Type(self.language_texts[self.dictionary["Text"]["Type text"]])
254+
# Iterate through the small languages list
255+
for language in self.languages["small"]:
256+
# Get the translated language in the user language
257+
translated_language = self.languages["full_translated"][language][self.user_language]
258+
259+
# Define the type text
260+
type_text = self.language_texts[self.dictionary["Text"]["Type text"]] + " " + self.Language.language_texts["genders, type: dict"]["in"] + " " + translated_language
261+
262+
# Ask the user to type the data in each language
263+
self.dictionary["Text"]["Data"][language] = self.Input.Type(type_text)
256264

257265
# If the "Options" key is inside the Text dictionary
258266
# That means the user must select the data from a list of options

Modules/Friends/Friends/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ def __init__(self):
2323
self.Define_Folders_And_Files()
2424

2525
# Class methods
26+
27+
# Define the "Information items" dictionary
2628
self.Define_Information_Items()
29+
30+
# Define the "Friends" dictionary
2731
self.Define_Friends_Dictionary()
2832

2933
def Define_Basic_Variables(self):
@@ -222,13 +226,15 @@ def Define_Information_Items(self):
222226
# Define the text key
223227
text_key = key.lower().replace(" ", "_")
224228

229+
# Define the text addon
225230
addon = ""
226231

227232
if "_" not in text_key:
228233
addon = ", title()"
229234

230235
# Iterate through the small languages list
231236
for language in self.languages["small"]:
237+
# Get the information text
232238
text = self.Language.texts[text_key + addon][language]
233239

234240
# Define the language information item inside the local "dict_" dictionary
@@ -281,6 +287,7 @@ def Define_Information_Items(self):
281287
"Example": ""
282288
}
283289

290+
# If the key is in the "Formats" dictionary, use the format dictionary inside it
284291
if key in dictionary["Formats"]:
285292
dict_["Format"] = dictionary["Formats"][key]
286293

Modules/Project_Zomboid/Add_A_New_Survivor/__init__.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def __init__(self):
1515
# Type the information about the survivor
1616
self.Type_Survivor_Information()
1717

18+
# Create the folder of the survivor
19+
self.Create_Survivor_Folder()
20+
1821
# Update the files of the survivor
1922
self.Update_Files()
2023

@@ -52,6 +55,8 @@ def Type_Survivor_Information(self):
5255
# Ask for the name of the survivor
5356
survivor["Name"] = self.Input.Type(self.language_texts["type_the_name_of_the_survivor"], accept_enter = False, next_line = True)
5457

58+
# ---------- #
59+
5560
# Show the text telling the user to type the details about the survivor
5661
print()
5762
print(self.separators["5"])
@@ -67,13 +72,13 @@ def Type_Survivor_Information(self):
6772
}
6873
},
6974
"Age": {
70-
"Regex": {
75+
"Format": {
7176
"Regex": "^([2][7-9]|[3-9][0-9]|100)$",
7277
"Example": "27"
7378
}
7479
},
7580
"Date of birth": {
76-
"Regex": {
81+
"Format": {
7782
"Regex": "^(0[0-9]|3[0-1])/(0[0-9]|1[0-2])/(1893|196[0-6]|19[0-5][0-9])$",
7883
"Example": "01/01/1966"
7984
}
@@ -103,32 +108,32 @@ def Type_Survivor_Information(self):
103108
plural_text = self.Language.language_texts[text_key]
104109

105110
# Define the parameters dictionary for the "Select" method of the "Input" class
106-
dictionary = {
111+
parameters = {
107112
"options": detail["Lists"]["en"],
108113
"language_options": detail["Lists"]["Language"],
109114
"show_text": text,
110115
"select_text": plural_text
111116
}
112117

113118
# Ask the user to select an option from the list
114-
typed = self.Input.Select(**dictionary)["option"]
119+
typed = self.Input.Select(**parameters)["option"]
115120

116-
# If the "Regex" key is inside the "Detail" dictionary
117-
if "Regex" in detail:
118-
# Define the regex variable for easier typing
119-
regex = detail["Regex"]
121+
# If the "Format" key is inside the "Detail" dictionary
122+
if "Format" in detail:
123+
# Define the format variable for easier typing
124+
format = detail["Format"]
120125

121126
# Update the detail text to add the example
122127
new_text = text + ":" + "\n" + \
123-
"(" + self.Language.language_texts["leave_empty_to_use_the_default_value"] + ': "' + regex["Example"] + '")'
128+
"(" + self.Language.language_texts["leave_empty_to_use_the_default_value"] + ': "' + format["Example"] + '")'
124129

125130
# Ask for the detail
126131
typed = self.Input.Type(new_text, next_line = True)
127132

128133
# If the typed value is an empty string
129134
if typed == "":
130135
# Define the typed variable as the default detail value
131-
typed = regex["Example"]
136+
typed = format["Example"]
132137

133138
# Show the default detail
134139
print(text + ":")
@@ -140,16 +145,18 @@ def Type_Survivor_Information(self):
140145
import re
141146

142147
# Search for the regex in the typed value
143-
search = re.search(regex["Regex"], typed)
148+
search = re.search(format["Regex"], typed)
144149

145150
# If the value does not match the regex
146151
if search == None:
147152
# Ask for the detail again
148-
typed = self.Input.Type(new_text, accept_enter = False, next_line = True, regex = regex)
153+
typed = self.Input.Type(new_text, accept_enter = False, next_line = True, regex = format)
149154

150155
# Add the detail to the "Details" dictionary of the "Survivor" dictionary
151156
survivor["Details"][key] = typed
152157

158+
# ---------- #
159+
153160
# Ask the user to select the city of the survivor
154161
city = self.Select_City()
155162

@@ -159,10 +166,12 @@ def Type_Survivor_Information(self):
159166
# Add the city to the root dictionary
160167
self.dictionary["City"] = city
161168

169+
# ---------- #
170+
162171
# Define the root "Survivor" dictionary as the local dictionary
163172
self.dictionary["Survivor"] = survivor
164173

165-
def Update_Files(self):
174+
def Create_Survivor_Folder(self):
166175
# Define and create the survivor folder
167176
root_folder = self.project_zomboid["Folders"]["Survivors"]["root"]
168177

@@ -173,6 +182,7 @@ def Update_Files(self):
173182
self.dictionary["Survivor"]["Folders"]["Survivor"] = self.dictionary["Survivor"]["Folders"]["root"] + "Survivor.json"
174183
self.File.Create(self.dictionary["Survivor"]["Folders"]["Survivor"])
175184

185+
def Update_Files(self):
176186
# Update the "Survivor.json" file
177187
self.Update_Dictionary(self.dictionary["Survivor"])
178188

Modules/Project_Zomboid/Project_Zomboid/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ def Define_The_Cities(self):
252252

253253
def Select_City(self):
254254
# Define the parameters dictionary for the "Select" method of the "Input" class
255-
dictionary = {
255+
parameters = {
256256
"options": self.project_zomboid["Cities"]["List"],
257257
"show_text": self.Language.language_texts["cities, title()"],
258258
"select_text": self.Language.language_texts["city, title()"]
259259
}
260260

261261
# Ask the user to select a city from the list
262-
city = self.Input.Select(**dictionary)["option"]
262+
city = self.Input.Select(**parameters)["option"]
263263

264264
# Get the city from the "Cities" dictionary
265265
city = self.project_zomboid["Cities"]["Dictionary"][city]

Modules/Social_Networks/Social_Networks/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ def __init__(self):
1717
self.Define_Folders_And_Files()
1818

1919
# Class methods
20+
21+
# Define the "Information items" dictionary
2022
self.Define_Information_Items_Dictionary()
23+
24+
# Define the "Social Networks" dictionary
2125
self.Define_Social_Networks_Dictionary()
26+
27+
# Define the information items
2228
self.Define_Information_Items()
29+
30+
# Update the social networks file
2331
self.Update_Social_Networks_File()
2432

2533
def Define_Basic_Variables(self):
@@ -675,6 +683,7 @@ def Define_Information_Items(self):
675683
"Example": ""
676684
}
677685

686+
# If the key is in the "Formats" dictionary, use the format dictionary inside it
678687
if key in dictionary["Formats"]:
679688
dict_["Format"] = dictionary["Formats"][key]
680689

0 commit comments

Comments
 (0)