From d6e8efaaa3300c46568e6ace7c6e523b4f99fd48 Mon Sep 17 00:00:00 2001 From: LoafyLemon Date: Thu, 29 Sep 2022 22:19:55 +0100 Subject: [PATCH] Refactoring --- game/scripts/cg/camera.rpy | 2 +- game/scripts/cg/xray.rpy | 6 +- game/scripts/characters/astoria/favors.rpy | 11 +- .../luna/events/spectrespecs/fx.rpy | 2 +- .../tonks/clothing_upgrades_NOT_IN_USE.txt | 6 +- game/scripts/chibis/classes.rpy | 10 +- game/scripts/chibis/transforms.rpy | 2 +- game/scripts/doll/outfits.rpy | 3 + game/scripts/events/DayNight.rpy | 214 +++++++++--------- game/scripts/events/Start.rpy | 24 +- game/scripts/events/event_class.rpy | 24 +- game/scripts/events/labels.rpy | 49 ++-- game/scripts/gui/help.rpy | 2 +- game/scripts/gui/mods.rpy | 4 +- game/scripts/gui/save_files.rpy | 4 +- game/scripts/gui/say.rpy | 2 +- game/scripts/interface/brewing.rpy | 13 +- game/scripts/interface/color_picker.rpy | 8 +- game/scripts/interface/inventory.rpy | 158 +++++++------ game/scripts/inventory/books_waifu.rpy | 25 +- game/scripts/inventory/classes.rpy | 7 +- game/scripts/inventory/potions/_potions_.txt | 2 +- .../minigames/cardgame/__card_game_init__.rpy | 20 +- .../minigames/cardgame/_card_game_.rpy | 24 +- .../minigames/cardgame/_deck_builder_.rpy | 4 +- .../scripts/minigames/cardgame/_loot_box_.rpy | 4 +- .../minigames/cardgame/_snape_card_game_.rpy | 2 +- game/scripts/minigames/mirror/classes.rpy | 2 +- game/scripts/minigames/mirror/menu.rpy | 23 +- game/scripts/minigames/puzzle.rpy | 8 +- game/scripts/mods.rpy | 18 +- game/scripts/options.rpy | 2 +- .../rooms/main_room/objects/cupboard.rpy | 4 +- game/scripts/rooms/quidditch_pitch/init.rpy | 4 +- game/scripts/shops/dress/menu.rpy | 10 +- game/scripts/shops/item/menu.rpy | 52 +++-- game/scripts/utility/devtools.rpy | 6 +- game/scripts/utility/lint.rpy | 4 +- game/scripts/utility/load_fix.rpy | 2 +- game/scripts/utility/punk.rpy | 12 +- game/scripts/wardrobe/functions.rpy | 4 +- game/scripts/wardrobe/studio.rpy | 4 +- game/scripts/wardrobe/wardrobe.rpy | 2 +- 43 files changed, 408 insertions(+), 381 deletions(-) diff --git a/game/scripts/cg/camera.rpy b/game/scripts/cg/camera.rpy index 309014e4..800491db 100644 --- a/game/scripts/cg/camera.rpy +++ b/game/scripts/cg/camera.rpy @@ -115,7 +115,7 @@ init python: if self.image is None: return - if isinstance(self.image, basestring): + if isinstance(self.image, str): d = renpy.get_registered_image(self.image) else: d = self.image diff --git a/game/scripts/cg/xray.rpy b/game/scripts/cg/xray.rpy index 507565db..fd620e74 100644 --- a/game/scripts/cg/xray.rpy +++ b/game/scripts/cg/xray.rpy @@ -43,9 +43,9 @@ init python: self._overlay = overlay self._mask = mask - self.child = ImageReference(child) if isinstance(child, basestring) else child - self.overlay = ImageReference(overlay) if isinstance(overlay, basestring) else overlay - self.mask = ImageReference(mask) if isinstance(mask, basestring) else mask + self.child = ImageReference(child) if isinstance(child, str) else child + self.overlay = ImageReference(overlay) if isinstance(overlay, str) else overlay + self.mask = ImageReference(mask) if isinstance(mask, str) else mask self.radius = radius self.tag_prefix = tag_prefix self.target = (0, 0) diff --git a/game/scripts/characters/astoria/favors.rpy b/game/scripts/characters/astoria/favors.rpy index c37bcf92..50411014 100644 --- a/game/scripts/characters/astoria/favors.rpy +++ b/game/scripts/characters/astoria/favors.rpy @@ -32,9 +32,10 @@ default ag_se_imperio_sb = event_class( default ag_spell_list = [] label update_astoria_spells: - $ del ag_spell_list[:] # Clear list - if not ag_st_imperio.is_complete(): - $ ag_spell_list.append(ag_st_imperio) - else: - $ ag_spell_list.append(ag_se_imperio_sb) # Susan + python: + del ag_spell_list[:] # Clear list + if not ag_st_imperio.is_complete(): + ag_spell_list.append(ag_st_imperio) + else: + ag_spell_list.append(ag_se_imperio_sb) # Susan return diff --git a/game/scripts/characters/luna/events/spectrespecs/fx.rpy b/game/scripts/characters/luna/events/spectrespecs/fx.rpy index 580bd055..dad51c8f 100644 --- a/game/scripts/characters/luna/events/spectrespecs/fx.rpy +++ b/game/scripts/characters/luna/events/spectrespecs/fx.rpy @@ -59,7 +59,7 @@ screen spectrevision(): zorder 16 tag spectrevision - for i in xrange(wrackspurts_count): + for i in range(wrackspurts_count): add "object" at OBJwrackspurt add "spectrevision" diff --git a/game/scripts/characters/tonks/clothing_upgrades_NOT_IN_USE.txt b/game/scripts/characters/tonks/clothing_upgrades_NOT_IN_USE.txt index 07f3e80e..1416c505 100644 --- a/game/scripts/characters/tonks/clothing_upgrades_NOT_IN_USE.txt +++ b/game/scripts/characters/tonks/clothing_upgrades_NOT_IN_USE.txt @@ -125,7 +125,7 @@ label upgrades_menu(xx=150, yy=90): item_bought = True - for i in xrange(1, min(_iter+1, len(_list))): + for i in range(1, min(_iter+1, len(_list))): if not _list[i].unlocked: _list[i].unlock() ton_clothing_upgrades += 1 @@ -233,14 +233,14 @@ screen upgrades_menuitem(xx, yy): yfill True # TODO: Reduce the clutter and optimize the code. - for i in upgrades_dict[current_category]["outfits"].itervalues(): + for i in upgrades_dict[current_category]["outfits"].values(): $ linear_price = 0 if len(i) > 0 and (i[0].unlocked or upgrades_show_locked): vbox: hbox: spacing 0 - for x in xrange(len(i)): + for x in range(len(i)): if x < len(i)-1: if not i[x+1].unlocked: $ linear_price += i[x+1].price diff --git a/game/scripts/chibis/classes.rpy b/game/scripts/chibis/classes.rpy index 2980aed2..908d5e7d 100644 --- a/game/scripts/chibis/classes.rpy +++ b/game/scripts/chibis/classes.rpy @@ -55,7 +55,7 @@ init -1 python: def complete_chibi_moves(**elapsed): """Resume old chibi action after (multiple) reduced move calls.""" q = [] - for chibi, (t, a) in chibi_moves.iteritems(): + for chibi, (t, a) in chibi_moves.items(): et = elapsed.get(chibi, 0) t -= et q.append((chibi, t, a)) @@ -198,7 +198,7 @@ init -1 python: old_action = self.action if action: move_action = action - elif isinstance(self.action_info[2], basestring): + elif isinstance(self.action_info[2], str): # Action info provides a move action move_action = self.action_info[2] else: @@ -209,7 +209,7 @@ init -1 python: # Calculate movement time times = [] - for i in xrange(len(path) - 1): + for i in range(len(path) - 1): dist = math.sqrt((path[i][0] - path[i+1][0])**2 + (path[i][1] - path[i+1][1])**2) time = dist / (float(self.speed) * speed) if loop_time > 0: @@ -308,7 +308,7 @@ init -1 python: yield d def clear(self): - for k in self.layers.iterkeys(): + for k in self.layers.keys(): self.layers[k] = None def __getitem__(self, key): @@ -319,7 +319,7 @@ init -1 python: # Layer must be defined at init raise KeyError(key) - if isinstance(value, basestring) and '.' in value: + if isinstance(value, str) and '.' in value: # Assume value is a filename and resolve it if value.startswith('~') or not self.special: # Avoid special directory diff --git a/game/scripts/chibis/transforms.rpy b/game/scripts/chibis/transforms.rpy index a6606f75..3254e62c 100644 --- a/game/scripts/chibis/transforms.rpy +++ b/game/scripts/chibis/transforms.rpy @@ -77,7 +77,7 @@ init python: it = 0 seg = 0 - for i in xrange(len(times)): + for i in range(len(times)): if it + times[i] > st: seg = i break diff --git a/game/scripts/doll/outfits.rpy b/game/scripts/doll/outfits.rpy index 27196448..dd57f75f 100644 --- a/game/scripts/doll/outfits.rpy +++ b/game/scripts/doll/outfits.rpy @@ -27,6 +27,9 @@ init python: # def __del__(self): # print("Outfit with hash: {} has been garbage collected.".format(self.hash)) + def __hash__(self): + return self.hash + def __eq__(self, obj): if not isinstance(obj, DollOutfit): return NotImplemented diff --git a/game/scripts/events/DayNight.rpy b/game/scripts/events/DayNight.rpy index e41a7906..64a05162 100644 --- a/game/scripts/events/DayNight.rpy +++ b/game/scripts/events/DayNight.rpy @@ -11,93 +11,95 @@ label day_start: hide luna_main with dissolve - # Reset room objects - $ candleL_OBJ.foreground = None - $ candleR_OBJ.foreground = None - $ fire_in_fireplace = False - $ fireplace_OBJ.foreground = None - $ phoenix_is_fed = False - $ phoenix_is_petted = False - $ phoenix_OBJ.foreground = None # Removes seeds image - $ owl_away = False - $ cupboard_searched = False + python: - # Reset gift flags - $ gave_tonks_gift = False - $ gave_hermione_gift = False - $ gave_luna_gift = False - $ gave_cho_gift = False - $ gave_astoria_gift = False - $ gave_susan_gift = False + # Reset room objects + candleL_OBJ.foreground = None + candleR_OBJ.foreground = None + fire_in_fireplace = False + fireplace_OBJ.foreground = None + phoenix_is_fed = False + phoenix_is_petted = False + phoenix_OBJ.foreground = None # Removes seeds image + owl_away = False + cupboard_searched = False - # Reset chit-chat flags - $ snape_chatted = False - $ tonks_chatted = False - $ hermione_chatted = False - $ luna_chatted = False - $ cho_chatted = False - $ astoria_chatted = False - $ susan_chatted = False + # Reset gift flags + gave_tonks_gift = False + gave_hermione_gift = False + gave_luna_gift = False + gave_cho_gift = False + gave_astoria_gift = False + gave_susan_gift = False - # Tick Event timers - $ ss_event_pause = max(ss_event_pause-1, 0) - $ ss_summon_pause = max(ss_summon_pause-1, 0) - $ nt_event_pause = max(nt_event_pause-1, 0) - $ nt_summon_pause = max(nt_summon_pause-1, 0) - $ hg_event_pause = max(hg_event_pause-1, 0) - $ hg_summon_pause = max(hg_summon_pause-1, 0) - $ ll_event_pause = max(ll_event_pause-1, 0) - $ ll_summon_pause = max(ll_summon_pause-1, 0) - $ cc_event_pause = max(cc_event_pause-1, 0) - $ cc_summon_pause = max(cc_summon_pause-1, 0) - $ ag_event_pause = max(ag_event_pause-1, 0) - $ ag_summon_pause = max(ag_summon_pause-1, 0) - $ sb_event_pause = max(sb_event_pause-1, 0) - $ sb_summon_pause = max(sb_summon_pause-1, 0) + # Reset chit-chat flags + snape_chatted = False + tonks_chatted = False + hermione_chatted = False + luna_chatted = False + cho_chatted = False + astoria_chatted = False + susan_chatted = False - # Reset busy flags (Based on current tick) - $ snape_busy = bool(ss_summon_pause) - $ tonks_busy = bool(nt_summon_pause) - $ hermione_busy = bool(hg_summon_pause) - $ luna_busy = bool(ll_summon_pause) - $ cho_busy = bool(cc_summon_pause) - $ astoria_busy = bool(ag_summon_pause) - $ susan_busy = bool(sb_summon_pause) + # Tick Event timers + ss_event_pause = max(ss_event_pause-1, 0) + ss_summon_pause = max(ss_summon_pause-1, 0) + nt_event_pause = max(nt_event_pause-1, 0) + nt_summon_pause = max(nt_summon_pause-1, 0) + hg_event_pause = max(hg_event_pause-1, 0) + hg_summon_pause = max(hg_summon_pause-1, 0) + ll_event_pause = max(ll_event_pause-1, 0) + ll_summon_pause = max(ll_summon_pause-1, 0) + cc_event_pause = max(cc_event_pause-1, 0) + cc_summon_pause = max(cc_summon_pause-1, 0) + ag_event_pause = max(ag_event_pause-1, 0) + ag_summon_pause = max(ag_summon_pause-1, 0) + sb_event_pause = max(sb_event_pause-1, 0) + sb_summon_pause = max(sb_summon_pause-1, 0) - # Improve Mood - if game.difficulty == 1: # Easy difficulty - $ val = 3 - elif game.difficulty == 2: # Normal difficulty - $ val = 2 - elif game.difficulty == 3: # Hardcore difficulty - $ val = 1 + # Reset busy flags (Based on current tick) + snape_busy = bool(ss_summon_pause) + tonks_busy = bool(nt_summon_pause) + hermione_busy = bool(hg_summon_pause) + luna_busy = bool(ll_summon_pause) + cho_busy = bool(cc_summon_pause) + astoria_busy = bool(ag_summon_pause) + susan_busy = bool(sb_summon_pause) - $ ton_mood = max(ton_mood-val, 0) - $ her_mood = max(her_mood-val, 0) - $ lun_mood = max(lun_mood-val, 0) - $ cho_mood = max(cho_mood-val, 0) - $ ast_mood = max(ast_mood-val, 0) - $ sus_mood = max(sus_mood-val, 0) + # Improve Mood + if game.difficulty == 1: # Easy difficulty + val = 3 + elif game.difficulty == 2: # Normal difficulty + val = 2 + elif game.difficulty == 3: # Hardcore difficulty + val = 1 - # Game flags - $ game.day += 1 - $ game.weather = "random" - $ game.daytime = True + ton_mood = max(ton_mood-val, 0) + her_mood = max(her_mood-val, 0) + lun_mood = max(lun_mood-val, 0) + cho_mood = max(cho_mood-val, 0) + ast_mood = max(ast_mood-val, 0) + sus_mood = max(sus_mood-val, 0) - # Randomisers - $ random_gold = renpy.random.randint(8, 40) - $ random_map_loc = renpy.random.randint(1, 5) + # Game flags + game.day += 1 + game.weather = "random" + game.daytime = True - # Send salary every 7th day - if game.day % 7 == 0: - if reports_finished >= 1: - $ letter_work_report.send() - if not first_random_twins: - $ twins_interest = True + # Randomisers + random_gold = renpy.random.randint(8, 40) + random_map_loc = renpy.random.randint(1, 5) - # Pass time - $ mailbox.tick() - $ eventqueue.tick() + # Send salary every 7th day + if game.day % 7 == 0: + if reports_finished >= 1: + letter_work_report.send() + if not first_random_twins: + twins_interest = True + + # Pass time + mailbox.tick() + eventqueue.tick() # Update map locations call set_her_map_location() @@ -170,38 +172,40 @@ label night_start: hide luna_main with dissolve - # Reset room objects - if not candleL_OBJ.foreground: - $ candleL_OBJ.get_action()() - if not candleR_OBJ.foreground: - $ candleR_OBJ.get_action()() - $ cupboard_searched = False + python: - # Reset chit-chat flags - $ snape_chatted = False - $ tonks_chatted = False - $ hermione_chatted = False - $ luna_chatted = False - $ cho_chatted = False - $ astoria_chatted = False - $ susan_chatted = False + # Reset room objects + if not candleL_OBJ.foreground: + candleL_OBJ.get_action()() + if not candleR_OBJ.foreground: + candleR_OBJ.get_action()() + cupboard_searched = False - # Reset busy flags (Based on current tick) - $ snape_busy = bool(ss_summon_pause) - $ tonks_busy = bool(nt_summon_pause) - $ hermione_busy = bool(hg_summon_pause) - $ luna_busy = bool(ll_summon_pause) - $ cho_busy = bool(cc_summon_pause) - $ astoria_busy = bool(ag_summon_pause) - $ susan_busy = bool(sb_summon_pause) + # Reset chit-chat flags + snape_chatted = False + tonks_chatted = False + hermione_chatted = False + luna_chatted = False + cho_chatted = False + astoria_chatted = False + susan_chatted = False - # Game flags - $ game.weather = "random" - $ game.daytime = False + # Reset busy flags (Based on current tick) + snape_busy = bool(ss_summon_pause) + tonks_busy = bool(nt_summon_pause) + hermione_busy = bool(hg_summon_pause) + luna_busy = bool(ll_summon_pause) + cho_busy = bool(cc_summon_pause) + astoria_busy = bool(ag_summon_pause) + susan_busy = bool(sb_summon_pause) - # Randomisers - $ random_gold = renpy.random.randint(8, 40) - $ random_map_loc = renpy.random.randint(1, 5) + # Game flags + game.weather = "random" + game.daytime = False + + # Randomisers + random_gold = renpy.random.randint(8, 40) + random_map_loc = renpy.random.randint(1, 5) # Update map locations call set_her_map_location() diff --git a/game/scripts/events/Start.rpy b/game/scripts/events/Start.rpy index 3a15f9cd..773d4221 100644 --- a/game/scripts/events/Start.rpy +++ b/game/scripts/events/Start.rpy @@ -126,14 +126,15 @@ label genie_intro_E1: gen "I think I will stick around for a little bit..." ("base", xpos="far_left", ypos="head") # Highlight important objects - $ fireplace_OBJ.idle = At("fireplace_idle_shadow", pulse_hover) - $ cupboard_OBJ.idle = At("cupboard_idle", pulse_hover) - $ phoenix_OBJ.idle = At("phoenix_idle", pulse_hover) - $ door_OBJ.idle = At("door_idle", pulse_hover) - $ desk_OBJ.idle = At("ch_gen sit_behind_desk", pulse_hover) + python: + fireplace_OBJ.idle = At("fireplace_idle_shadow", pulse_hover) + cupboard_OBJ.idle = At("cupboard_idle", pulse_hover) + phoenix_OBJ.idle = At("phoenix_idle", pulse_hover) + door_OBJ.idle = At("door_idle", pulse_hover) + desk_OBJ.idle = At("ch_gen sit_behind_desk", pulse_hover) - $ achievements.unlock("start") - $ genie_intro.E1_complete = True + achievements.unlock("start") + genie_intro.E1_complete = True jump main_room_menu @@ -198,8 +199,9 @@ label skip_to_hermione: jump day_start label send_letters: - $ letter_hg_2.send() # Arrives on day 2 - $ letter_work_unlock.send() # Arrives on day 4 - $ letter_favors.send() # Arrives on day 8 - $ letter_cards_unlock.send() # Arrives on day 24 + python: + letter_hg_2.send() # Arrives on day 2 + letter_work_unlock.send() # Arrives on day 4 + letter_favors.send() # Arrives on day 8 + letter_cards_unlock.send() # Arrives on day 24 return diff --git a/game/scripts/events/event_class.rpy b/game/scripts/events/event_class.rpy index 0d6247ec..ce689f45 100644 --- a/game/scripts/events/event_class.rpy +++ b/game/scripts/events/event_class.rpy @@ -76,20 +76,20 @@ init python: if not self.iconset: raise Exception('Events: "iconset" list was not defined for "{}". You need to add at least one set of icons.'.format(self.title)) elif len(self.iconset) < self._max_tiers: - for i in xrange(self._max_tiers-len(self.iconset)): + for i in range(self._max_tiers-len(self.iconset)): self.iconset.append([self.iconset[0][0], self.iconset[0][1]]) if self.icons and len(self.icons) < self._max_tiers: raise Exception('Events: "icons" list does not match the number of events for "{}".'.format(self.title)) - for i in xrange(self._max_tiers): - for j in xrange(len(self.events[i])): + for i in range(self._max_tiers): + for j in range(len(self.events[i])): self.events[i][j] += [False] def start(self): self.counter += 1 - for i in xrange(len(self.events[self._tier])): + for i in range(len(self.events[self._tier])): if self.events[self._tier][i][1] == False: self.events[self._tier][i][1] = True self.points += 1 @@ -100,8 +100,8 @@ init python: def start_advance(self): self.counter += 1 - for i in xrange(self._max_tiers): - for j in xrange(len(self.events[i])): + for i in range(self._max_tiers): + for j in range(len(self.events[i])): if self.events[i][j][1] == False: self.events[i][j][1] = True self._tier = i @@ -111,7 +111,7 @@ init python: self.start_random() def start_random(self): - events_filtered = filter(lambda x: '_intro' not in x[0], self.events[self._tier]) + events_filtered = [x for x in self.events[self._tier] if '_intro' not in x[0]] random_event = events_filtered[random.randint(0, len(events_filtered)-1)][0] return renpy.jump(random_event) @@ -168,8 +168,8 @@ init python: # Reset the event completely def reset(self): - for i in xrange(self._max_tiers): - for j in xrange(len(self.events[i])): + for i in range(self._max_tiers): + for j in range(len(self.events[i])): self.events[i][j][1] = False self._tier = 0 self._points = 0 @@ -240,13 +240,13 @@ init python: def status(self): """Print currently defined keys and values in the console.""" - for key, value in self.iteritems(): - print key + " == " + str(value) + for key, value in self.items(): + print(key + " == " + str(value)) return def reset(self): """Reset all key values back to default values depending on the value type.""" - for key in self.iterkeys(): + for key in self.keys(): if isinstance(self[key], (float, int)): self[key] = 0 elif isinstance(self[key], bool): diff --git a/game/scripts/events/labels.rpy b/game/scripts/events/labels.rpy index 2130ac59..633154be 100644 --- a/game/scripts/events/labels.rpy +++ b/game/scripts/events/labels.rpy @@ -104,30 +104,31 @@ label increase_house_points(house, points): #TODO Check and fix teleport/heal effect position (chibis are now anchored bottom-left) label teleport(position=None,effect=True,poof_label=None): - if position == "genie": - $ teleport_xpos = genie_chibi.pos[0]+75 - $ teleport_ypos = genie_chibi.pos[1] - $ teleport_zorder = 3 - elif position == "hermione": - $ teleport_xpos = hermione_chibi.pos[0]+45 - $ teleport_ypos = hermione_chibi.pos[1] - $ teleport_zorder = 3 - elif position == "cho": - $ teleport_xpos = cho_chibi.pos[0]+45 - $ teleport_ypos = cho_chibi.pos[1] - $ teleport_zorder = 3 - elif position == "astoria": - $ teleport_xpos = astoria_chibi.pos[0]+45 - $ teleport_ypos = astoria_chibi.pos[1] - $ teleport_zorder = 3 - elif position == "desk": - $ teleport_xpos = 320 - $ teleport_ypos = 450 - $ teleport_zorder = 5 - else: - $ teleport_xpos = position[0] - $ teleport_ypos = position[1] - $ teleport_zorder = 2 + python: + if position == "genie": + teleport_xpos = genie_chibi.pos[0]+75 + teleport_ypos = genie_chibi.pos[1] + teleport_zorder = 3 + elif position == "hermione": + teleport_xpos = hermione_chibi.pos[0]+45 + teleport_ypos = hermione_chibi.pos[1] + teleport_zorder = 3 + elif position == "cho": + teleport_xpos = cho_chibi.pos[0]+45 + teleport_ypos = cho_chibi.pos[1] + teleport_zorder = 3 + elif position == "astoria": + teleport_xpos = astoria_chibi.pos[0]+45 + teleport_ypos = astoria_chibi.pos[1] + teleport_zorder = 3 + elif position == "desk": + teleport_xpos = 320 + teleport_ypos = 450 + teleport_zorder = 5 + else: + teleport_xpos = position[0] + teleport_ypos = position[1] + teleport_zorder = 2 if effect == True: $ renpy.play('sounds/magic4.ogg') diff --git a/game/scripts/gui/help.rpy b/game/scripts/gui/help.rpy index 916eb0bd..d7c4738a 100644 --- a/game/scripts/gui/help.rpy +++ b/game/scripts/gui/help.rpy @@ -34,7 +34,7 @@ screen help(page='tutorials'): textbutton _("About") action [SelectedIf(page == 'about'), Show("help", config.intra_transition, "about")] screen tutorials_help(): - for entry, tutorial in tutorial_dict.iteritems(): + for entry, tutorial in tutorial_dict.items(): $ title = tutorial[0] textbutton "[title]": diff --git a/game/scripts/gui/mods.rpy b/game/scripts/gui/mods.rpy index f0379a10..daf0040e 100644 --- a/game/scripts/gui/mods.rpy +++ b/game/scripts/gui/mods.rpy @@ -6,7 +6,7 @@ screen mods(): use game_menu("Mods"): - default selection = next(iter(mods_list.iterkeys())) + default selection = next(iter(mods_list.keys())) default checkbox_enabled = gui.theme("check_true") default checkbox_disabled = gui.theme("check_false") @@ -26,7 +26,7 @@ screen mods(): style_prefix gui.theme("slot") - for mod in mods_list.itervalues(): + for mod in mods_list.values(): $ name = mod["Name"] $ desc = mod["Description"] $ author = mod["Author"] diff --git a/game/scripts/gui/save_files.rpy b/game/scripts/gui/save_files.rpy index c22b06ca..c37965e4 100644 --- a/game/scripts/gui/save_files.rpy +++ b/game/scripts/gui/save_files.rpy @@ -64,7 +64,7 @@ screen file_slots(title): transpose True - for i in xrange(gui.file_slot_cols * gui.file_slot_rows): + for i in range(gui.file_slot_cols * gui.file_slot_rows): $ slot = i + 1 @@ -123,7 +123,7 @@ screen file_slots(title): $ page_modifier = max(0, int(FilePageName(str(page_modifier+9), str(page_modifier+9)))-9) - for page in xrange(1+page_modifier, 10+page_modifier): + for page in range(1+page_modifier, 10+page_modifier): textbutton "[page]": xminimum 40 action FilePage(page) diff --git a/game/scripts/gui/say.rpy b/game/scripts/gui/say.rpy index 8799a39e..f651b61d 100644 --- a/game/scripts/gui/say.rpy +++ b/game/scripts/gui/say.rpy @@ -171,7 +171,7 @@ screen choice(items): spacing 2 xpos choice_width - 5 align (1.0, 0.5) - for i in xrange(0, max_progress): + for i in range(0, max_progress): if i < len(progress): add progress[i] else: diff --git a/game/scripts/interface/brewing.rpy b/game/scripts/interface/brewing.rpy index bb519922..071affde 100644 --- a/game/scripts/interface/brewing.rpy +++ b/game/scripts/interface/brewing.rpy @@ -19,13 +19,14 @@ label brewing: label brewing_menu(xx=150, yy=90): - $ items_shown = 36 - $ current_filter = "Unlocked" - $ current_sorting = "A-z" + python: + items_shown = 36 + current_filter = "Unlocked" + current_sorting = "A-z" - $ 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) + 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) show screen brewing(xx, yy) diff --git a/game/scripts/interface/color_picker.rpy b/game/scripts/interface/color_picker.rpy index 9d707d9b..4aa3a681 100644 --- a/game/scripts/interface/color_picker.rpy +++ b/game/scripts/interface/color_picker.rpy @@ -380,8 +380,8 @@ init -1 python: canvas = rv.canvas() surf = canvas.get_surface() - for x in xrange(w): - for y in xrange(h): + for x in range(w): + for y in range(h): hue = float(y) / h r, g, b = Color(hsv=(hue, 1.0, 1.0)).rgb color = (r * 255, g * 255, b * 255) @@ -407,8 +407,8 @@ init -1 python: canvas = rv.canvas() surf = canvas.get_surface() - for x in xrange(w): - for y in xrange(h): + for x in range(w): + for y in range(h): hue = float(y) / h color = (255.0, 255.0, 255.0, x) surf.set_at((x, y), color) diff --git a/game/scripts/interface/inventory.rpy b/game/scripts/interface/inventory.rpy index 916f294b..753c34df 100644 --- a/game/scripts/interface/inventory.rpy +++ b/game/scripts/interface/inventory.rpy @@ -1,7 +1,7 @@ init python: def inventory_sortfilter(item, sortby="A-z", filtering=None): if filtering == "Owned": - item = filter(lambda x: x.owned > 0, item) + item = [x for x in item if x.owned > 0] # Always sort alphabetically first. item = sorted(item, key=lambda x: natsort_key(x.name)) @@ -9,9 +9,9 @@ init python: if sortby == "z-A": item = sorted(item, key=lambda x: natsort_key(x.name), reverse=True) elif current_sorting == "Available": - item = sorted(item, key=lambda x: x.owned, reverse=True) + item = sorted(item, key=lambda x: x.owned is True, reverse=True) elif current_sorting == "Unavailable": - item = sorted(item, key=lambda x: x.owned) + item = sorted(item, key=lambda x: x.owned is False) return item @@ -28,93 +28,103 @@ label inventory: label inventory_menu(xx=150, yy=90): # Inventory dictionary - if inventory_mode == 0: - $ inventory_dict = { - "Gifts": inventory.get_instances_of_type("gift"), - "Books": inventory.get_instances_of_type("book"), - "Scrolls": inventory.get_instances_of_type("scroll"), - "Ingredients": inventory.get_instances_of_type("ingredient"), - "Potions": inventory.get_instances_of_type("potion"), - "Decorations": inventory.get_instances_of_type("decoration"), - "Quest Items": inventory.get_instances_of_type("quest"), - } - elif inventory_mode == 1: - $ inventory_dict = { - "Gifts": inventory.get_instances_of_type("gift"), - "Potions": inventory.get_instances_of_type("potion"), - "Quest Items": inventory.get_instances_of_type("quest"), - } + python: - $ items_shown = 36 - $ current_page = 0 - $ current_category = next(iter(inventory_dict.iterkeys())) - $ current_filter = "Owned" - $ current_sorting = "Available" + if inventory_mode == 0: + inventory_dict = { + "Gifts": inventory.get_instances_of_type("gift"), + "Books": inventory.get_instances_of_type("book"), + "Scrolls": inventory.get_instances_of_type("scroll"), + "Ingredients": inventory.get_instances_of_type("ingredient"), + "Potions": inventory.get_instances_of_type("potion"), + "Decorations": inventory.get_instances_of_type("decoration"), + "Quest Items": inventory.get_instances_of_type("quest"), + } + elif inventory_mode == 1: + inventory_dict = { + "Gifts": inventory.get_instances_of_type("gift"), + "Potions": inventory.get_instances_of_type("potion"), + "Quest Items": inventory.get_instances_of_type("quest"), + } - $ category_items = inventory_dict[current_category] - $ menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_item = next(iter(menu_items), None) + items_shown = 36 + current_page = 0 + current_category = next(iter(inventory_dict.keys())) + current_filter = "Owned" + current_sorting = "Available" + + category_items = inventory_dict[current_category] + menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) + current_item = next(iter(menu_items), None) show screen inventory(xx, yy) label .after_init: + $ _choice = ui.interact() if _choice[0] == "select": $ current_item = _choice[1] elif _choice[0] == "category": - $ 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) + python: + 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) - if current_category == "Decorations": - $ menu_items = sorted(menu_items, key=lambda x: x.placement.id) + if current_category == "Decorations": + menu_items = sorted(menu_items, key=lambda x: x.placement.id) + + current_page = 0 + current_item = next(iter(menu_items), None) - $ current_page = 0 - $ current_item = next(iter(menu_items), None) elif _choice == "inc": $ current_page += 1 elif _choice == "dec": $ current_page += -1 elif _choice == "sort": - if current_sorting == "A-z": - $ current_sorting = "z-A" - elif current_sorting == "z-A": - $ current_sorting = "Available" - elif current_sorting == "Available": - $ current_sorting = "Unavailable" - else: - $ current_sorting = "A-z" - $ menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) + python: + if current_sorting == "A-z": + current_sorting = "z-A" + elif current_sorting == "z-A": + current_sorting = "Available" + elif current_sorting == "Available": + current_sorting = "Unavailable" + else: + current_sorting = "A-z" + menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) - if current_category == "Decorations": - $ menu_items = sorted(menu_items, key=lambda x: x.placement.id) + if current_category == "Decorations": + menu_items = sorted(menu_items, key=lambda x: x.placement.id) - $ current_page = 0 + current_page = 0 + + if not current_item or not menu_items_length: + current_item = next(iter(menu_items), None) - if not current_item or not menu_items_length: - $ current_item = next(iter(menu_items), None) elif _choice == "filter": - if current_filter == None: - $ current_filter = "Owned" - else: - $ current_filter = None - $ menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) - $ menu_items_length = len(menu_items) + python: + if current_filter == None: + current_filter = "Owned" + else: + current_filter = None + menu_items = inventory_sortfilter(category_items, current_sorting, current_filter) + menu_items_length = len(menu_items) - if current_category == "Decorations": - $ menu_items = sorted(menu_items, key=lambda x: x.placement.id) + if current_category == "Decorations": + menu_items = sorted(menu_items, key=lambda x: x.placement.id) - $ current_page = 0 + current_page = 0 + + if not current_item or not menu_items_length: + current_item = next(iter(menu_items), None) - if not current_item or not menu_items_length: - $ current_item = next(iter(menu_items), None) elif _choice == "use": - $ enable_game_menu() - $ current_item.use() + python: + enable_game_menu() + current_item.use() elif _choice == "give": if current_item.type == "gift": @@ -163,9 +173,10 @@ label inventory_menu(xx=150, yy=90): hide screen blktone with d3 else: - $ enable_game_menu() - $ inventory_mode = 0 - $ current_item.give(active_girl) + python: + enable_game_menu() + inventory_mode = 0 + current_item.give(active_girl) elif current_item.type == "quest": if not active_girl in current_item.usable_on: show screen blktone @@ -201,9 +212,10 @@ label inventory_menu(xx=150, yy=90): hide screen blktone with d3 else: - $ enable_game_menu() - $ inventory_mode = 0 - $ current_item.give(active_girl) + python: + enable_game_menu() + inventory_mode = 0 + current_item.give(active_girl) else: hide screen inventory @@ -241,7 +253,7 @@ screen inventory_menu(xx, yy): vbox: pos (6, 41) - for category in inventory_dict.iterkeys(): + for category in iter(inventory_dict.keys()): vbox: textbutton category: style "empty" @@ -287,7 +299,7 @@ screen inventory_menuitem(xx, yy): text "Inventory" size 22 xalign 0.5 ypos 65 - #text "Unlocked: "+str(len(filter(lambda x: x[1][3] is True, menu_items)))+"/[menu_items_length]" size 12 pos (24, 70) + #text "Unlocked: "+str(len([x for x in menu_items if x[1][3] is True]))+"/[menu_items_length]" size 12 pos (24, 70) # Page counter if menu_items_length > items_shown: @@ -314,7 +326,7 @@ screen inventory_menuitem(xx, yy): action Return("inc") # Add items - for i in xrange(current_page*items_shown, (current_page*items_shown)+items_shown): + for i in range(current_page*items_shown, (current_page*items_shown)+items_shown): if i < menu_items_length: $ row = (i // 9) % 4 $ col = i % 9 diff --git a/game/scripts/inventory/books_waifu.rpy b/game/scripts/inventory/books_waifu.rpy index c51c949a..b3f54814 100644 --- a/game/scripts/inventory/books_waifu.rpy +++ b/game/scripts/inventory/books_waifu.rpy @@ -185,21 +185,22 @@ define waifu_chapters = { label waifu_book: # Setup - $ day = 1 + python: + day = 1 - $ shea_points = 0 - $ stevens_points = 0 - $ leena_points = 0 + shea_points = 0 + stevens_points = 0 + leena_points = 0 - $ generic_ending = waifu_progression["generic_ending"] - $ shea_ending = waifu_progression["shea_ending"] - $ stevens_ending = waifu_progression["stevens_ending"] - $ leena_ending = waifu_progression["leena_ending"] - $ harem_ending = waifu_progression["harem_ending"] + generic_ending = waifu_progression["generic_ending"] + shea_ending = waifu_progression["shea_ending"] + stevens_ending = waifu_progression["stevens_ending"] + leena_ending = waifu_progression["leena_ending"] + harem_ending = waifu_progression["harem_ending"] - $ shea_dates = waifu_chapters["shea_dates"] - $ stevens_dates = waifu_chapters["stevens_dates"] - $ leena_dates = waifu_chapters["leena_dates"] + shea_dates = waifu_chapters["shea_dates"] + stevens_dates = waifu_chapters["stevens_dates"] + leena_dates = waifu_chapters["leena_dates"] call book_start diff --git a/game/scripts/inventory/classes.rpy b/game/scripts/inventory/classes.rpy index 6369f030..c65a8ef6 100644 --- a/game/scripts/inventory/classes.rpy +++ b/game/scripts/inventory/classes.rpy @@ -1,5 +1,4 @@ init python: - class Inventory(object): def __init__(self): self.items = set() @@ -14,7 +13,7 @@ init python: return self.items def get_instances_of_type(self, type): - return filter(lambda x: x.type == type, self.get_instances()) + return [x for x in self.get_instances() if x.type == type] class Item(object): def __init__(self, id, type, name, price=0, desc="", unlocked=True, func=None, label=None, limit=100, image="default", givable=False, currency="gold", caption="use", owned=0, infinite=False, give_label=None, usable_on=[]): @@ -82,7 +81,7 @@ init python: renpy.jump(self.give_label) def get_image(self): - if isinstance(self.image, basestring): + if isinstance(self.image, str): return self.image else: return self.image() @@ -161,7 +160,7 @@ init python: def set_active(self, who): """Marks the event as 'in progress' and will trigger a return event in the morning/evening.""" - if not who in self.in_progress.keys(): + if not who in list(self.in_progress.keys()): raise Exception("Potion '{}' is not marked as usable on '{}'.".format(self.name, who)) self.in_progress[who] = True diff --git a/game/scripts/inventory/potions/_potions_.txt b/game/scripts/inventory/potions/_potions_.txt index 9eef3503..6b5ebffc 100644 --- a/game/scripts/inventory/potions/_potions_.txt +++ b/game/scripts/inventory/potions/_potions_.txt @@ -285,7 +285,7 @@ label potions_menu: for item in potion_choice: if not potion_inv.has(item): missing_items.append(item) - for i in xrange(len(missing_items)): + for i in range(len(missing_items)): tmp_txt += "{size=+5}{b}"+potion_lib.get_name_by_id(missing_items[i])+"{/b}{/size}" if len(missing_items) > 1: if i < len(missing_items)-2: diff --git a/game/scripts/minigames/cardgame/__card_game_init__.rpy b/game/scripts/minigames/cardgame/__card_game_init__.rpy index f9de5475..a5abfdcf 100644 --- a/game/scripts/minigames/cardgame/__card_game_init__.rpy +++ b/game/scripts/minigames/cardgame/__card_game_init__.rpy @@ -19,7 +19,7 @@ default geniecard_level = 1 default tokens = 0 default cardgame_eoc = False # End of content flag -default table_cards = [[None for x in xrange(0,3)] for y in xrange(0,3)] +default table_cards = [[None for x in range(0,3)] for y in range(0,3)] #Special Cards @@ -601,7 +601,7 @@ init python: gretest_func = lambda elm1, elm2 : elm1.get_total_value() < elm2.get_total_value() temp_pool = [] temp_pool.extend(card_pool) - for card in xrange(0,5): + for card in range(0,5): random_choice = renpy.random.choice(temp_pool) new_deck.append(random_choice) @@ -625,7 +625,7 @@ init python: return new_deck def find_index_func(seq, func): func_index = 0 - for i in xrange(0, len(seq)): + for i in range(0, len(seq)): if func(seq[func_index], seq[i]): func_index = i return func_index @@ -671,7 +671,7 @@ init python: def get_rgb_list(hex): hex = hex.lstrip('#') hex_len = len(hex) - rgb = list(int(hex[i:i + hex_len // 3], 16) for i in xrange(0, hex_len, hex_len // 3)) + rgb = list(int(hex[i:i + hex_len // 3], 16) for i in range(0, hex_len, hex_len // 3)) if len(rgb) < 4: rgb.append(255) # Add alpha return rgb @@ -685,8 +685,8 @@ init python: def reset_table_cards(): global table_cards - for y in xrange(0,3): - for x in xrange(0,3): + for y in range(0,3): + for x in range(0,3): table_cards[x][y] = None return @@ -694,8 +694,8 @@ init python: global table_cards playerpoints = len(player_deck) - for y in xrange(0,3): - for x in xrange(0,3): + for y in range(0,3): + for x in range(0,3): if table_cards[x][y] and table_cards[x][y].playercard: playerpoints += 1 if playerpoints > 5: @@ -813,8 +813,8 @@ init python: score_func = lambda a : a take_over = lambda a, b : a > b - for y in xrange(0,3): - for x in xrange(0,3): + for y in range(0,3): + for x in range(0,3): score = 0 if table_cards[x][y] == None: if not y == 0 and not table_cards[x][y-1] == None and table_cards[x][y-1].playercard: diff --git a/game/scripts/minigames/cardgame/_card_game_.rpy b/game/scripts/minigames/cardgame/_card_game_.rpy index b2394e55..059afade 100644 --- a/game/scripts/minigames/cardgame/_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_card_game_.rpy @@ -9,9 +9,9 @@ init python: duel_player_deck = playerdeck backside_list = [] - for i in xrange(0, rules[0]): + for i in range(0, rules[0]): backside_list.append(True) - for i in xrange(rules[0], len(opppent_deck)): + for i in range(rules[0], len(opppent_deck)): backside_list.append(False) ## Setup Deck ## @@ -58,9 +58,9 @@ init python: enemy_deck.append(elm) backside_list = [] - for i in xrange(0, rules[0]): + for i in range(0, rules[0]): backside_list.append(True) - for i in xrange(rules[0], len(opppent_deck)): + for i in range(rules[0], len(opppent_deck)): backside_list.append(False) reset_table_cards() @@ -187,7 +187,7 @@ init python: if rules[3]: rules_list.append(card_rule_double) is_random_deck = True - for x in xrange(len(player_deck)): + for x in range(len(player_deck)): is_random_deck = is_random_deck and (player_deck[x].title is playerdeck[x].title) if not is_random_deck: rules_list.append(card_rule_random) @@ -227,21 +227,21 @@ screen card_battle(l_playerdeck, l_enemydeck, shown_cards): imagemap: ground "images/cardgame/card_table.webp" - for y in xrange(0,3): - for x in xrange(0,3): + for y in range(0,3): + for x in range(0,3): if table_cards[x][y] == None: hotspot (353+124*x, 25+184*y, 125, 182) clicked Return(str(x+y*3)) else: use cardrender(table_cards[x][y], 353+124*x, 25+184*y, cardzoom=0.375, animated=True) - for i in xrange(0, len(l_playerdeck)): + for i in range(0, len(l_playerdeck)): if not selectcard == i: use cardrender(l_playerdeck[i], 18,17+80*i, True) if not selectcard == -1: use cardrender(l_playerdeck[selectcard], 54,17+80*selectcard) - for i in xrange(0, len(l_enemydeck)): + for i in range(0, len(l_enemydeck)): if not selectenemycard == i: use cardrender(l_enemydeck[i], 898,17+80*i, True, backside=shown_cards[i]) @@ -303,14 +303,14 @@ style cardrender_text: screen start_deck(): zorder 26 - for i in xrange(len(unlocked_cards)): + for i in range(len(unlocked_cards)): use cardrender(unlocked_cards[i],40+125*i,200, interact=False, cardzoom=0.375) screen advance_deck(): tag advance_deck zorder 26 - for i in xrange(len(cards_dynamic)): + for i in range(len(cards_dynamic)): use cardrender(cards_dynamic[i],40+125*i,200, interact=False, cardzoom=0.375) text "Tier [geniecard_level]" size 32 color "#fff" ypos 100 xalign 0.5 outlines [ (2, "#000", 0, 0) ] @@ -342,7 +342,7 @@ screen rules_display(game_rules_list): background "#7c716a" vbox: spacing 5 - for i in xrange(len(game_rules_list)): + for i in range(len(game_rules_list)): hbox: add game_rules_list[i].icon text game_rules_list[i].name yalign 0.5 diff --git a/game/scripts/minigames/cardgame/_deck_builder_.rpy b/game/scripts/minigames/cardgame/_deck_builder_.rpy index ca29f401..56010b49 100644 --- a/game/scripts/minigames/cardgame/_deck_builder_.rpy +++ b/game/scripts/minigames/cardgame/_deck_builder_.rpy @@ -54,7 +54,7 @@ screen deck_builder_screen(): $ card_shown=5 imagebutton idle "images/cardgame/deck_builder.webp" action Return("unselect") - for i in xrange(0, clamp(card_shown, 0, (len(unlocked_cards))-(card_shown*currentpage))): + for i in range(0, clamp(card_shown, 0, (len(unlocked_cards))-(card_shown*currentpage))): use cardrender(unlocked_cards[clamp(i+(currentpage*card_shown), 0, len(unlocked_cards))], 18,17+80*i, True) if not selectcard == -1: @@ -89,7 +89,7 @@ screen deck_builder_screen(): ysize 500 text "{size=-5}"+unlocked_cards[selectcard].get_description()+"{/size}" - for i in xrange(0,5): + for i in range(0,5): use cardrender(playerdeck[i], 223+165*i, 17, True, return_value=i, color=True) imagebutton: diff --git a/game/scripts/minigames/cardgame/_loot_box_.rpy b/game/scripts/minigames/cardgame/_loot_box_.rpy index 110b661c..6c96da2d 100644 --- a/game/scripts/minigames/cardgame/_loot_box_.rpy +++ b/game/scripts/minigames/cardgame/_loot_box_.rpy @@ -4,7 +4,7 @@ screen card_lootbox(): use blktone - for i in xrange(len(card_loot)): + for i in range(len(card_loot)): if card_loot[i] in cards_realm: frame: style "empty" @@ -22,7 +22,7 @@ label card_lootbox: cards_choice = [card_iris, card_jasmine, card_azalea, card_dahlia, card_aladdin, card_maslab, card_lilly, card_rasul, card_jafar, card_her_schoolgirl, card_lun_schoolgirl, card_sus_schoolgirl, card_cho_schoolgirl] rand_card = None - for i in xrange(5): + for i in range(5): rand_card = random.choice(cards_items) if i == 4: diff --git a/game/scripts/minigames/cardgame/_snape_card_game_.rpy b/game/scripts/minigames/cardgame/_snape_card_game_.rpy index 235efde1..56635628 100644 --- a/game/scripts/minigames/cardgame/_snape_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_snape_card_game_.rpy @@ -331,7 +331,7 @@ label snape_random_duel: hide screen blkfade python: - ingredients = filter(lambda x: x.price > 0, inventory.get_instances_of_type("ingredient")) + ingredients = [x for x in inventory.get_instances_of_type("ingredient") if x.price > 0] item = renpy.random.choice(ingredients) if not random_snape_win: diff --git a/game/scripts/minigames/mirror/classes.rpy b/game/scripts/minigames/mirror/classes.rpy index 9bce2cdb..74c99e4e 100644 --- a/game/scripts/minigames/mirror/classes.rpy +++ b/game/scripts/minigames/mirror/classes.rpy @@ -20,7 +20,7 @@ init 5 python: if tag == "All": return self.get_instances() - return filter(lambda x: tag in x.tags, self.get_instances()) + return [x for x in self.get_instances() if tag in x.tags] def get_tags(self): return sorted({"All"} | {tag for x in self.get_instances() for tag in x.tags}) diff --git a/game/scripts/minigames/mirror/menu.rpy b/game/scripts/minigames/mirror/menu.rpy index 57df38fa..c4f01ca5 100644 --- a/game/scripts/minigames/mirror/menu.rpy +++ b/game/scripts/minigames/mirror/menu.rpy @@ -1,9 +1,9 @@ init python: def mirror_sortfilter(item, sortby="A-z", filtering=None): if filtering == "Locked": - item = filter(lambda x: x.is_unlocked(), item) + item = [x for x in item if x.is_unlocked()] elif filtering == "Unlocked": - item = filter(lambda x: x.is_unlocked() is True, item) + item = [x for x in item if x.is_unlocked() is True] # Always sort alphabetically first. item = sorted(item, key=lambda x: natsort_key(x.name)) @@ -19,17 +19,18 @@ label mirror: label mirror_menu(xx=150, yy=90): - $ mirror_categories = mirror.get_tags() + python: + mirror_categories = mirror.get_tags() - $ items_shown = 36 - $ current_page = 0 - $ current_category = mirror_categories[0] - $ current_filter = "Unlocked" - $ current_sorting = "A-z" + items_shown = 36 + current_page = 0 + current_category = mirror_categories[0] + current_filter = "Unlocked" + current_sorting = "A-z" - $ menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter) - $ menu_items_length = len(menu_items) - $ current_item = next(iter(menu_items), None) + menu_items = mirror_sortfilter(mirror.get_instances_of_tag(current_category), current_sorting, current_filter) + menu_items_length = len(menu_items) + current_item = next(iter(menu_items), None) show screen mirror(xx, yy) diff --git a/game/scripts/minigames/puzzle.rpy b/game/scripts/minigames/puzzle.rpy index 5f821924..92fb1ba0 100644 --- a/game/scripts/minigames/puzzle.rpy +++ b/game/scripts/minigames/puzzle.rpy @@ -4,14 +4,14 @@ init python: tiles = grid*grid difficulty = difficulty * tiles - puzzle = list(xrange(tiles)) + puzzle = list(range(tiles)) renpy.random.shuffle(puzzle) def is_valid(): inversions = 0 - for x in xrange(tiles): - for y in xrange(x+1, tiles): + for x in range(tiles): + for y in range(x+1, tiles): if not (puzzle[x] == blank or puzzle[y] == blank) and puzzle[x] > puzzle[y]: inversions += 1 @@ -96,7 +96,7 @@ screen puzzle_minigame(): if tries >= 75: textbutton "-Force it open-" xalign 0.5 action Return(False) at pulse_hover if config.developer: - textbutton "-Solve it-" xalign 0.5 action SetScreenVariable("tiles", list(xrange(16))) + textbutton "-Solve it-" xalign 0.5 action SetScreenVariable("tiles", list(range(16))) label puzzle_minigame: call screen puzzle_minigame() diff --git a/game/scripts/mods.rpy b/game/scripts/mods.rpy index 9da06a3d..0b8cd87a 100644 --- a/game/scripts/mods.rpy +++ b/game/scripts/mods.rpy @@ -13,12 +13,12 @@ init python: global mods_list all_files = renpy.list_files() - mods = filter(lambda x: x.endswith(".json"), all_files) + mods = [x for x in all_files if x.endswith(".json")] for i, manifest in enumerate(mods): path = os.path.split(manifest)[0] - files = filter(lambda x: path in x, all_files) - scripts = filter(lambda x: x.endswith(".rpym"), files) + files = [x for x in all_files if path in x] + scripts = [x for x in files if x.endswith(".rpym")] logo = "{}/logo.webp".format(path) if not renpy.loadable(logo): @@ -64,14 +64,14 @@ init python: with renpy.open_file(file) as s: data = s.read() - print "Loading '{}'".format(mod) + print("Loading '{}'".format(mod)) #renpy.load_module(os.path.splitext(file)[0]) try: renpy.load_string(data, filename="game/{}/{}".format(path, fn)) except Exception as e: - print "Loading '{}' has failed.\nFile: {}\nError: {}".format(mod, fn, e) + print("Loading '{}' has failed.\nFile: {}\nError: {}".format(mod, fn, e)) mods_parsed.add(mod) renpy.execute_default_statement(False) @@ -131,20 +131,20 @@ init python: error_f, error_fn = rpy_error.open_error_file(os.path.join(dp, "errors.txt"), "w") with error_f: - error_f.write(u"\ufeff") # BOM - error_f.write(u"I'm sorry, but errors were detected in your mod script.\nPlease correct the errors listed below, and try again.\n\n") + error_f.write("\ufeff") # BOM + error_f.write("I'm sorry, but errors were detected in your mod script.\nPlease correct the errors listed below, and try again.\n\n") for i in errors: if not isinstance(i, str): i = str(i, "utf-8", "replace") error_f.write(i) - error_f.write(u"\n\n") + error_f.write("\n\n") # We need to remove reported errors to avoid incorrectly detecting .rpym format in the next call. renpy.parser.parse_errors.remove(i) - error_f.write(u"Game Version: {}\nRen'Py Version: {}\n{}".format(renpy.store.version, renpy.version_only, str(time.ctime()))) + error_f.write("Game Version: {}\nRen'Py Version: {}\n{}".format(renpy.store.version, renpy.version_only, str(time.ctime()))) try: if renpy.game.args.command == "run": # @UndefinedVariable diff --git a/game/scripts/options.rpy b/game/scripts/options.rpy index e10f6ca2..78c991c8 100644 --- a/game/scripts/options.rpy +++ b/game/scripts/options.rpy @@ -35,7 +35,7 @@ define compatible_version = 1.43 define config.name = "Witch Trainer Silver" # Application window settings -define config.window_title = "{} (v{}) ({}) ({}-bit)".format(config.name, config.version, get_renderer(), renpy.bits) +define config.window_title = f"{config.name} (v{config.version}) ({get_renderer()}) ({renpy.bits}-bit)" define config.window_icon = "gui/icon.webp" define config.screen_width = 1080 define config.screen_height = 600 diff --git a/game/scripts/rooms/main_room/objects/cupboard.rpy b/game/scripts/rooms/main_room/objects/cupboard.rpy index bb0fc4f4..412aef21 100644 --- a/game/scripts/rooms/main_room/objects/cupboard.rpy +++ b/game/scripts/rooms/main_room/objects/cupboard.rpy @@ -122,7 +122,7 @@ init python: if game.gold < int(170 * math.log(game.day)) and random_percent <= 56 - dr: return int(progress_factor * random_gold) else: - filtered_list = filter(lambda x: x.owned <= 5, drop_list) + filtered_list = [x for x in drop_list if x.owned <= 5] random_item = renpy.random.choice(filtered_list if filtered_list else drop_list) return random_item @@ -132,7 +132,7 @@ init python: if game.gold < int(120 * math.log(game.day)) and random_percent <= 38 - dr: return int(progress_factor * random_gold) else: - filtered_list = filter(lambda x: x.owned <= 3, drop_list) + filtered_list = [x for x in drop_list if x.owned <= 3] random_item = renpy.random.choice(filtered_list if filtered_list else drop_list) if int(120 * math.log(game.day)) / 3 < random_item.price: diff --git a/game/scripts/rooms/quidditch_pitch/init.rpy b/game/scripts/rooms/quidditch_pitch/init.rpy index ee361749..3f9602ce 100644 --- a/game/scripts/rooms/quidditch_pitch/init.rpy +++ b/game/scripts/rooms/quidditch_pitch/init.rpy @@ -4,7 +4,7 @@ screen quid_pitch_back(): zorder 0 add "images/rooms/quidditch_pitch/back.webp" zoom 0.5 if game.weather == "cloudy": - for i in xrange(random.randint(2, 5)): + for i in range(random.randint(2, 5)): add "object" at OBJcloud add "images/rooms/quidditch_pitch/back_overlay.webp" zoom 0.5 @@ -17,5 +17,5 @@ screen quid_pitch_front(): sensitive False zorder 5 add "images/rooms/quidditch_pitch/front.webp" zoom 0.5 - for i in xrange(random.randint(1, 3)): + for i in range(random.randint(1, 3)): add "object" at OBJbutterfly diff --git a/game/scripts/shops/dress/menu.rpy b/game/scripts/shops/dress/menu.rpy index 22e4ab7c..7b5cc99a 100644 --- a/game/scripts/shops/dress/menu.rpy +++ b/game/scripts/shops/dress/menu.rpy @@ -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(filter(lambda x: bool(x.unlocked == False and x.price > 0 and not x in store_cart), category_items.get(current_category, [])), current_sorting) + 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) current_item = next(iter(menu_items), None) show screen shop_dress() @@ -36,7 +36,7 @@ label shop_dress_menu: if _choice[0] == "category": $ current_category = _choice[1] - $ menu_items = shop_dress_sortfilter(filter(lambda x: bool(x.unlocked == False and x.price > 0 and not x in store_cart), category_items.get(current_category, [])), current_sorting) + $ 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) $ current_item = next(iter(menu_items), None) elif _choice[0] == "buy": show screen blktone @@ -50,7 +50,7 @@ label shop_dress_menu: $ renpy.play("sounds/money.ogg") $ game.gold -= _choice[1].price $ store_cart.add(_choice[1]) - $ menu_items = shop_dress_sortfilter(filter(lambda x: bool(x.unlocked == False and x.price > 0 and not x in store_cart), category_items.get(current_category, [])), current_sorting) + $ 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) $ current_item = next(iter(menu_items), None) if len(store_cart) < 5: @@ -72,7 +72,7 @@ label shop_dress_menu: elif current_sorting == "Lewdness (Desc)": $ current_sorting = "Price (Asc)" - $ menu_items = shop_dress_sortfilter(filter(lambda x: bool(x.unlocked == False and x.price > 0 and not x in store_cart), category_items.get(current_category, [])), current_sorting) + $ 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) else: # Close if len(store_cart) < 5: show screen blktone @@ -154,7 +154,7 @@ screen shop_dress_menu(): vbox: pos (6, 6) - for category in category_items.iterkeys(): + for category in category_items.keys(): if getattr(renpy.store, category+"_unlocked"): $ icon = Fixed(icon_bg, Frame( Transform("interface/icons/head/{}.webp".format(category), fit="contain"), xysize=(42, 42), offset=(3, 3)), "interface/achievements/glass_iconbox.webp") diff --git a/game/scripts/shops/item/menu.rpy b/game/scripts/shops/item/menu.rpy index c742ff2f..4f5f2ecc 100644 --- a/game/scripts/shops/item/menu.rpy +++ b/game/scripts/shops/item/menu.rpy @@ -14,29 +14,31 @@ label shop_item: return label shop_item_menu(xx=150, yy=90): - $ inventory_dict = { - "Gifts": inventory.get_instances_of_type("gift"), - "Books": inventory.get_instances_of_type("book"), - "Scrolls": inventory.get_instances_of_type("scroll"), - "Ingredients": inventory.get_instances_of_type("ingredient"), - "Decorations": inventory.get_instances_of_type("decoration"), - "Quest Items": inventory.get_instances_of_type("quest"), - } - $ items_shown = 36 - $ current_page = 0 - $ current_category = next(iter(inventory_dict.iterkeys())) - $ current_sorting = "Price (Asc)" + python: + inventory_dict = { + "Gifts": inventory.get_instances_of_type("gift"), + "Books": inventory.get_instances_of_type("book"), + "Scrolls": inventory.get_instances_of_type("scroll"), + "Ingredients": inventory.get_instances_of_type("ingredient"), + "Decorations": inventory.get_instances_of_type("decoration"), + "Quest Items": inventory.get_instances_of_type("quest"), + } - if current_category in {"Gifts", "Ingredients"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.unlocked), inventory_dict[current_category]) - elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.owned < x.limit and x.unlocked), inventory_dict[current_category]) + items_shown = 36 + current_page = 0 + current_category = next(iter(inventory_dict.keys())) + current_sorting = "Price (Asc)" - $ menu_items = shop_item_sortfilter(category_items, current_sorting) - $ menu_items_length = len(menu_items) + if current_category in {"Gifts", "Ingredients"}: + category_items = [x for x in inventory_dict[current_category] if bool(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)] - $ current_item = next(iter(menu_items), None) + menu_items = shop_item_sortfilter(category_items, current_sorting) + menu_items_length = len(menu_items) + + current_item = next(iter(menu_items), None) show screen shop_item(xx, yy) @@ -48,9 +50,9 @@ label shop_item_menu(xx=150, yy=90): elif _choice[0] == "category": $ current_category = _choice[1] if current_category in {"Gifts", "Ingredients"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.unlocked), inventory_dict[current_category]) + $ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)] elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.owned < x.limit and x.unlocked), inventory_dict[current_category]) + $ category_items = [x for x in inventory_dict[current_category] if bool(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 @@ -71,9 +73,9 @@ label shop_item_menu(xx=150, yy=90): $ renpy.call("purchase_item", current_item) if current_category in {"Gifts", "Ingredients"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.unlocked), inventory_dict[current_category]) + $ category_items = [x for x in inventory_dict[current_category] if bool(x.price > 0 and x.unlocked)] elif current_category in {"Books", "Scrolls", "Decorations", "Quest Items"}: - $ category_items = filter(lambda x: bool(x.price > 0 and x.owned < x.limit and x.unlocked), inventory_dict[current_category]) + $ category_items = [x for x in inventory_dict[current_category] if bool(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) @@ -126,7 +128,7 @@ screen shop_item_menu(xx, yy): vbox: pos (6, 41) - for category in inventory_dict.iterkeys(): + for category in inventory_dict.keys(): vbox: textbutton category: style "empty" @@ -191,7 +193,7 @@ screen shop_item_menuitem(xx, yy): action Return("inc") # Add items - for i in xrange(current_page*items_shown, (current_page*items_shown)+items_shown): + for i in range(current_page*items_shown, (current_page*items_shown)+items_shown): if i < menu_items_length: $ price = menu_items[i].price diff --git a/game/scripts/utility/devtools.rpy b/game/scripts/utility/devtools.rpy index 972dcee1..8a5efd17 100644 --- a/game/scripts/utility/devtools.rpy +++ b/game/scripts/utility/devtools.rpy @@ -79,10 +79,10 @@ init -1 python: file = os.path.normpath(config.gamedir + "/images.whitespace") with open(file, "w") as f: - for img, box in sorted(whitespace_dict.iteritems()): - f.write(u"{}:{},{},{},{}\n".format(img, *box)) + for img, box in sorted(whitespace_dict.items()): + f.write("{}:{},{},{},{}\n".format(img, *box)) - print "\rCalculating whitespace... Done!" + print("\rCalculating whitespace... Done!") return False label missing_label(): diff --git a/game/scripts/utility/lint.rpy b/game/scripts/utility/lint.rpy index e5b69b4f..6ce193a5 100644 --- a/game/scripts/utility/lint.rpy +++ b/game/scripts/utility/lint.rpy @@ -78,9 +78,9 @@ init -1 python: else: kwargs[key] = val - for key, val in kwargs.iteritems(): + for key, val in list(kwargs.items()): # Validate facial expressions - if key in EXPRESSIONS and who in SAYERS.iterkeys(): + if key in EXPRESSIONS and who in iter(list(SAYERS.keys())): if val is None: continue diff --git a/game/scripts/utility/load_fix.rpy b/game/scripts/utility/load_fix.rpy index fa56b40e..84b6179a 100644 --- a/game/scripts/utility/load_fix.rpy +++ b/game/scripts/utility/load_fix.rpy @@ -15,7 +15,7 @@ init 2 python: # context = renpy.game.context() # script = renpy.game.script -# for i in xrange(-1, -len(context.return_stack)-1, -1): +# for i in range(-1, -len(context.return_stack)-1, -1): # node = None # if script.has_label(context.return_stack[i]): diff --git a/game/scripts/utility/punk.rpy b/game/scripts/utility/punk.rpy index 8a573f69..356fc802 100644 --- a/game/scripts/utility/punk.rpy +++ b/game/scripts/utility/punk.rpy @@ -70,7 +70,7 @@ init python: self._rewind_bytes(8) chunk_size = len(self._bytes_to_hide) - print 'Hiding', (chunk_size / 1024), 'kB (', chunk_size, 'bytes)' + print('Hiding', (chunk_size / 1024), 'kB (', chunk_size, 'bytes)') # Create a temporary byte array for the CRC check. tmp_bytes = bytearray() @@ -106,10 +106,10 @@ init python: def _read_next_chunk(self): chunk_size = self._read_bytes_as_int(4) - print 'Chunk size:', chunk_size + print('Chunk size:', chunk_size) chunk_type = self._read_bytes_as_ascii(4) - print 'Chunk type:', chunk_type + print('Chunk type:', chunk_type) if self._mode == 'encode' and chunk_type == self._END_CHUNK_TYPE: self._inject_punk_chunk() @@ -121,15 +121,15 @@ init python: content = self._read_bytes(chunk_size) crc = self._read_bytes_as_hex(4) - print 'CRC:', crc + print('CRC:', crc) if self._mode == 'decode' and chunk_type == self._PUNK_CHUNK_TYPE: - print "Found a chunk data", len(content), "bytes. Importing.." + print("Found a chunk data", len(content), "bytes. Importing..") #self._output.write(bytearray(content)) #self._output.close() self._output = content.decode('utf-8') self._file.close() - print "Done." + print("Done.") return True self._read_next_chunk() diff --git a/game/scripts/wardrobe/functions.rpy b/game/scripts/wardrobe/functions.rpy index 55425d02..80ebcc45 100644 --- a/game/scripts/wardrobe/functions.rpy +++ b/game/scripts/wardrobe/functions.rpy @@ -42,12 +42,12 @@ init python: if not has_panties: req += ["NO PANTIES: {}".format(get_character_requirement(key, "unequip panties"))] - print "\n".join(req) + print("\n".join(req)) def get_character_outfit_hash(key): ### Untested ### char = get_character_object(key) - clothes = [x[0] for x in char.clothes.itervalues() if x[0]] + clothes = [x[0] for x in char.clothes.values() if x[0]] salt = str( sorted([ sorted([x.name, x.type, x.id, x.color]) for x in clothes ]) ) return hash(salt) diff --git a/game/scripts/wardrobe/studio.rpy b/game/scripts/wardrobe/studio.rpy index a269a2d2..a2c72810 100644 --- a/game/scripts/wardrobe/studio.rpy +++ b/game/scripts/wardrobe/studio.rpy @@ -205,7 +205,7 @@ screen studio(): add bg draggroup: - for i in studio.drags.itervalues(): + for i in studio.drags.values(): if i[1]: add i[0] @@ -300,7 +300,7 @@ screen studio(): vbox: label "Characters" vbox: - for k, v in studio.drags.iteritems(): + for k, v in studio.drags.items(): $ active = (active_girl == k and v[1]) $ unlocked = getattr(renpy.store, k+"_unlocked") diff --git a/game/scripts/wardrobe/wardrobe.rpy b/game/scripts/wardrobe/wardrobe.rpy index 271d2290..0f6de1f7 100644 --- a/game/scripts/wardrobe/wardrobe.rpy +++ b/game/scripts/wardrobe/wardrobe.rpy @@ -63,7 +63,7 @@ label wardrobe_menu(): # Defaults current_category = "head" - category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) + category_items = OrderedDict(sorted(iter(list(wardrobe_subcategories.get(current_category, {}).items())), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True)) current_subcategory = list(category_items.keys())[0] if category_items else "" menu_items = [x for x in category_items.get(current_subcategory, []) if x.unlocked==True] current_item = char_active.get_equipped_item(menu_items)