Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Make scast work with metamagic adept #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions Collections/Sorcerer Basics/scast.alias
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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_list = ["Sorcery Points", "Sorcery Points (Metamagic Adept)"]

# Arguments
args = &ARGS&
Expand Down Expand Up @@ -31,15 +31,40 @@ 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:
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 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) and character().get_cc(cc) >= 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 <level>` 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)
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." """

Expand Down