mirror of
https://git.cavemanon.xyz/Cavemanon/SnootGame.git
synced 2025-02-24 10:38:56 +01:00
storyline refactoring and improve function modularity
This commit is contained in:
parent
8b783f6838
commit
859610e3bd
1 changed files with 37 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
|||
# Store the general chapters inside an array for easy manipulation
|
||||
define general_chapters = [
|
||||
default chapter_list = [
|
||||
"chapter_1", "chapter_2", "chapter_3", "chapter_4", "chapter_5",
|
||||
"chapter_6", "chapter_7", "chapter_8", "chapter_9", "chapter_10", "chapter_11"
|
||||
]
|
||||
|
@ -12,16 +12,14 @@ define ending_routes = {
|
|||
}
|
||||
|
||||
|
||||
default chapters_array_length = len(general_chapters) - 1
|
||||
|
||||
default chapter_index = 0 # Index number for the current position of the general chapters array
|
||||
default chapter_list_length = len(chapter_list) - 1
|
||||
default chapter_list_index = 0 # Index number for the current position of the general chapters array
|
||||
|
||||
# This stores the name of the label as a string
|
||||
# When starting a new game, it takes the first element of the general_chapters array
|
||||
default current_general_chapter = general_chapters[chapter_index]
|
||||
# When starting a new game, it takes the first element of the chapter_list array
|
||||
default current_chapter = chapter_list[chapter_list_index]
|
||||
|
||||
default ending_route_number = None
|
||||
|
||||
default is_end_reached = False
|
||||
|
||||
|
||||
|
@ -41,38 +39,50 @@ init -1 python:
|
|||
init python:
|
||||
|
||||
def next_story_chapter():
|
||||
global chapter_index
|
||||
global current_general_chapter
|
||||
global ending_route_number
|
||||
global is_end_reached
|
||||
global chapter_list_index, current_chapter, ending_route_number
|
||||
|
||||
# Add check "is_end_reached" to have this if statement be executed only once when finishing the general chapters
|
||||
if not is_end_reached and is_end_of_chapters():
|
||||
ending_route_number = get_ending()
|
||||
add_ending_chapters()
|
||||
is_end_reached = True
|
||||
process_ending()
|
||||
|
||||
if chapter_index < chapters_array_length:
|
||||
chapter_index += 1
|
||||
current_general_chapter = general_chapters[chapter_index]
|
||||
renpy.call(current_general_chapter)
|
||||
if chapter_list_index < chapter_list_length:
|
||||
chapter_list_index += 1
|
||||
current_chapter = chapter_list[chapter_list_index]
|
||||
renpy.call(current_chapter)
|
||||
else:
|
||||
ending_image()
|
||||
renpy.call("lending")
|
||||
end_story()
|
||||
|
||||
|
||||
def is_end_of_chapters():
|
||||
return chapter_index >= chapters_array_length
|
||||
return chapter_list_index >= chapter_list_length
|
||||
|
||||
|
||||
def process_ending():
|
||||
global ending_route_number
|
||||
|
||||
ending_route_number = get_ending()
|
||||
add_ending_chapters()
|
||||
update_ending_variables()
|
||||
|
||||
|
||||
def add_ending_chapters():
|
||||
global general_chapters
|
||||
global chapters_array_length
|
||||
global chapter_list
|
||||
|
||||
if ending_route_number in ending_routes:
|
||||
general_chapters.extend(ending_routes[ending_route_number])
|
||||
chapters_array_length = len(general_chapters) - 1
|
||||
# renpy.block_rollback() BLOQUEAR O CAMBIARLO A TUPLE
|
||||
general_chapters = tuple(general_chapters)
|
||||
chapter_list.extend(ending_routes[ending_route_number])
|
||||
|
||||
|
||||
def update_ending_variables():
|
||||
global chapter_list_length
|
||||
global is_end_reached
|
||||
|
||||
# chapter_list_length is updated to reflect the addition to the chapter_list array
|
||||
chapter_list_length = len(chapter_list) - 1
|
||||
is_end_reached = True
|
||||
|
||||
|
||||
def end_story():
|
||||
ending_image()
|
||||
renpy.call("lending")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue