from tft.staticdata.parse import parse, resolve_spell
RAW = {
"sets": {
"17": {
"name": "Set17",
"champions": [
{
"apiName": "TFT17_Mage",
"name": "Mage",
"cost": 2,
"traits": ["Caster"],
"role": "Caster",
"stats": {"hp": 600, "armor": 25, "magicResist": 25, "damage": 40,
"attackSpeed": 0.7, "mana": 60, "initialMana": 10},
"squareIcon": "ASSETS/x.TFT_Set17.tex",
"ability": {
"name": "Blast",
"desc": "Deal @ModifiedDamage@ (%i:scaleAP%) magic damage.",
"variables": [{"name": "Damage", "value": [0, 200, 300, 450, 700, 0, 0]}],
},
},
],
"traits": [
{
"apiName": "TFT17_Caster",
"name": "Caster",
"icon": "ASSETS/t.tex",
"effects": [
{"minUnits": 2, "maxUnits": 3, "style": 1,
"variables": {"BonusAP": 20.0}},
],
},
],
},
},
"items": [
{
"apiName": "TFT_Item_TestSword",
"name": "Test Sword",
"composition": ["TFT_Item_A", "TFT_Item_B"],
"effects": {"AD": 0.35, "CritChance": 35.0},
"icon": "ASSETS/i.tex",
},
],
}
def test_parse_keeps_effects_and_variables():
parsed = parse(RAW, set_override=17)
assert parsed["items"]["TFT_Item_TestSword"]["effects"] == {"AD": 0.35, "CritChance": 35.0}
bp = parsed["traits"]["TFT17_Caster"]["breakpoints"][0]
assert bp["variables"] == {"BonusAP": 20.0}
def test_parse_resolves_spell_damage():
unit = parse(RAW, set_override=17)["units"]["TFT17_Mage"]
assert unit["spell_damage"] == [0, 200, 300, 450, 700, 0, 0]
assert unit["spell_damage_type"] == "magic"
assert unit["spell_scaling"] == "ap"
def test_resolve_spell_adaptive_and_fallback():
adaptive = {
"desc": "Deal @TotalDamage@ damage. %i:scaleAP% %i:scaleAD%",
"variables": [
{"name": "ADDamage", "value": [0, 100, 150, 225, 0, 0, 0]},
{"name": "APDamage", "value": [0, 50, 75, 110, 0, 0, 0]},
],
}
r = resolve_spell(adaptive)
assert r["spell_damage"][1] == 150 # 100 + 50
assert r["spell_scaling"] == "both"
utility = {"desc": "Grant a shield.", "variables": [
{"name": "Shield", "value": [0, 300, 400, 500, 0, 0, 0]}]}
assert resolve_spell(utility)["spell_damage"] is None