From 78f39432436b60f6c46748578f92e2f9449937d8 Mon Sep 17 00:00:00 2001 From: Eric Triebe Date: Tue, 18 Jul 2023 14:03:26 -0700 Subject: [PATCH 1/2] Make scast work with metamagic adept --- Collections/Sorcerer Basics/scast.alias | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Collections/Sorcerer Basics/scast.alias b/Collections/Sorcerer Basics/scast.alias index 1b2f47d..3491a0c 100644 --- a/Collections/Sorcerer Basics/scast.alias +++ b/Collections/Sorcerer Basics/scast.alias @@ -3,6 +3,8 @@ spell_gvar = load_json(get_gvar('5e2c8e11-6ade-4ce2-9ece-562fc9db70c7')) meta_gvar = load_json(get_gvar('9af34023-6eba-4789-82b1-e68b191220ac')) cc = "Sorcery Points" +cc_alt = "Sorcery Points (Metamagic Adept)" +cc_to_use = cc # Arguments args = &ARGS& @@ -31,19 +33,22 @@ for meta in meta_gvar: # Min 1 for cantrips meta_cost += max(int(get(meta.points, meta.points)),1) -if not character().cc_exists(cc) and meta_cost: +if not character().cc_exists(cc) and character().cc_exists(cc_alt): + cc_to_use = cc_alt + +if not character().cc_exists(cc_to_use) and meta_cost: return f"""embed -title "I'm sorry {ctx.author.display_name}, I can't let you do that." -desc "You are missing a Sorcery Points custom counter. You can either create one yourself (`!help cc create`), or use the [`{ctx.prefix}level` alias](https://avrae.io/dashboard/workshop/5f7385fe647bb0a416316d1d)." """ elif meta_cost: - if character().cc_exists(cc) and character().get_cc(cc) >= meta_cost: + if character().cc_exists(cc_to_use) and character().get_cc(cc_to_use) >= meta_cost: # If the character cannot cast the spell at the level specified, safely error before expending sorcery points if character().spellbook.get_slots(spell_level) == 0 and not argparse(args).last('i'): return f"""embed -title "Cannot cast spell!" -desc "You don't have enough level {spell_level} slots left! Use `-l ` to cast at a different level, `!g lr` to take a long rest, or `-i` to ignore spell slots!" """ - character().mod_cc(cc, -meta_cost) + character().mod_cc(cc_to_use, -meta_cost) else: return f"""embed -title "I'm sorry {ctx.author.display_name}, I can't let you do that." -desc "You don't have enough Sorcery Points for that." """ -cc_out = f""" -f "{cc} {f'(-{meta_cost})' if meta_cost and character().get_cc(cc) >= meta_cost else ''}|{character().cc_str(cc) if character().cc_exists(cc) else '*None*'}" """ +cc_out = f""" -f "{cc_to_use} {f'(-{meta_cost})' if meta_cost and character().get_cc(cc_to_use) >= meta_cost else ''}|{character().cc_str(cc_to_use) if character().cc_exists(cc_to_use) else '*None*'}" """ # If no arguments, return the help if not args: From 3238d237835435f48886facc82375bf9c2e50919 Mon Sep 17 00:00:00 2001 From: Eric Triebe Date: Tue, 18 Jul 2023 15:06:53 -0700 Subject: [PATCH 2/2] Update to work with an array of metamagics --- Collections/Sorcerer Basics/scast.alias | 34 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Collections/Sorcerer Basics/scast.alias b/Collections/Sorcerer Basics/scast.alias index 3491a0c..a551dda 100644 --- a/Collections/Sorcerer Basics/scast.alias +++ b/Collections/Sorcerer Basics/scast.alias @@ -2,9 +2,7 @@ # Data spell_gvar = load_json(get_gvar('5e2c8e11-6ade-4ce2-9ece-562fc9db70c7')) meta_gvar = load_json(get_gvar('9af34023-6eba-4789-82b1-e68b191220ac')) -cc = "Sorcery Points" -cc_alt = "Sorcery Points (Metamagic Adept)" -cc_to_use = cc +cc_list = ["Sorcery Points", "Sorcery Points (Metamagic Adept)"] # Arguments args = &ARGS& @@ -33,22 +31,44 @@ for meta in meta_gvar: # Min 1 for cantrips meta_cost += max(int(get(meta.points, meta.points)),1) +total_cc_value = 0 +cc_counters_exist = False + +for cc_name in cc_list: + if character().cc_exists(cc_name): + cc_counters_exist = True + total_cc_value += character().get_cc(cc_name) + + +if character().cc_exists(cc): + total_cc_value += character().get_cc(cc_to_use) + if not character().cc_exists(cc) and character().cc_exists(cc_alt): cc_to_use = cc_alt -if not character().cc_exists(cc_to_use) and meta_cost: +if not cc_counters_exist and meta_cost: return f"""embed -title "I'm sorry {ctx.author.display_name}, I can't let you do that." -desc "You are missing a Sorcery Points custom counter. You can either create one yourself (`!help cc create`), or use the [`{ctx.prefix}level` alias](https://avrae.io/dashboard/workshop/5f7385fe647bb0a416316d1d)." """ elif meta_cost: - if character().cc_exists(cc_to_use) and character().get_cc(cc_to_use) >= meta_cost: + if cc_counters_exist and total_cc_value >= meta_cost: # If the character cannot cast the spell at the level specified, safely error before expending sorcery points if character().spellbook.get_slots(spell_level) == 0 and not argparse(args).last('i'): return f"""embed -title "Cannot cast spell!" -desc "You don't have enough level {spell_level} slots left! Use `-l ` to cast at a different level, `!g lr` to take a long rest, or `-i` to ignore spell slots!" """ - character().mod_cc(cc_to_use, -meta_cost) + current_meta_amount = meta_cost + for cc_name in cc_list: + if current_meta_amount == 0: + break + if character().cc_exists(cc_name): + current_cc_value = character().get_cc(cc_name) + # only deprecate the counter amount if it is smaller than the cost + deprecation_amount = min(current_meta_amount, current_cc_value) + character().mod_cc(cc_name, -deprecation_amount) + current_meta_amount -= deprecation_amount + else: return f"""embed -title "I'm sorry {ctx.author.display_name}, I can't let you do that." -desc "You don't have enough Sorcery Points for that." """ -cc_out = f""" -f "{cc_to_use} {f'(-{meta_cost})' if meta_cost and character().get_cc(cc_to_use) >= meta_cost else ''}|{character().cc_str(cc_to_use) if character().cc_exists(cc_to_use) else '*None*'}" """ +cc_out = f""" -f "{cc} {f'(-{meta_cost})' if meta_cost and character().get_cc(cc) >= meta_cost else ''}|{character().cc_str(cc) if character().cc_exists(cc) else '*None*'}" """ # If no arguments, return the help if not args: