from Code.FireEmblemCombatV2 import *
import os
import sys
main_file = os.path.abspath(sys.modules["__main__"].__file__)
imported_file = os.path.abspath(sys.modules["Code.FireEmblemCombatV2"].__file__)
if main_file == imported_file:
module = sys.modules["__main__"]
else:
module = sys.modules["Code.FireEmblemCombatV2"]
# iterates over items defined in given module and copies them into the local
# namespace if they are functions or classes
for item_name in dir(module):
# if item_name is not a special global variable like __name__
if not item_name.startswith("__"):
# moves item directly into local namespace by copying original
exec(f"{item_name} = getattr(module, item_name)")
# TODO: Change to programmatically generate slid functions and arguments to reduce repetition
[docs]def slid1(user: Character):
if user.is_initiating:
return 1
return 0
[docs]def slid2(user: Character):
if user.is_initiating:
return 0
return 1
[docs]def slid3(skill: Skill, user: Character):
slid = find(skill, 3)
if hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid4(skill: Skill, turn: int):
slid = find(skill, 4)
if slid.param1 == 0:
return 1 if turn == (1 - slid.param2) else 0
elif slid.param1 > 0:
return 1 if (turn - 1) % slid.param1 == slid.param2 else 0
raise ValueError("Invalid value {0} supplied by SLID param1. Must be positive integer.".format(slid.param1))
[docs]def slid5(skill: Skill, foe: Character):
slid = find(skill, 5)
if hp_between(slid.param1, slid.param2, foe):
return 1
return 0
[docs]def slid7(skill: Skill, user: Character, foe: Character):
slid = find(skill, 7)
if foe.stat_difference(slid.param1, user) >= slid.param2:
return 1
return 0
[docs]def slid9(skill: Skill, foe: Character):
if skill.skill_targets(foe):
return 1
return 0
[docs]def slid11(skill: Skill, user: Character):
slid = find(skill, 11)
# minus one accounts for exclusion of foe from calculations
if count_around(user, foes, slid) - 1 >= count_around(user, allies, slid) + slid.param2:
return 1
return 0
[docs]def slid13(skill: Skill, user: Character):
slid = find(skill, 13)
# minus one accounts for exclusion of foe from calculations
# count_around takes output of within_range, which includes foe, but not user
# maybe try using lambda nearby: foes([i for i in nearby if i is not foe])
if count_around(user, allies, slid) >= count_around(user, foes, slid) - 1 + slid.param2:
return 1
return 0
[docs]def slid14(skill: Skill, user: Character):
slid = find(skill, 14)
if count_around(user, allies, slid) >= slid.param2:
return 1
return 0
[docs]def slid15(skill: Skill, foe: Character):
wep_weaknesses = filter_true_indexes(convert_to_bitmask_list(skill.wep_weakness))
for foe_skill in foe.equipped_skills:
assert isinstance(foe_skill, Skill)
for index in wep_weaknesses:
if in_bitmask(index, foe_skill.wep_effective):
break
else:
continue
break
else:
return 0
return 1
[docs]def slid19(skill: Skill, user: Character):
slid = find(skill, 14)
if count_around(user, allies, slid) <= slid.param2:
return 1
return 0
# TODO: Write status-checking code
[docs]def slid21(skill: Skill, user: Character):
"""
param1 = 1, param2 = 0: If Bonus is active on unit
param1 = 1, param2 = 1: If March is active on unit
param1 = 1, param2 = 2: If【Bonus】is active on unit
:param user:
:return:
"""
slid = find(skill, 21)
if slid.param1 == 1:
# TODO: Add functionality to keys 1 and 2
out = {0: bonus_narrow(user), 1: user.status_effects["March"], 2: bonus_broad(user)}.get(slid.param2)
return 1 if out else 0
return 0
[docs]def slid22(skill: Skill, user: Character, foe: Character):
slid = find(skill, 22)
if user.stat_difference(slid.param1, foe) >= slid.param2:
return 1
return 0
[docs]def slid23(skill: Skill, user: Character, foe: Character):
slid = find(skill, 22)
if user.stat_difference(slid.param1, foe) <= slid.param2:
return 1
return 0
[docs]def slid24(user: Character):
if user.special_cd == 0:
return 1
return 0
[docs]def slid25(foe: Character):
return penalty_broad(foe)
[docs]def slid27(skill: Skill, user: Character):
slid = find(skill, 27)
if penalty_broad(user) or hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid28(user: Character, foe: Character):
if user.calc_weapon_triangle(foe) > 0:
return 1
return 0
[docs]def slid29(skill: Skill, user: Character):
slid = find(skill, 29)
# CHECK: now I think this ought to work, but I've learned not to trust myself
if count_around(user, lambda items, unit: not_dragon(not_beast(allies(items, unit))), slid) <= slid.param2:
return 1
return 0
[docs]def slid32(foe: Character):
return not bonus_narrow(foe)
[docs]def slid33(skill: Skill, user: Character, foe: Character):
slid = find(skill, 33)
if (hp_between(slid.param1, slid.param2, user) and hp_between(slid.param1, slid.param2, foe)) \
or (not hp_between(slid.param1, slid.param2, user) and not hp_between(slid.param1, slid.param2, foe)):
return 1
return 0
[docs]def slid34(skill: Skill, user: Character, foe: Character):
slid = find(skill, 34)
if buff_total(user) + debuff_total(foe) >= slid.param1:
return 1
return 0
[docs]def slid36(skill: Skill, user: Character):
slid = find(skill, 36)
if slid.param1 == 1:
if bonus_narrow(user):
return 1
if slid.param2 == 1:
if user.status_effects["March"] == True:
return 1
return 0
[docs]def slid37(skill: Skill, foe: Character):
slid = find(skill, 37)
if penalty_broad(foe) or hp_between(slid.param1, slid.param2, foe):
return 1
return 0
[docs]def slid38(skill: Skill, foe: Character, turn: int):
slid = find(skill, 38)
if turn % 2 == 1 or hp_between(slid.param1, slid.param2, foe):
return 1
return 0
[docs]def slid39(skill: Skill, user: Character, foe: Character):
slid = find(skill, 39)
if user.stats["hp"] >= foe.hp + slid.param2:
return 1
return 0
[docs]def slid40(skill: Skill, user: Character, foe: Character):
slid = find(skill, 40)
if user.status_effects["March"] or user.stat_difference(slid.param1, foe) >= slid.param2:
return 1
return 0
[docs]def slid41(foe: Character):
if foe.is_initiating or not bonus_narrow(foe):
return 1
return 0
[docs]def slid42(skill: Skill, user: Character):
slid = find(skill, 42)
if hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid43(skill: Skill, user: Character):
slid = find(skill, 43)
if penalty_broad(user) or hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid44(skill: Skill, user: Character, foe: Character):
slid = find(skill, 44)
if user.stat_difference(slid.param1, foe) >= slid.param2:
return 1
return 0
[docs]def slid45(skill: Skill, user: Character, foe: Character):
slid = find(skill, 45)
if user.stat_difference(hundreds(slid.param1), foe) >= tens_ones(slid.param1) or \
hp_between(slid.param2, 100, foe):
return 1
return 0
[docs]def slid46(skill: Skill, foe: Character):
slid = find(skill, 46)
if foe.is_initiating or hp_between(slid.param1, slid.param2, foe):
return 1
return 0
[docs]def slid47(skill: Skill, user: Character):
slid = find(skill, 47)
if count_around(user, lambda items: [i for i in allies(items, user) if i.has_acted], slid) >= slid.param2:
return 1
return 0
[docs]def slid48(skill: Skill, user: Character):
slid = find(skill, 48)
if bonus_narrow(user) or hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid49(skill: Skill, user: Character):
slid = find(skill, 49)
if count_around(user, lambda items: [i for i in allies(items, user) if buff_total(i)
>= tens_ones(slid.param1)],
slid) >= hundreds(slid.param2):
return 1
return 0
[docs]def slid50(skill: Skill, user: Character):
slid = find(skill, 50)
# wowza, that's something alright
return True in [i for i in allies(within_range_abstracted(
user, None, "within_range", distance_override=slid.param1), user) if hp_between(0, slid.param2, i)]
[docs]def slid51(skill: Skill, user: Character):
slid = find(skill, 51)
if bonus_narrow(user) or count_around(user, allies, slid) >= slid.param2:
return 1
return 0
[docs]def slid52(skill: Skill, user: Character, foe: Character):
slid = find(skill, 52)
if foe.is_initiating or hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid54(skill: Skill, user: Character, foe: Character):
slid = find(skill, 54)
if skill.skill_targets(foe) or hp_between(slid.param1, slid.param2, user):
return 1
return 0
[docs]def slid56(skill: Skill):
# man, fuck this, I'll put it in later
# can't believe I have to add an entire new variable just for one skill
return 0
[docs]def slid57(skill: Skill, user: Character, foe: Character):
slid = find(skill, 57)
if hp_between(slid.param1, slid.param2, user) or hp_between(slid.param1, slid.param2, foe):
return 1
return 0