def make_battle_config( heal_at_missing=HEAL_AT_MISSING, potion_hp_hi=POTION_HP_HI, potion_hp_lo=POTION_HP_LO, potion_hp_critical=POTION_HP_CRITICAL, downtime_mana=DOWNTIME_MANA, mana_hi=MANA_HI, mana_lo=MANA_LO, critical_mana=CRITICAL_MANA, ): return BattleConfig( **{ "config_name": "test_battle_config", "hasted_speed": HASTED_SPEED, "heal_at_missing": heal_at_missing, "downtime_heal_at_missing": DOWNTIME_HEAL_AT_MISSING, "minor_heal": MINOR_HEAL, "medium_heal": MEDIUM_HEAL, "greater_heal": GREATER_HEAL, "potion_hp_hi": potion_hp_hi, "potion_hp_lo": potion_hp_lo, "potion_hp_critical": potion_hp_critical, "critical_mana": critical_mana, "mana_hi": mana_hi, "mana_lo": mana_lo, "downtime_mana": downtime_mana, "should_equip_amulet": True, "should_equip_ring": True, "should_eat_food": True, "emergency_hp_threshold": TOTAL_HP * 0.5, })
def test_load_resolve(self): # given input = { "char_name": "test_char_name", "vocation": "mage", "total_hp": 100, "total_mana": 101, "base_speed": 102, "hasted_speed": 103, "strong_hasted_speed": 104, "battle_configs": [{ "config_name": "test_base", "hasted_speed": "{strong_hasted_speed}", "heal_at_missing": "{total_hp-10}", "downtime_heal_at_missing": "{total_hp-10}", "mana_hi": "{total_mana-10}", "mana_lo": "{total_mana-10}", "critical_mana": 110, "downtime_mana": "{total_mana-10}", "minor_heal": "{total_hp-10}", "medium_heal": "{total_hp-20}", "greater_heal": "{total_hp-30}", "emergency_hp_threshold": "{total_hp-40}", }] } expected = CharConfig(char_name="test_char_name", vocation="mage", total_hp=100, total_mana=101, base_speed=102, hasted_speed=103, strong_hasted_speed=104, battle_configs=[ BattleConfig(config_name="test_base", hasted_speed=104, heal_at_missing=90, downtime_heal_at_missing=90, mana_hi=91, mana_lo=91, critical_mana=110, downtime_mana=91, minor_heal=90, medium_heal=80, greater_heal=70, emergency_hp_threshold=60) ]) target = CharConfigSchema() # when actual = target.load(input) # then self.assertEqual(actual, expected)
def make_char_config(self, total_hp=TOTAL_HP, total_mana=TOTAL_MANA, base_speed=BASE_SPEED, hasted_speed=HASTED_SPEED, heal_at_missing=HEAL_AT_MISSING, downtime_heal_at_missing=DOWNTIME_HEAL_AT_MISING, minor_heal=MINOR_HEAL, medium_heal=MEDIUM_HEAL, greater_heal=GREATER_HEAL, critical_mana=CRITICAL_MANA, mana_hi=MANA_HI, mana_lo=MANA_LO, downtime_mana=DOWNTIME_MANA, should_equip_amulet=True, should_equip_ring=True, should_eat_food=True, emergency_hp_threshold=TOTAL_HP * 0.5): return CharConfig(**{ 'char_name': 'test_char', 'strong_hasted_speed': 500, 'total_hp': total_hp, 'total_mana': total_mana, 'base_speed': base_speed, 'hasted_speed': hasted_speed, 'battle_configs': [ BattleConfig(**{ 'config_name': 'test_battle_config', 'hasted_speed': hasted_speed, 'heal_at_missing': heal_at_missing, 'downtime_heal_at_missing': downtime_heal_at_missing, 'minor_heal': minor_heal, 'medium_heal': medium_heal, 'greater_heal': greater_heal, 'critical_mana': critical_mana, 'mana_hi': mana_hi, 'mana_lo': mana_lo, 'downtime_mana': downtime_mana, 'should_equip_amulet': should_equip_amulet, 'should_equip_ring': should_equip_ring, 'should_eat_food': should_eat_food, 'emergency_hp_threshold': emergency_hp_threshold, 'item_crosshair_macros': [ ItemCrosshairMacroConfig(**{'hotkey': 'x'}) ], 'directional_macros': [ DirectionalMacroConfig(**{ 'spell_key_rotation': ['a'], 'rotation_threshold_secs': 3, 'direction_pairs': [ ('a', 'b') ] }) ] })], })
def test_load_minimal(self): # given root = { "config_name": "test", "hasted_speed": 110, "heal_at_missing": 109, "downtime_heal_at_missing": 108, "mana_hi": 107, "mana_lo": 106, "critical_mana": 105, "downtime_mana": 104, "minor_heal": 103, "medium_heal": 102, "greater_heal": 101, "emergency_hp_threshold": 100, } expected = BattleConfig(**root) target = BattleConfigSchema() # when actual = target.load(root) # then self.assertEqual(actual, expected)
def test_load_maximal(self): # given input = { "config_name": "default", "hidden": True, "hasted_speed": 100, "heal_at_missing": 101, "downtime_heal_at_missing": 102, "mana_hi": 103, "mana_lo": 104, "critical_mana": 104, "downtime_mana": 105, "minor_heal": 106, "medium_heal": 107, "greater_heal": 108, "should_equip_amulet": False, "should_equip_ring": False, "should_eat_food": True, "magic_shield_type": "emergency", "magic_shield_threshold": 109, "emergency_hp_threshold": 110, "item_crosshair_macros": [ { "hotkey": "delete" }, { "hotkey": "x" }, ], "directional_macros": [{ "spell_key_rotation": ["8"], "rotation_threshold_secs": 4, "direction_pairs": [ ["ctrl+f", None], ["ctrl+e", None], ["ctrl+s", None], ["ctrl+d", None], ] }] } expected = BattleConfig(config_name="default", hidden=True, hasted_speed=100, heal_at_missing=101, downtime_heal_at_missing=102, mana_hi=103, mana_lo=104, critical_mana=104, downtime_mana=105, minor_heal=106, medium_heal=107, greater_heal=108, should_equip_amulet=False, should_equip_ring=False, should_eat_food=True, magic_shield_type="emergency", magic_shield_threshold=109, emergency_hp_threshold=110, item_crosshair_macros=[ ItemCrosshairMacroConfig(hotkey="delete"), ItemCrosshairMacroConfig(hotkey="x"), ], directional_macros=[ DirectionalMacroConfig( spell_key_rotation=["8"], rotation_threshold_secs=4, direction_pairs=[ ("ctrl+f", None), ("ctrl+e", None), ("ctrl+s", None), ("ctrl+d", None), ]) ]) target = BattleConfigSchema() # when actual = target.load(input) # then self.assertEqual(actual, expected)