From be88d0ed7e9857e31a33d74c0325952e942cc675 Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:31:41 +0100 Subject: [PATCH] A bunch more f-strings I'm not done --- game/scripts/cg/xray.rpy | 6 +-- game/scripts/characters/genie/common.rpy | 2 +- game/scripts/characters/hermione/chibi.rpy | 8 +-- game/scripts/chibis/classes.rpy | 16 +++--- game/scripts/doll/bodypart.rpy | 4 +- game/scripts/doll/clothes.rpy | 6 +-- game/scripts/doll/clothes_dynamic.rpy | 2 +- game/scripts/doll/face.rpy | 4 +- game/scripts/doll/makeup.rpy | 2 +- game/scripts/doll/outfits.rpy | 3 +- game/scripts/gui/_gui_.rpy | 4 +- game/scripts/gui/history.rpy | 2 +- game/scripts/gui/preferences.rpy | 10 ++-- game/scripts/gui/save_files.rpy | 8 +-- game/scripts/gui/say.rpy | 2 +- game/scripts/interface/brewing.rpy | 2 +- game/scripts/interface/parcel.rpy | 6 +-- game/scripts/interface/tutorials.rpy | 5 +- game/scripts/inventory/classes.rpy | 50 ++++++++++--------- game/scripts/inventory/game.rpy | 8 +-- .../minigames/cardgame/_card_game_.rpy | 2 +- game/scripts/minigames/mirror/classes.rpy | 8 +-- game/scripts/minigames/mirror/menu.rpy | 2 +- game/scripts/minigames/puzzle.rpy | 2 +- game/scripts/mods.rpy | 4 +- game/scripts/rooms/labels.rpy | 4 +- game/scripts/rooms/quidditch_stands/init.rpy | 8 +-- game/scripts/rooms/quidditch_stands2/init.rpy | 6 +-- game/scripts/shops/dress/menu.rpy | 4 +- game/scripts/utility/common_functions.rpy | 2 +- 30 files changed, 100 insertions(+), 92 deletions(-) diff --git a/game/scripts/cg/xray.rpy b/game/scripts/cg/xray.rpy index fd620e74..d95af604 100644 --- a/game/scripts/cg/xray.rpy +++ b/game/scripts/cg/xray.rpy @@ -82,12 +82,12 @@ init python: child = getattr(self, layer) if isinstance(child, ImageReference): - name = getattr(self, "_{}".format(layer)) - attributes = renpy.get_attributes(name) or renpy.get_attributes("{}_{}".format(tag_prefix, layer)) + name = getattr(self, f"_{layer}") + attributes = renpy.get_attributes(name) or renpy.get_attributes(f"{tag_prefix}_{layer}") if attributes: attributes = " ".join(attributes) - child = ImageReference("{} {}".format(name, attributes)) + child = ImageReference(f"{name} {attributes}") elif child.name != name: child = ImageReference(name) else: diff --git a/game/scripts/characters/genie/common.rpy b/game/scripts/characters/genie/common.rpy index d49fca14..2591fc40 100644 --- a/game/scripts/characters/genie/common.rpy +++ b/game/scripts/characters/genie/common.rpy @@ -24,7 +24,7 @@ init python: states.gen.image.offset = (0, 600) if face: - variant = "genie {}".format(face) + variant = f"genie {face}" renpy.set_tag_attributes(variant) side = "genie" diff --git a/game/scripts/characters/hermione/chibi.rpy b/game/scripts/characters/hermione/chibi.rpy index c2396c72..07b26c43 100644 --- a/game/scripts/characters/hermione/chibi.rpy +++ b/game/scripts/characters/hermione/chibi.rpy @@ -82,7 +82,7 @@ init python: else: chibi["base"] = "ch_hem walk_robe_n" else: - chibi["base"] = "ch_hem walk" + chibi["base"] = "ch_hem walk" elif not chibi.action or chibi.action == "stand": # Determine clothing state @@ -97,7 +97,7 @@ init python: else: chibi["base"] = "ch_hem blink_robe_n" else: - chibi["base"] = "ch_hem blink" + chibi["base"] = "ch_hem blink" elif chibi.action == "dance": # Determine clothing state @@ -140,9 +140,9 @@ init python: elif chibi.action in ("drink_potion", "sniff_potion", "hold_potion"): if not hermione.is_any_worn("top", "bottom"): - chibi["base"] = "ch_hem {}_nude".format(chibi.action) + chibi["base"] = f"ch_hem {chibi.action}_nude" else: - chibi["base"] = "ch_hem {}".format(chibi.action) + chibi["base"] = f"ch_hem {chibi.action}" # Sets up a chibi scene with Hermione and Genie in it diff --git a/game/scripts/chibis/classes.rpy b/game/scripts/chibis/classes.rpy index fda56e1d..2e8abea5 100644 --- a/game/scripts/chibis/classes.rpy +++ b/game/scripts/chibis/classes.rpy @@ -14,7 +14,7 @@ screen chibi(chibi_object): screen chibi_emote(emote, chibi_object): zorder chibi_object.zorder sensitive False - add "emo_{}".format(emote): + add f"emo_{emote}": at emote_effect anchor (0.5, 1.0) pos chibi_object.pos @@ -45,12 +45,12 @@ init -1 python: def get_chibi_object(name): """Get a chibi object by its character's name.""" - name = "{}_chibi".format(name) + name = f"{name}_chibi" c = getattr(renpy.store, name, None) if c and isinstance(c, Chibi): return c else: - raise Exception("Chibi object not found. {}".format(name)) + raise Exception(f"Chibi object not found. {name}") def complete_chibi_moves(**elapsed): """Resume old chibi action after (multiple) reduced move calls.""" @@ -120,7 +120,7 @@ init -1 python: if image_path: self.image_path = image_path else: - self.image_path = "characters/{}/chibis".format(tag) + self.image_path = f"characters/{tag}/chibis" if actions: # Override class variable for this instance @@ -138,11 +138,11 @@ init -1 python: self.transform = None # Define a screen for the chibi - self.screen_tag = "{}_chibi".format(tag) + self.screen_tag = f"{tag}_chibi" renpy.define_screen(self.screen_tag, Chibi._screen, tag=self.screen_tag, zorder="chibi_object.zorder") # Define a screen for the chibi emote - self.emote_tag = "{}_chibi_emote".format(tag) + self.emote_tag = f"{tag}_chibi_emote" renpy.define_screen(self.emote_tag, Chibi._emote_screen, tag=self.emote_tag, zorder="chibi_object.zorder") @staticmethod @@ -282,7 +282,7 @@ init -1 python: # Combine with base transform return combine_transforms(self.base_transform(), trans(*args)) elif config.developer: - raise Exception("Expected a transform: {}".format(name)) + raise Exception(f"Expected an ATL transform: {name}") # No transform was given or found return self.base_transform() @@ -358,7 +358,7 @@ init -1 python: room = room or renpy.store.states.room chibi_room = ChibiRoom.rooms.get(room, None) if not chibi_room: - raise Exception("Chibi room is not defined for {}".format(room)) + raise Exception(f"Chibi room is not defined for {room}") return chibi_room @staticmethod diff --git a/game/scripts/doll/bodypart.rpy b/game/scripts/doll/bodypart.rpy index 2bdc3379..fccf8b98 100644 --- a/game/scripts/doll/bodypart.rpy +++ b/game/scripts/doll/bodypart.rpy @@ -37,7 +37,7 @@ init 1 python: ltype, *tails = fn.rsplit("_") # if not ltype in types: - # print("Invalid layer type for file: {}".format(f)) + # print(f"Invalid layer type for file: {f}") # continue zorder = types.get(ltype) or self.zorder @@ -50,7 +50,7 @@ init 1 python: lmodifier, *tails = tails if not lmodifier in modifiers: - print("Invalid modifier for file: {}".format(f)) + print(f"Invalid modifier for file: {f}") continue zorder_mod = modifiers.get(lmodifier) diff --git a/game/scripts/doll/clothes.rpy b/game/scripts/doll/clothes.rpy index 287b08ac..1d4fbc08 100644 --- a/game/scripts/doll/clothes.rpy +++ b/game/scripts/doll/clothes.rpy @@ -108,7 +108,7 @@ init python: ltype, *tails = fn.rsplit("_") if not ltype.isdigit() and not ltype in types: - print("Invalid layer type for file: {}".format(f)) + print(f"Invalid layer type for file: {f}") continue zorder = z if (z := types.get(ltype)) is not None else self.zorder @@ -121,7 +121,7 @@ init python: lmodifier, *tails = tails if not lmodifier in modifiers: - print("Invalid modifier for file: {}".format(f)) + print(f"Invalid modifier for file: {f}") continue zorder_mod = modifiers.get(lmodifier) @@ -319,7 +319,7 @@ init python: # Method 4 average = (0.3333, 0.3333, 0.3333) - + return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha)) except TypeError: diff --git a/game/scripts/doll/clothes_dynamic.rpy b/game/scripts/doll/clothes_dynamic.rpy index dad5497d..f97d7d73 100644 --- a/game/scripts/doll/clothes_dynamic.rpy +++ b/game/scripts/doll/clothes_dynamic.rpy @@ -131,7 +131,7 @@ init python: lmodifier, *tails = tails if not lmodifier in modifiers: - print("Invalid modifier for file: {}".format(f)) + print(f"Invalid modifier for file: {f}") continue zorder_mod = modifiers.get(lmodifier) diff --git a/game/scripts/doll/face.rpy b/game/scripts/doll/face.rpy index c655ea91..2befdd73 100644 --- a/game/scripts/doll/face.rpy +++ b/game/scripts/doll/face.rpy @@ -54,7 +54,7 @@ init python: ltype, *tails = fn.rsplit("_") if not ltype in types: - print("Invalid layer type for file: {}".format(f)) + print(f"Invalid layer type for file: {f}") continue zorder = types.get(ltype) or face_layers.get(part) @@ -63,7 +63,7 @@ init python: lmodifier, *tails = tails if not lmodifier in modifiers: - print("Invalid modifier for file: {}".format(f)) + print(f"Invalid modifier for file: {f}") continue zorder_mod = modifiers.get(lmodifier) diff --git a/game/scripts/doll/makeup.rpy b/game/scripts/doll/makeup.rpy index 83beb706..041e8199 100644 --- a/game/scripts/doll/makeup.rpy +++ b/game/scripts/doll/makeup.rpy @@ -49,7 +49,7 @@ init python: lmodifier, *tails = tails if not lmodifier in modifiers: - print("Invalid modifier for file: {}".format(f)) + print(f"Invalid modifier for file: {f}") continue zorder_mod = modifiers.get(lmodifier) diff --git a/game/scripts/doll/outfits.rpy b/game/scripts/doll/outfits.rpy index 5b3a1bb4..d48c8869 100644 --- a/game/scripts/doll/outfits.rpy +++ b/game/scripts/doll/outfits.rpy @@ -218,7 +218,7 @@ init python: d, "interface/wardrobe/export_frame.webp", Text(states.active_girl, align=(0.5, 0.995)), - Text("Ver. {}".format(config.version), size=10, align=(0.99, 0.99)) + Text(f"Ver. {config.version}", size=10, align=(0.99, 0.99)) ) displayable_to_file(d, path, size=(310, 470) ) @@ -286,4 +286,3 @@ init python: if self.has_type(arg): return True return False - diff --git a/game/scripts/gui/_gui_.rpy b/game/scripts/gui/_gui_.rpy index 5408841e..11ea40a9 100644 --- a/game/scripts/gui/_gui_.rpy +++ b/game/scripts/gui/_gui_.rpy @@ -26,7 +26,9 @@ init python in gui: The returned form is "{theme}_{name}", so styles can fall back on parent styles. """ theme = "dark" if is_dark() else "light" - return "{}_{}".format(theme, name) if name else theme + if name: + return f"{theme}_{name}" + return theme def format(template): """ diff --git a/game/scripts/gui/history.rpy b/game/scripts/gui/history.rpy index 4421da72..3574a9cc 100644 --- a/game/scripts/gui/history.rpy +++ b/game/scripts/gui/history.rpy @@ -36,7 +36,7 @@ screen history(): if "icon" in entry.show_args: $ icon = entry.show_args["icon"] - add Fixed(gui.format("interface/achievements/{}/iconbox.webp"), Transform("interface/icons/head/{}.webp".format(icon), xzoom=-1, size=(40, 40), align=(0.5, 0.5)), fit_first=True) + add Fixed(gui.format("interface/achievements/{}/iconbox.webp"), Transform(f"interface/icons/head/{icon}.webp", xzoom=-1, size=(40, 40), align=(0.5, 0.5)), fit_first=True) if entry.who: text entry.who: diff --git a/game/scripts/gui/preferences.rpy b/game/scripts/gui/preferences.rpy index 20dc544e..06ba5630 100644 --- a/game/scripts/gui/preferences.rpy +++ b/game/scripts/gui/preferences.rpy @@ -138,7 +138,7 @@ screen preferences_visuals(): label "Framerate" - textbutton ("{} fps".format(int(renpy.get_refresh_rate()))) action [Preference("gl framerate", None), Notify(fps_msg)] + textbutton (f"{int(renpy.get_refresh_rate())} fps") action [Preference("gl framerate", None), Notify(fps_msg)] if renpy.get_refresh_rate() > 60: textbutton "60 fps" action [Preference("gl framerate", 60), Notify(fps_msg)] textbutton "30 fps" action [Preference("gl framerate", 30), Notify(fps_msg)] @@ -178,7 +178,7 @@ screen preferences_visuals(): hbox: bar value DictValue(persistent.custom_settings, "image_cache_size", range=1792, max_is_zero=False, style="slider", offset=256, step=128, force_step=True, action=Notify("Restart the game to apply image cache size changes.")) tooltip "Improves performance at a cost of higher memory usage." - + text get_gpu_info() yalign 1.0 size 10 screen preferences_sound(): @@ -325,9 +325,9 @@ auto saves, quick saves, and manual saves.{/size}\n Are you sure?""" define gui.SAVE_INCOMPATIBLE_WARNING = """{color=#7a0000}Warning!{/color} -{size=-4}The save file you are attempting to load is not compatible -with the current game version. While you can try loading it, -doing so may result in unexpected crashes and bugs. +{size=-4}The save file you are attempting to load is not compatible +with the current game version. While you can try loading it, +doing so may result in unexpected crashes and bugs. Proceed anyway?""" diff --git a/game/scripts/gui/save_files.rpy b/game/scripts/gui/save_files.rpy index cccb1a4d..a50545bb 100644 --- a/game/scripts/gui/save_files.rpy +++ b/game/scripts/gui/save_files.rpy @@ -93,8 +93,8 @@ screen file_slots(title): $ hours, minutes = divmod(minutes, 60) text FileTime(slot, format=slot_time_format) - text "Day: {}".format(day) - text "Playtime: {}H {}M {}S".format(hours, minutes, seconds) + text f"Day: {day}" + text f"Playtime: {hours}H {minutes}M {seconds}S" else: text "INCOMPATIBLE VERSION" color "#f00" @@ -104,7 +104,7 @@ screen file_slots(title): key "save_delete" action FileDelete(slot) else: - text "Empty Slot {}.".format(FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)) style "slot_button_text" + text f"Empty Slot {FileSlotName(slot, gui.file_slot_cols * gui.file_slot_rows)}." style "slot_button_text" ## Buttons to access other pages. hbox: @@ -131,7 +131,7 @@ screen file_slots(title): xminimum 40 action FilePage(page) if page < 10: - keysym "K_{}".format(page) + keysym f"K_{page}" textbutton _(">") action FilePageNext() diff --git a/game/scripts/gui/say.rpy b/game/scripts/gui/say.rpy index 49af47c2..d58bea62 100644 --- a/game/scripts/gui/say.rpy +++ b/game/scripts/gui/say.rpy @@ -193,7 +193,7 @@ screen choice(items, menu_yalign=.6): style "empty" if style_part: - style_prefix gui.theme("{}_menu".format(style_part)) + style_prefix gui.theme(f"{style_part}_menu") fit_first "height" diff --git a/game/scripts/interface/brewing.rpy b/game/scripts/interface/brewing.rpy index 39f568fe..d164c172 100644 --- a/game/scripts/interface/brewing.rpy +++ b/game/scripts/interface/brewing.rpy @@ -170,7 +170,7 @@ screen brewing_menuitem(): text "Usable on:" size 12 hbox: for c in current_item.usable_on: - add "interface/icons/head/{}.webp".format(c) size (24, 24) + add f"interface/icons/head/{c}.webp" size (24, 24) hbox: spacing 10 diff --git a/game/scripts/interface/parcel.rpy b/game/scripts/interface/parcel.rpy index f8c75595..f82778df 100644 --- a/game/scripts/interface/parcel.rpy +++ b/game/scripts/interface/parcel.rpy @@ -62,11 +62,11 @@ init python: icon = item.image if quantity == 1: - text = "You have received one {}.".format(item.name) + text = f"You have received one {item.name}." else: - text = "You have received {} pieces of {}.".format(num_to_word(quantity), item.name) + text = f"You have received {num_to_word(quantity)} pieces of {item.name}." else: - items = ", ".join( [" ".join( [str(x[1]), x[0].name] ) for x in self.contents] ) + items = ", ".join(f"{x[1]} {x[0].name}" for x in self.contents) icon = "interface/icons/box_brown_"+str(random.randint(1, 4))+".webp" text = "You have received your ordered items:\n{size=-4}"+items+"{/size}" diff --git a/game/scripts/interface/tutorials.rpy b/game/scripts/interface/tutorials.rpy index 4d83dd07..9ef94c3d 100644 --- a/game/scripts/interface/tutorials.rpy +++ b/game/scripts/interface/tutorials.rpy @@ -55,8 +55,9 @@ screen tutorial(entry): text "Tutorial" size 10 yalign 0.5 text tutorial_dict[entry][0] size 16 xalign 0.5 yalign 0.5 - if renpy.loadable("interface/tutorials/{}.webp".format(entry)): - add "interface/tutorials/{}.webp".format(entry) xalign 0.5 + $ formated = f"interface/tutorials/{entry}.webp" + if renpy.loadable(formated): + add formated xalign 0.5 text tutorial_dict[entry][1] size 12 diff --git a/game/scripts/inventory/classes.rpy b/game/scripts/inventory/classes.rpy index 86247e87..7f25cd6d 100644 --- a/game/scripts/inventory/classes.rpy +++ b/game/scripts/inventory/classes.rpy @@ -26,7 +26,9 @@ init python: self.func = func self.label = label self.limit = limit - self.image = "interface/icons/{}.webp".format(self.id) if image == "default" else image + if image == "default": + image = f"interface/icons/{self.id}.webp" + self.image = image self.currency = currency self.caption = caption @@ -42,10 +44,10 @@ init python: def use(self): if not self.usable: - raise Exception("Item {!r} is not usable as it does not have any function or a label.".format(self.name)) + raise Exception(f"Item {self.name!r} is not usable as it does not have any function or a label.") if self.owned == 0: - raise Exception("Item {!r} owned count is equal to zero.".format(self.name)) + raise Exception(f"Item {self.name!r} owned count is equal to zero.") if not self.type == "quest": # Quest items require manual triggers, it's more convenient. @@ -62,10 +64,10 @@ init python: def give(self, who): if not self.givable: - raise Exception("Item {!r} is not marked as givable.".format(self.name)) + raise Exception(f"Item {self.name!r} is not marked as givable.") if self.owned == 0: - raise Exception("Item {!r} owned count is equal to zero.".format(self.name)) + raise Exception(f"Item {self.name!r} owned count is equal to zero.") if not self.type == "quest": # Quest items require manual triggers, it's more convenient. @@ -103,8 +105,10 @@ init python: def __init__(self, id, type, name, placement, price=0, desc="", unlocked=True, image="default", room_image="default", room_image_hover=None, owned=0, replaces=False, use_action=None, replace_action=None, replace_anchor=None, replace_pos=None): super(Decoration, self).__init__(id, type, name, price, desc, unlocked, None, None, 1, image, False, "tokens", "Apply", owned) - self.room_image = Transform("images/rooms/main_room/decorations/{}.webp".format(self.id), zoom=self.room_scale) if room_image == "default" else Transform(room_image, zoom=self.room_scale) - self.room_image_hover = Transform(room_image_hover, zoom=self.room_scale) if room_image_hover else self.room_image + if room_image == "default": + room_image = f"images/rooms/main_room/decorations/{self.id}.webp" + self.room_image = Transform(room_image, zoom=self.room_scale) + self.room_image_hover = Transform(room_image_hover or room_image, zoom=self.room_scale) self.usable = True self.placement = placement self.in_use = False @@ -119,7 +123,7 @@ init python: def use(self): if self.owned == 0: - raise Exception("Decoration {!r} owned count is equal to zero.".format(self.name)) + raise Exception(f"Decoration {self.name!r} owned count is equal to zero.") achievements.unlock("decorator") @@ -152,10 +156,10 @@ init python: self.make_intro = False self.in_progress = {i: False for i in usable_on} - self.usable = bool( renpy.has_label("{}_use".format(self.label)) ) + self.usable = bool(renpy.has_label(f"{self.label}_use")) if self.recipe is None: - raise Exception("Potion {!r} recipe is empty!".format(self.name)) + raise Exception(f"Potion {self.name!r} recipe is empty!") def has_ingredients(self): return all(x.owned > 0 for x in self.recipe) @@ -163,7 +167,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 list(self.in_progress.keys()): - raise Exception("Potion {!r} is not marked as usable on {!r}.".format(self.name, who)) + raise Exception(f"Potion {self.name!r} is not marked as usable on {who!r}.") self.in_progress[who] = True @@ -176,7 +180,7 @@ init python: i.owned -= 1 self.owned += 1 - label = "{}_make".format(self.label) + label = f"{self.label}_make" if renpy.has_label(label) and not self.make_intro: self.make_intro = True @@ -191,17 +195,17 @@ init python: def give(self, who): """Use potion on """ - give_label = "{}_{}_give".format(who[:3], self.label) - check_label = "{}_potion_check".format(who[:3]) + give_label = f"{who[:3]}_{self.label}_give" + check_label = f"{who[:3]}_potion_check" if not renpy.has_label(give_label): - raise Exception("Potion {!r} give label doesn't exist.".format(self.name)) + raise Exception(f"Potion {self.name!r} give label doesn't exist.") if not renpy.has_label(check_label): - raise Exception("Potion {!r} check label doesn't exist for {!r}.".format(self.name, who)) + raise Exception(f"Potion {self.name!r} check label doesn't exist for {who!r}.") if self.owned == 0: - raise Exception("Potion {!r} owned count is equal to zero.".format(self.name)) + raise Exception(f"Potion {self.name!r} owned count is equal to zero.") if not self.check_progression(who): self.jump(check_label) @@ -212,13 +216,13 @@ init python: def use(self): """Use potion on Genie""" - label = "{}_use".format(self.label) + label = f"{self.label}_use" if not renpy.has_label(label): - raise Exception("Potion {!r} has no use label.".format(self.name)) + raise Exception(f"Potion {self.name!r} has no use label.") if self.owned == 0: - raise Exception("Potion {!r} owned count is equal to zero.".format(self.name)) + raise Exception(f"Potion {self.name!r} owned count is equal to zero.") self.owned -= 1 self.jump(label) @@ -227,12 +231,12 @@ init python: """Play the return event for """ if not self.in_progress[who]: - raise Exception("Potion {!r} is not marked as in progress.".format(self.name)) + raise Exception(f"Potion {self.name!r} is not marked as in progress.") - label = "{}_{}_return".format(who[:3], self.label) + label = f"{who[:3]}_{self.label}_return" if not renpy.has_label(label): - raise Exception("Potion {!r} has no return label.".format(self.name)) + raise Exception(f"Potion {self.name!r} has no return label.") self.in_progress[who] = False self.jump(label) diff --git a/game/scripts/inventory/game.rpy b/game/scripts/inventory/game.rpy index e4ff5df2..6f7fa0cf 100644 --- a/game/scripts/inventory/game.rpy +++ b/game/scripts/inventory/game.rpy @@ -1,13 +1,13 @@ init -100 python: def show_gold(st, at, old, new): if st > 1.0: - return Text("G {}".format(new)), None + return Text(f"G {new}"), None else: if new > old: - value = int( (new-old)*(1.0-st) ) + 1 + value = int((new-old)*(1.0-st)) + 1 d = Text("G {}\n+{}".format(old + int((new-old)*st), value)) else: - value = int( (old-new)*(1.0-st) ) + 1 + value = int((old-new)*(1.0-st)) + 1 d = Text("G {}\n-{}".format(old - int((old-new)*st), value)) return d, 0.01 @@ -62,7 +62,7 @@ init -100 python: value = renpy.random.choices(self.weather_types, weights=self.weather_weights)[0] if not value in self.weather_types: - raise ValueError("Unsupported weather type: {!r}".format(value)) + raise ValueError(f"Unsupported weather type: {value!r}") self._weather = value diff --git a/game/scripts/minigames/cardgame/_card_game_.rpy b/game/scripts/minigames/cardgame/_card_game_.rpy index 430dabb3..5496ab84 100644 --- a/game/scripts/minigames/cardgame/_card_game_.rpy +++ b/game/scripts/minigames/cardgame/_card_game_.rpy @@ -223,7 +223,7 @@ init python: geniecard_level = tier # Change card image for each respective card. for card in cards_dynamic: - card.imagepath = card.imagepath.split("_v")[0] + "_v{}.webp".format(geniecard_level) + card.imagepath = card.imagepath.partition("_v")[0] + f"_v{geniecard_level}.webp" renpy.show_screen("advance_deck") renpy.pause() diff --git a/game/scripts/minigames/mirror/classes.rpy b/game/scripts/minigames/mirror/classes.rpy index d485f897..011c3021 100644 --- a/game/scripts/minigames/mirror/classes.rpy +++ b/game/scripts/minigames/mirror/classes.rpy @@ -34,7 +34,9 @@ init 5 python: self.unlocked = unlocked self.label = label self.label_rewards = label_rewards - self.image = "interface/icons/{}.webp".format(self.id) if image == "default" else image + if image == "default": + image = f"interface/icons/{self.id}.webp" + self.image = image self.req = self.validate_req(req) self.authors = authors self.tags = tags @@ -58,12 +60,12 @@ init 5 python: return None if not isinstance(req, str): - raise TypeError("MirrorEvent {!r} requirement has to be a string, got {!r}.".format(self.id, type(req))) + raise TypeError(f"MirrorEvent {self.id!r} requirement has to be a string, got {type(req)!r}.") output = eval(req) if not isinstance(output, bool): - raise TypeError("MirrorEvent {!r} requirement must evaluate to a boolean type, got {!r}.".format(self.id, type(output))) + raise TypeError(f"MirrorEvent {self.id!r} requirement must evaluate to a boolean type, got {type(output)!r}.") return req def play(self): diff --git a/game/scripts/minigames/mirror/menu.rpy b/game/scripts/minigames/mirror/menu.rpy index 38be1a86..42f90b5c 100644 --- a/game/scripts/minigames/mirror/menu.rpy +++ b/game/scripts/minigames/mirror/menu.rpy @@ -168,7 +168,7 @@ screen mirror_menuitem(xx, yy): add "interface/topbar/icon_check.webp" align (1.0, 1.0) offset (-5, -5) zoom 0.7 vbox: text ev.name - text "By {}".format(authors) size 10 + text f"By {authors}" size 10 add gui.format("interface/achievements/{}/spacer_left.webp") diff --git a/game/scripts/minigames/puzzle.rpy b/game/scripts/minigames/puzzle.rpy index fa091823..bb622af4 100644 --- a/game/scripts/minigames/puzzle.rpy +++ b/game/scripts/minigames/puzzle.rpy @@ -53,7 +53,7 @@ screen puzzle_minigame(): grid 4 4: for i, tile in enumerate(tiles): - $ img = "interface/puzzle/{}.webp".format(tile) + $ img = f"interface/puzzle/{tile}.webp" $ empty = tiles.index(15) $ is_valid = (i in (empty-1, empty+1, empty-4, empty+4) and not ( (empty % 4 == 3) and (i % 4 == 0) ) diff --git a/game/scripts/mods.rpy b/game/scripts/mods.rpy index 78d9af71..cb2e3964 100644 --- a/game/scripts/mods.rpy +++ b/game/scripts/mods.rpy @@ -20,7 +20,7 @@ init -999: path = os.path.split(manifest)[0] 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) + logo = f"{path}/logo.webp" if not renpy.loadable(logo): logo = "#000" @@ -50,7 +50,7 @@ init -999: global mods_incompatible for i in persistent.mods_enabled.copy(): control, major, *minor = mods_list[i]["GameVer"].split(" ")[0].split(".") - ver = float("{}.{}{}".format(control, major, "".join(minor))) + ver = float(f"{control}.{major}{''.join(minor)}") if ver < mods_compatible: persistent.mods_enabled.remove(i) diff --git a/game/scripts/rooms/labels.rpy b/game/scripts/rooms/labels.rpy index 14fbb4db..1852f722 100644 --- a/game/scripts/rooms/labels.rpy +++ b/game/scripts/rooms/labels.rpy @@ -11,10 +11,10 @@ label room(room=None, hide_screens=True, stop_sound=True): stop weather fadeout 0.5 $ renpy.stop_predict_screen(states.room) - $ renpy.stop_predict("images/rooms/{}/*.webp".format(states.room)) + $ renpy.stop_predict(f"images/rooms/{states.room}/*.webp") $ states.room = room $ renpy.start_predict_screen(states.room) - $ renpy.start_predict("images/rooms/{}/*.webp".format(states.room)) + $ renpy.start_predict(f"images/rooms/{states.room}/*.webp") if room == "main_room": # Update sound effects diff --git a/game/scripts/rooms/quidditch_stands/init.rpy b/game/scripts/rooms/quidditch_stands/init.rpy index cdfadf52..e8c49a1b 100644 --- a/game/scripts/rooms/quidditch_stands/init.rpy +++ b/game/scripts/rooms/quidditch_stands/init.rpy @@ -68,13 +68,13 @@ label quidditch_stands(hidden=False, reset=False, **kwargs): screen quidditch_stands_back(weather, rain=False, crowd=(), crowd_bj=False, crowd_react=(None, None, None), tree_fire=False, puddles=False, **kwargs): zorder 0 - add "images/rooms/quidditch_stands/bg_{}.webp".format(weather) zoom 0.5 + add f"images/rooms/quidditch_stands/bg_{weather}.webp" zoom 0.5 if tree_fire: add "quid_stands_fire" pos (870, -15) for c in crowd: - add "images/rooms/quidditch_stands/crowd_{}.webp".format(c) zoom 0.5 + add f"images/rooms/quidditch_stands/crowd_{c}.webp" zoom 0.5 if crowd_bj: add "crowd_bj" zoom 0.5 @@ -91,13 +91,13 @@ screen quidditch_stands_back(weather, rain=False, crowd=(), crowd_bj=False, crow screen quidditch_stands_mid(weather, **kwargs): zorder 8 - add "images/rooms/quidditch_stands/podium_{}.webp".format(weather) zoom 0.5 + add f"images/rooms/quidditch_stands/podium_{weather}.webp" zoom 0.5 screen quidditch_stands_front(weather, spotlight=False, hole=False, rain=False, **kwargs): zorder 8 - add "images/rooms/quidditch_stands/fg_{}.webp".format(weather) zoom 0.5 + add f"images/rooms/quidditch_stands/fg_{weather}.webp" zoom 0.5 if hole: add "images/rooms/quidditch_stands/hole.webp" zoom 0.5 diff --git a/game/scripts/rooms/quidditch_stands2/init.rpy b/game/scripts/rooms/quidditch_stands2/init.rpy index f5497edd..da5a9fe7 100644 --- a/game/scripts/rooms/quidditch_stands2/init.rpy +++ b/game/scripts/rooms/quidditch_stands2/init.rpy @@ -20,10 +20,10 @@ label quidditch_stands2(hidden=False, reset=False, **kwargs): screen quidditch_stands_back2(weather, crowd=(), crowd_react=(None, None, None), **kwargs): zorder 0 - add "images/rooms/quidditch_stands2/bg_{}.webp".format(weather) zoom 0.5 + add f"images/rooms/quidditch_stands2/bg_{weather}.webp" zoom 0.5 for c in crowd: - add "images/rooms/quidditch_stands2/crowd_{}.webp".format(c) zoom 0.5 + add f"images/rooms/quidditch_stands2/crowd_{c}.webp" zoom 0.5 add crowd_react[0] pos (570, 140) add crowd_react[1] pos (720, 90) @@ -32,4 +32,4 @@ screen quidditch_stands_back2(weather, crowd=(), crowd_react=(None, None, None), screen quidditch_stands_front2(weather, **kwargs): zorder 8 - add "images/rooms/quidditch_stands2/fg_{}.webp".format(weather) zoom 0.5 + add f"images/rooms/quidditch_stands2/fg_{weather}.webp" zoom 0.5 diff --git a/game/scripts/shops/dress/menu.rpy b/game/scripts/shops/dress/menu.rpy index b82ff599..9ca396e7 100644 --- a/game/scripts/shops/dress/menu.rpy +++ b/game/scripts/shops/dress/menu.rpy @@ -105,7 +105,7 @@ label shop_dress_menu: hide screen shop_dress hide screen blktone - $ _tmp = "tomorrow" if transit_time == 1 else "in about {} days".format(str(transit_time)) + $ _tmp = "tomorrow" if transit_time == 1 else f"in about {transit_time} days" maf "You can expect a parcel [_tmp]." # Executes callbacks upon receival of the parcel. @@ -160,7 +160,7 @@ screen shop_dress_menu(): pos (6, 6) for category in category_items.keys(): if get_character_unlock(category): - $ 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") + $ icon = Fixed(icon_bg, Frame( Transform(f"interface/icons/head/{category}.webp", fit="contain"), xysize=(42, 42), offset=(3, 3)), "interface/achievements/glass_iconbox.webp") vbox: textbutton category: diff --git a/game/scripts/utility/common_functions.rpy b/game/scripts/utility/common_functions.rpy index 044f9772..2fe4f051 100644 --- a/game/scripts/utility/common_functions.rpy +++ b/game/scripts/utility/common_functions.rpy @@ -112,7 +112,7 @@ init python early: defaults_set.remove(arg) changed_set.remove(arg) elif config.developer: - raise Exception("The variable `{}` was not previously set with a default value.".format(arg)) + raise Exception(f"The variable {arg!r} was not previously set with a default value.") renpy.execute_default_statement(False) def disable_game_menu():