Compare commits

...

10 Commits

Author SHA1 Message Date
95b3db770e Avoid extraneous bool call 2023-11-14 23:35:10 +01:00
0d4a309898 Sort in-place to save time 2023-11-14 23:34:14 +01:00
9d61a4c583 Use python hide instead of a single-use function 2023-11-14 23:24:15 +01:00
5a2434df5e Fix indent 2023-11-14 23:21:10 +01:00
06b4da76f6 Weird variable setting 2023-11-14 23:16:40 +01:00
a2665c15fe Fix misuse of variable
- don't use a reserved name (starting with an underscore)
- use a file-local mangled name (starting with two underscores
- use renpy.dynamx to cleanup the variable automatically
2023-11-14 23:16:26 +01:00
710400f2ce Repr instead of adding simple quotes manually
it's a tad slower but it's a better general practice and we're in an error handling branch anyway
2023-11-14 23:14:33 +01:00
a3ccbf60ce Sirt in-place to save time
not the first time, so that we can still pass it iterators
2023-11-14 22:55:53 +01:00
07d0c7b151 Simplify that call 2023-11-14 22:55:30 +01:00
49fe8f4902 skip unnecessary lambda 2023-11-14 22:54:02 +01:00
17 changed files with 228 additions and 231 deletions

View File

@ -103,25 +103,25 @@ label upgrades_menu(xx=150, yy=90):
with d3
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "category":
$ current_category = __choice[1]
$ category_items = 0
$ menu_items = upgrades_sortfilter([], current_sorting)
$ menu_items_length = len(menu_items)
$ current_item = 0
elif _choice[0] == "subcat":
if _choice[1] != current_subcategory:
$ current_subcategory = _choice[1]
elif _choice[0] == "buy":
if game.gold >= _choice[1] and ton_friendship >= _choice[3]*25:
elif __choice[0] == "subcat":
if __choice[1] != current_subcategory:
$ current_subcategory = __choice[1]
elif __choice[0] == "buy":
if game.gold >= __choice[1] and ton_friendship >= __choice[3]*25:
python:
renpy.play('sounds/money.ogg')
game.gold -= _choice[1]
_list = _choice[2]
_iter = _choice[3]
game.gold -= __choice[1]
_list = __choice[2]
_iter = __choice[3]
item_bought = True
@ -129,7 +129,7 @@ label upgrades_menu(xx=150, yy=90):
if not _list[i].unlocked:
_list[i].unlock()
ton_clothing_upgrades += 1
elif ton_friendship < _choice[4]:
elif ton_friendship < __choice[4]:
$ renpy.play('sounds/fail.ogg')
"> Tonks doesn't like you enough."
else:

View File

@ -201,12 +201,12 @@ label achievement_menu(xx=150, yy=90):
label .after_init:
python:
_choice = ui.interact()
renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
current_item = _choice[1]
elif _choice[0] == "category":
current_category = _choice[1]
if __choice[0] == "select":
current_item = __choice[1]
elif __choice[0] == "category":
current_category = __choice[1]
if current_category == "All":
category_items = list(persistent.achievements.items())
else:
@ -215,11 +215,11 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items)
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
current_page += 1
elif _choice == "dec":
elif __choice == "dec":
current_page += -1
elif _choice == "filter":
elif __choice == "filter":
if current_filter == None:
current_filter = "Locked"
elif current_filter == "Locked":
@ -232,7 +232,7 @@ label achievement_menu(xx=150, yy=90):
menu_items_length = len(menu_items)
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "A-z":
current_sorting = "z-A"
elif current_sorting == "z-A":

View File

@ -79,24 +79,24 @@ label book_handle(book=None):
show screen book_animator("book_page_next", 0.5)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice == "next":
if __choice == "next":
$ book.next()
play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_next", 0.5)
with d1
elif _choice == "prev":
elif __choice == "prev":
$ book.prev()
play sound "sounds/pageflip.ogg"
show screen book_animator("book_page_prev", 0.5)
with d1
elif _choice == "back":
elif __choice == "back":
$ book.open()
play sound "sounds/pageflipback.ogg"
show screen book_animator("book_page_start", 0.5)
with d1
elif _choice == "Close":
elif __choice == "Close":
$ book.close()
play sound "sounds/bookclose.ogg"
return

View File

@ -31,11 +31,11 @@ label brewing_menu(xx=150, yy=90):
show screen brewing(xx, yy)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
elif _choice == "filter":
if __choice[0] == "select":
$ current_item = __choice[1]
elif __choice == "filter":
if current_filter == "Unlocked":
$ current_filter = None
elif current_filter == None:
@ -44,7 +44,7 @@ label brewing_menu(xx=150, yy=90):
$ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
$ current_item = next(iter(menu_items), None)
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "A-z":
$ current_sorting = "z-A"
else:
@ -53,10 +53,10 @@ label brewing_menu(xx=150, yy=90):
$ menu_items = brewing_sortfilter(inventory.get_instances_of_type("potion"), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
#$ current_item = next(iter(menu_items), None)
elif _choice[0] == "make":
if _choice[1].has_ingredients():
elif __choice[0] == "make":
if __choice[1].has_ingredients():
play sound "sounds/bubble.ogg"
$ _choice[1].make()
$ __choice[1].make()
else:
gen "It appears I'm missing some key ingredients..." ("base", xpos="far_left", ypos="head")
else:

View File

@ -34,18 +34,18 @@ label summon_menu(xx=723, yy=90):
show screen summon(xx, yy)
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "summon":
if __choice[0] == "summon":
hide screen summon
if not _choice[2]:
if not __choice[2]:
$ enable_game_menu()
$ renpy.jump_out_of_context("summon_"+_choice[1].lower())
$ renpy.jump_out_of_context("summon_"+__choice[1].lower())
else:
if game.daytime or _choice[1] in ["Tonks", "Snape"]:
nar "[_choice[1]] is currently busy. Try again later."
if game.daytime or __choice[1] in ["Tonks", "Snape"]:
nar "[__choice[1]] is currently busy. Try again later."
else:
nar "[_choice[1]] is currently asleep. Try again tomorrow."
nar "[__choice[1]] is currently asleep. Try again tomorrow."
else:
hide screen summon
return

View File

@ -62,13 +62,13 @@ label inventory_menu(xx=150, yy=90):
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
elif _choice[0] == "category":
if __choice[0] == "select":
$ current_item = __choice[1]
elif __choice[0] == "category":
python:
current_category = _choice[1]
current_category = __choice[1]
category_items = inventory_dict[current_category]
menu_items = inventory_sortfilter(category_items, current_sorting, current_filter)
menu_items_length = len(menu_items)
@ -79,11 +79,11 @@ label inventory_menu(xx=150, yy=90):
current_page = 0
current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "sort":
elif __choice == "sort":
python:
if current_sorting == "A-z":
current_sorting = "z-A"
@ -104,7 +104,7 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None)
elif _choice == "filter":
elif __choice == "filter":
python:
if current_filter == None:
current_filter = "Owned"
@ -121,11 +121,11 @@ label inventory_menu(xx=150, yy=90):
if not current_item or not menu_items_length:
current_item = next(iter(menu_items), None)
elif _choice == "use":
elif __choice == "use":
python:
enable_game_menu()
current_item.use()
elif _choice == "give":
elif __choice == "give":
if current_item.type == "gift":
if get_character_gifted(states.active_girl):

View File

@ -111,18 +111,18 @@ label stats_menu(xx=150, yy=90):
show screen stats(xx, yy)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "category":
$ current_category = __choice[1]
$ category_items = stats_dict[current_category]
$ menu_items = stats_sortfilter(category_items, current_sorting)
$ menu_items_length = len(menu_items)
$ current_item = stats_dict[current_category]
#$ current_subcategory = "overview"
elif _choice[0] == "subcat":
if _choice[1] != current_subcategory:
$ current_subcategory = _choice[1]
elif __choice[0] == "subcat":
if __choice[1] != current_subcategory:
$ current_subcategory = __choice[1]
else:
hide screen stats
return

View File

@ -31,7 +31,7 @@ label tutorial(entry):
label .display(entry):
show screen tutorial(entry)
$ _choice = ui.interact()
$ _choice = ui.interact() # ???
return
screen tutorial(entry):

View File

@ -5,34 +5,34 @@ label deck_builder:
label deck_builder_jump:
show screen deck_builder_screen
$ renpy.block_rollback()
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice in unlocked_cards:
$ selectcard = unlocked_cards.index(_choice)
if __choice in unlocked_cards:
$ selectcard = unlocked_cards.index(__choice)
jump deck_builder_jump
elif _choice == "gallery":
elif __choice == "gallery":
hide screen deck_builder_screen
show screen deck_builder_gallery
elif _choice == "back":
elif __choice == "back":
hide screen deck_builder_gallery
show screen deck_builder_screen
elif _choice == "Close":
elif __choice == "Close":
$ selectcard = -1
hide screen deck_builder_screen
jump main_room_menu
elif _choice == "guide":
elif __choice == "guide":
$ selectcard = -1
hide screen deck_builder_screen
jump deck_builder_guide
elif _choice == "inc":
elif __choice == "inc":
$ currentpage += 1
$ selectcard = -1
jump deck_builder_jump
elif _choice == "dec":
elif __choice == "dec":
$ currentpage -= 1
$ selectcard = -1
jump deck_builder_jump
elif _choice == "unselect":
elif __choice == "unselect":
$ selectcard = -1
jump deck_builder_jump
else:
@ -40,8 +40,8 @@ label deck_builder:
python:
if unlocked_cards[selectcard].copies > -1:
unlocked_cards[selectcard].copies -= 1
add_card_to_deck(playerdeck[int(_choice)].title)
playerdeck[int(_choice)] = unlocked_cards[selectcard]
add_card_to_deck(playerdeck[int(__choice)].title)
playerdeck[int(__choice)] = unlocked_cards[selectcard]
selectcard = -1
pass
jump deck_builder_jump
@ -256,9 +256,9 @@ label deck_builder_guide:
gen "(*Shudders*)" ("base", xpos="far_left", ypos="head")
gen "(Well... might as well...)" ("base", xpos="far_left", ypos="head")
#$ _choice = ui.interact()
#$ renpy.dynamic(__choice = ui.interact())
#if _choice == "back":
#if __choice == "back":
call music_block
hide screen deck_builder_tutorial

View File

@ -85,12 +85,12 @@
# $ test_sign.interactive = True
# $ _choice = ui.interact()
# $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result":
# if __choice[0] == "result":
# $ test_sign.interactive = False
# pause 3.0
# if _choice[1] >= 50.0:
# if __choice[1] >= 50.0:
# "Magician" "Congratulations, you have passed the test with the score of [_sign_max]%%, I am proud of you!"
# menu:
# "Magician" "Would you like to keep playing?"
@ -116,21 +116,21 @@
# show screen draw_magic
# $ _choice = ui.interact()
# $ renpy.dynamic(__choice = ui.interact())
# if _choice[0] == "result":
# if __choice[0] == "result":
# $ test_sign.interactive = False
# pause 3.0
# if _choice[1] == 0.0:
# if __choice[1] == 0.0:
# "Magician" "You suck."
# elif 25.0 > _choice[1] > 0.0:
# elif 25.0 > __choice[1] > 0.0:
# "Magician" "You still suck."
# elif 50.0 > _choice[1] > 25.0:
# elif 50.0 > __choice[1] > 25.0:
# "Magician" "You're average."
# elif 75.0 > _choice[1] > 50.0:
# elif 75.0 > __choice[1] > 50.0:
# "Magician" "You're above average."
# elif 100.0 > _choice[1] > 75.0:
# elif 100.0 > __choice[1] > 75.0:
# "Magician" "You're good."
# else:
# "Magician" "Holy shit! CRITICAL HIT!"

View File

@ -35,23 +35,23 @@ label mirror_menu(xx=150, yy=90):
show screen mirror(xx, yy)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
if __choice[0] == "select":
$ current_item = __choice[1]
$ current_item.seen = True
elif _choice[0] == "category":
$ current_category = _choice[1]
elif __choice[0] == "category":
$ current_category = __choice[1]
$ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter)
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "filter":
elif __choice == "filter":
if current_filter == "Unlocked":
$ current_filter = None
elif current_filter == None:
@ -61,7 +61,7 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "A-z":
$ current_sorting = "z-A"
else:
@ -71,8 +71,8 @@ label mirror_menu(xx=150, yy=90):
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
elif _choice[0] == "play":
$ _choice[1].play()
elif __choice[0] == "play":
$ __choice[1].play()
$ renpy.jump_out_of_context("mirror")
else:
$ enable_game_menu()

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,13 @@ init python:
item = sorted(item, key=lambda x: natsort_key(x.name))
if sortby == "Price (Asc)":
item = sorted(item, key=lambda x: x.price, reverse=False)
item.sort(key=lambda x: x.price, reverse=False)
elif current_sorting == "Price (Desc)":
item = sorted(item, key=lambda x: x.price, reverse=True)
item.sort(key=lambda x: x.price, reverse=True)
if sortby == "Lewdness (Asc)":
item = sorted(item, key=lambda x: get_outfit_score(x), reverse=False)
item.sort(key=get_outfit_score, reverse=False)
elif current_sorting == "Lewdness (Desc)":
item = sorted(item, key=lambda x: get_outfit_score(x), reverse=True)
item.sort(key=get_outfit_score, reverse=True)
return item
label shop_dress:
@ -25,7 +25,7 @@ label shop_dress_menu:
category_items = {"hermione": hermione.outfits, "tonks": tonks.outfits, "cho": cho.outfits, "luna": luna.outfits, "astoria": astoria.outfits, "susan": susan.outfits}
current_category = "hermione"
store_cart = set()
menu_items = shop_dress_sortfilter([x for x in category_items.get(current_category, []) if bool(x.unlocked == False and x.price > 0 and not x in store_cart)], current_sorting)
menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting)
current_item = next(iter(menu_items), None)
parcel_callbacks = []
@ -33,25 +33,25 @@ label shop_dress_menu:
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamic(__choice = ui.interact())
if _choice[0] == "category":
$ current_category = _choice[1]
$ menu_items = shop_dress_sortfilter([x for x in category_items.get(current_category, []) if bool(x.unlocked == False and x.price > 0 and not x in store_cart)], current_sorting)
if __choice[0] == "category":
$ current_category = __choice[1]
$ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting)
$ current_item = next(iter(menu_items), None)
elif _choice[0] == "buy":
elif __choice[0] == "buy":
show screen blktone
with d3
if game.gold < _choice[1].price:
if game.gold < __choice[1].price:
gen "(I don't have enough gold.)" ("base", xpos="far_left", ypos="head")
else:
if len(store_cart) < 5:
$ renpy.call("purchase_outfit", _choice[1])
$ renpy.call("purchase_outfit", __choice[1])
play sound "sounds/money.ogg"
$ game.gold -= _choice[1].price
$ store_cart.add(_choice[1])
$ menu_items = shop_dress_sortfilter([x for x in category_items.get(current_category, []) if bool(x.unlocked == False and x.price > 0 and not x in store_cart)], current_sorting)
$ game.gold -= __choice[1].price
$ store_cart.add(__choice[1])
$ menu_items = shop_dress_sortfilter((x for x in category_items.get(current_category, []) if (x.unlocked == False and x.price > 0 and x not in store_cart)), current_sorting)
$ current_item = next(iter(menu_items), None)
if len(store_cart) < 5:
@ -63,7 +63,7 @@ label shop_dress_menu:
hide screen blktone
with d3
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "Price (Asc)":
$ current_sorting = "Price (Desc)"
elif current_sorting == "Price (Desc)":
@ -112,12 +112,12 @@ label shop_dress_menu:
$ curry = renpy.curry(execute_callbacks)(parcel_callbacks) if parcel_callbacks else None
$ parcel_callbacks = []
$ Parcel(contents=[(k, 1) for k in store_cart], wait=transit_time, func=curry).send()
return
else:
gen "Nothing has caught my eye I'm afraid." ("base", xpos="far_left", ypos="head")
maf "Maybe next time."
return
gen "Nothing has caught my eye I'm afraid." ("base", xpos="far_left", ypos="head")
maf "Maybe next time."
return
jump .after_init

View File

@ -90,13 +90,8 @@ label purchase_item(item):
$ game.gold -= item.price
$ item.owned += 1
$ item_store_achievements()
return
init python:
def item_store_achievements():
# We require a function because lambdas aren't pickleable
python hide:
# We hide the lambdas which aren't pickleable
if isinstance(item, Decoration):
_posters = filter(lambda x: (x.type == "decoration" and x.placement == poster_OBJ), inventory.items)
_hats = filter(lambda x: (x.type == "decoration" and "hat" in x.name.lower()), inventory.items)
@ -105,4 +100,6 @@ init python:
achievements.unlock("postman")
if all(i.owned > 0 for i in _hats):
achievements.unlock("hats")
achievements.unlock("hats")
return

View File

@ -4,9 +4,9 @@ init python:
item = sorted(item, key=lambda x: natsort_key(x.name))
if sortby == "Price (Asc)":
item = sorted(item, key=lambda x: x.price, reverse=False)
item.sort(key=lambda x: x.price, reverse=False)
elif current_sorting == "Price (Desc)":
item = sorted(item, key=lambda x: x.price, reverse=True)
item.sort(key=lambda x: x.price, reverse=True)
return item
label shop_item:
@ -31,9 +31,9 @@ label shop_item_menu(xx=150, yy=90):
current_sorting = "Price (Asc)"
if current_category in {"Gifts", "Ingredients"}:
category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)]
category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.unlocked)]
elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}:
category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.owned < x.limit and x.unlocked)]
category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.owned < x.limit and x.unlocked)]
menu_items = shop_item_sortfilter(category_items, current_sorting)
menu_items_length = len(menu_items)
@ -43,39 +43,39 @@ label shop_item_menu(xx=150, yy=90):
show screen shop_item(xx, yy)
label .after_init:
$ _choice = ui.interact()
$ renpy.dynamix(__choice = ui.interact())
if _choice[0] == "select":
$ current_item = _choice[1]
elif _choice[0] == "category":
$ current_category = _choice[1]
if __choice[0] == "select":
$ current_item = __choice[1]
elif __choice[0] == "category":
$ current_category = __choice[1]
if current_category in {"Gifts", "Ingredients"}:
$ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)]
$ category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.unlocked)]
elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}:
$ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.owned < x.limit and x.unlocked)]
$ category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.owned < x.limit and x.unlocked)]
$ menu_items = shop_item_sortfilter(category_items, current_sorting)
$ menu_items_length = len(menu_items)
$ current_page = 0
$ current_item = next(iter(menu_items), None)
pass
elif _choice == "inc":
elif __choice == "inc":
$ current_page += 1
elif _choice == "dec":
elif __choice == "dec":
$ current_page += -1
elif _choice == "sort":
elif __choice == "sort":
if current_sorting == "Price (Asc)":
$ current_sorting = "Price (Desc)"
elif current_sorting == "Price (Desc)":
$ current_sorting = "Price (Asc)"
$ menu_items = shop_item_sortfilter(category_items, current_sorting)
elif _choice == "buy":
elif __choice == "buy":
$ renpy.call("purchase_item", current_item)
if current_category in {"Gifts", "Ingredients"}:
$ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)]
$ category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.unlocked)]
elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}:
$ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.owned < x.limit and x.unlocked)]
$ category_items = [x for x in inventory_dict[current_category] if (x.price > 0 and x.owned < x.limit and x.unlocked)]
$ menu_items = shop_item_sortfilter(category_items, current_sorting)
$ menu_items_length = len(menu_items)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff