From 67c9fc1696a2b1b8c38dd74ac483659d61f4625d Mon Sep 17 00:00:00 2001 From: Nate Bowman Date: Sat, 14 Nov 2026 21:38:42 -0500 Subject: [PATCH] Remove Blacksmith upgrades from siege weapons Siege weapons do not benefit from Blacksmith upgrades. Also, this commit splits the attack and defense ranges from Blacksmith upgrades into two attributes, which makes it easier to see what is happening to get the final range of attack-vs-defense upgrade values. --- examples/example-fighting.py | 6 +++- fighting/constants.py | 68 ++++++++++++++++++++++++++++++------ fighting/fighting.py | 44 ++++++++++++++++------- 3 files changed, 93 insertions(+), 25 deletions(-) diff --git a/examples/example-fighting.py b/examples/example-fighting.py index 0bbd58b..eec46ea 100644 --- a/examples/example-fighting.py +++ b/examples/example-fighting.py @@ -20,4 +20,8 @@ data = read_data_to_dict(data_json_keys) fight = Fighting(data, nums) results = fight.generate_all_fight_results() -print(results) + +for k, v in results.items(): + print(k) + print(v) + print('\n\n') diff --git a/fighting/constants.py b/fighting/constants.py index d4fe8ee..1010444 100644 --- a/fighting/constants.py +++ b/fighting/constants.py @@ -3,19 +3,37 @@ from fighting.types import ArmorClasses ranges = {ArmorClasses.MELEE: { - 'standard': range(-3, 5), - 'parthian tactics (armor)': range(-3, 5), - 'villager': range(0, 5), - 'villager (loom)': range(-1, 4), + 'attack': { + 'standard': range(0, 5), + 'villager': [0], + 'siege (chemistry)': range(0, 2), + 'siege': [0], + }, + 'armor': { + 'standard': range(-3, 1), + 'parthian tactics': range(-4, 1), + 'villager': [0], + 'villager (loom)': [-1], + 'siege': [0], + }, }, ArmorClasses.PIERCE: { - 'standard': range(-4, 5), - 'parthian tactics (armor)': range(-6, 5), - 'parthian tactics (attack)': range(-4, 7), - 'gambesons': range(-5, 5), - 'villager': range(0, 5), - 'villager (loom)': range(-2, 4), - } + 'attack': { + 'standard': range(0, 5), + 'parthian tactics': range(0, 7), + 'villager': [0], + 'siege (chemistry)': range(0, 2), + 'siege': [0], + }, + 'armor': { + 'standard': range(-4, 1), + 'parthian tactics': range(-6, 1), + 'gambesons': range(-5, 1), + 'villager': [0], + 'villager (loom)': [-2], + 'siege': [0], + }, + }, } @@ -139,3 +157,31 @@ bonuses = { }, } bonuses['armor']['Parthian Tactics'] = bonuses['attack']['Parthian Tactics']['attackers'] + +siege = [ + 'Battering Ram', + 'Capped Ram', + 'Siege Ram', + 'Mangonel', + 'Onager', + 'Siege Onager', + 'Rocket Cart', + 'Heavy Rocket Cart', + 'Scorpion', + 'Heavy Scorpion', + #'Siege Tower', + 'Bombard Cannon', + 'Trebuchet (packed)', + 'Trebuchet (unpacked)', + 'Traction Trebuchet', + ] +siege_no_chemistry = [ + 'Battering Ram', + 'Capped Ram', + 'Siege Ram', + 'Bombard Cannon', + 'Trebuchet (packed)', + 'Trebuchet (unpacked)', + 'Traction Trebuchet', + ] +siege_with_chemistry = list(set(siege) - set(siege_no_chemistry)) diff --git a/fighting/fighting.py b/fighting/fighting.py index e013dc8..6b91995 100644 --- a/fighting/fighting.py +++ b/fighting/fighting.py @@ -145,22 +145,40 @@ class Fighting(): number in this way, we do not need to consider all possible combinations of attack and armor blacksmith research. ''' - possible = constants.ranges[attack_type] + possible_attack = constants.ranges[attack_type]['attack'] - if defender == 'Villager': - if 'Loom' in hp_bonuses: - return possible['villager (loom)'] - else: - return possible['villager'] + if attacker == 'Villager': + attack_range = possible_attack['villager'] + elif 'Parthian Tactics' in extra_attack_bonuses: + attack_range = possible['parthian tactics'] + elif attacker in constants.siege_no_chemistry: + attack_range = possible_attack['siege'] + elif attacker in constants.siege_with_chemistry: + attack_range = possible_attack['siege (chemistry)'] + else: + attack_range = possible_attack['standard'] + + possible_armor = constants.ranges[attack_type]['armor'] + + if 'Loom' in hp_bonuses: + armor_range = possible_armor['villager (loom)'] + elif defender == 'Villager': + armor_range = possible_armor['villager'] elif 'Parthian Tactics' in extra_armor_bonuses: - return possible['parthian tactics (armor)'] - elif attack_type == ArmorClasses.PIERCE: - if 'Parthian Tactics' in extra_attack_bonuses: - return possible['parthian tactics (attack)'] - elif 'Gambesons' in extra_armor_bonuses: - return possible['gambesons'] + armor_range = possible_armor['parthian tactics'] + elif 'Gambesons' in extra_armor_bonuses: + armor_range = possible_armor['gambesons'] + elif defender in constants.siege: + armor_range = possible_armor['siege'] + else: + armor_range = possible_armor['standard'] - return possible['standard'] + all_range = set() + for attack in attack_range: + for armor in armor_range: + all_range.add(attack + armor) + + return sorted(list(all_range)) def get_attack_type(self, attacker_id):