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
|
# 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_1", "chapter_2", "chapter_3", "chapter_4", "chapter_5",
|
||||||
"chapter_6", "chapter_7", "chapter_8", "chapter_9", "chapter_10", "chapter_11"
|
"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_list_length = len(chapter_list) - 1
|
||||||
|
default chapter_list_index = 0 # Index number for the current position of the general chapters array
|
||||||
default chapter_index = 0 # Index number for the current position of the general chapters array
|
|
||||||
|
|
||||||
# This stores the name of the label as a string
|
# 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
|
# When starting a new game, it takes the first element of the chapter_list array
|
||||||
default current_general_chapter = general_chapters[chapter_index]
|
default current_chapter = chapter_list[chapter_list_index]
|
||||||
|
|
||||||
default ending_route_number = None
|
default ending_route_number = None
|
||||||
|
|
||||||
default is_end_reached = False
|
default is_end_reached = False
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,38 +39,50 @@ init -1 python:
|
||||||
init python:
|
init python:
|
||||||
|
|
||||||
def next_story_chapter():
|
def next_story_chapter():
|
||||||
global chapter_index
|
global chapter_list_index, current_chapter, ending_route_number
|
||||||
global current_general_chapter
|
|
||||||
global ending_route_number
|
|
||||||
global is_end_reached
|
|
||||||
|
|
||||||
|
# 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():
|
if not is_end_reached and is_end_of_chapters():
|
||||||
ending_route_number = get_ending()
|
process_ending()
|
||||||
add_ending_chapters()
|
|
||||||
is_end_reached = True
|
|
||||||
|
|
||||||
if chapter_index < chapters_array_length:
|
if chapter_list_index < chapter_list_length:
|
||||||
chapter_index += 1
|
chapter_list_index += 1
|
||||||
current_general_chapter = general_chapters[chapter_index]
|
current_chapter = chapter_list[chapter_list_index]
|
||||||
renpy.call(current_general_chapter)
|
renpy.call(current_chapter)
|
||||||
else:
|
else:
|
||||||
ending_image()
|
end_story()
|
||||||
renpy.call("lending")
|
|
||||||
|
|
||||||
|
|
||||||
def is_end_of_chapters():
|
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():
|
def add_ending_chapters():
|
||||||
global general_chapters
|
global chapter_list
|
||||||
global chapters_array_length
|
|
||||||
|
|
||||||
if ending_route_number in ending_routes:
|
if ending_route_number in ending_routes:
|
||||||
general_chapters.extend(ending_routes[ending_route_number])
|
chapter_list.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)
|
|
||||||
|
|
||||||
|
|
||||||
|
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