def test_hit_locations_hp(self): et = get_enemy_template() enemy = _Enemy(et).generate() enemy.hit_locations = [] enemy.stats['CON'] = 2 enemy.stats['SIZ'] = 2 enemy._add_hit_locations() self.assertEquals(enemy.hit_locations[0]['hp'], 1) #Leg self.assertEquals(enemy.hit_locations[3]['hp'], 3) #Chest enemy.hit_locations = [] enemy.stats['CON'] = 11 enemy.stats['SIZ'] = 11 enemy._add_hit_locations() self.assertEquals(enemy.hit_locations[0]['hp'], 5) #Leg self.assertEquals(enemy.hit_locations[2]['hp'], 6) #Abdomen self.assertEquals(enemy.hit_locations[3]['hp'], 7) #Chest self.assertEquals(enemy.hit_locations[5]['hp'], 4) #Arm self.assertEquals(enemy.hit_locations[6]['hp'], 5) #Head enemy.hit_locations = [] enemy.stats['CON'] = 22 enemy.stats['SIZ'] = 22 enemy._add_hit_locations() self.assertEquals(enemy.hit_locations[0]['hp'], 9) #Leg self.assertEquals(enemy.hit_locations[2]['hp'], 10) #Abdomen self.assertEquals(enemy.hit_locations[3]['hp'], 11) #Chest self.assertEquals(enemy.hit_locations[5]['hp'], 8) #Arm self.assertEquals(enemy.hit_locations[6]['hp'], 9) #Head
def test_hit_locations(self): et = get_enemy_template() enemy = _Enemy(et).generate() self.assertTrue(isinstance(enemy.hit_locations, list)) self.assertEquals(enemy.hit_locations[0]['name'], 'Right leg') self.assertEquals(enemy.hit_locations[0]['range'], '01-03')
def no_test_1_die_set_with_stat_values(self): et = get_enemy_template() enemy = _Enemy(et) enemy.stats.append({'name': 'STR', 'value': 10}) enemy.stats.append({'name': 'DEX', 'value': 20}) self.assertEquals(enemy._die_set_with_stat_values('STR+DEX'), '10+20') self.assertEquals(enemy._die_set_with_stat_values('STR+DEX+50'), '10+20+50')
def test_calculate_damage_modifier(self): class EM: name = 'name' get_cult_rank = 1 notes = '' is_spirit = False enemy_mock = EM() enemy = _Enemy(enemy_mock) enemy.stats = {} enemy.attributes = {} enemy._calculate_damage_modifier(2, 2) self.assertEquals(enemy.attributes['damage_modifier'], '-1d8') enemy._calculate_damage_modifier(2, 3) self.assertEquals(enemy.attributes['damage_modifier'], '-1d8') enemy._calculate_damage_modifier(12, 14) self.assertEquals(enemy.attributes['damage_modifier'], '+1d2') enemy._calculate_damage_modifier(20, 11) self.assertEquals(enemy.attributes['damage_modifier'], '+1d4') enemy._calculate_damage_modifier(20, 15) self.assertEquals(enemy.attributes['damage_modifier'], '+1d4') enemy._calculate_damage_modifier(40, 11) self.assertEquals(enemy.attributes['damage_modifier'], '+1d12') enemy._calculate_damage_modifier(40, 20) self.assertEquals(enemy.attributes['damage_modifier'], '+1d12') enemy._calculate_damage_modifier(40, 21) self.assertEquals(enemy.attributes['damage_modifier'], '+2d6') enemy._calculate_damage_modifier(65, 65) self.assertEquals(enemy.attributes['damage_modifier'], '+2d10+1d4')
def test_hit_locations(self): et = get_enemy_template() enemy = _Enemy(et).generate() self.assertTrue(isinstance(enemy.hit_locations, list)) self.assertEquals(enemy.hit_locations[0]['name'], 'Right leg') self.assertEquals(enemy.hit_locations[0]['range'], '01-03') HITPOINTS = {1: (1,3,2,1,1), 6: (2,4,3,1,2), 11: (3,5,4,2,3), 31: (7,9,8,6,7), 41: (9,11,10,8,9)}
def test_enemy_as_json(self): et = get_enemy_template() _add_magic(et) enemy = _Enemy(et).generate() ejson = as_json([enemy]) edict = json.loads(ejson) self.assertEqual(edict[0]['folk_spells'][0], 'Bladesharp') self.assertEqual(edict[0]['combat_styles'][0]['name'], 'Primary Combat Style') self.assertEqual(edict[0]['skills'][2].keys()[0], 'Endurance') self.assertEqual(edict[0]['skills'][2]['Endurance'], enemy.skills_dict['Endurance'])
def test_calculate_damage_modifier(self): class EM: name = 'name' enemy_mock = EM() enemy = _Enemy(enemy_mock) enemy.stats = {} enemy.attributes = {} enemy.stats['STR'] = 2 enemy.stats['SIZ'] = 2 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '-1D8') enemy.stats['STR'] = 3 enemy.stats['SIZ'] = 2 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '-1D8') enemy.stats['STR'] = 12 enemy.stats['SIZ'] = 14 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+1D2') enemy.stats['STR'] = 20 enemy.stats['SIZ'] = 11 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+1D4') enemy.stats['STR'] = 20 enemy.stats['SIZ'] = 15 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+1D4') enemy.stats['STR'] = 40 enemy.stats['SIZ'] = 11 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+1D12') enemy.stats['STR'] = 40 enemy.stats['SIZ'] = 20 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+1D12') enemy.stats['STR'] = 40 enemy.stats['SIZ'] = 21 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+2D6') enemy.stats['STR'] = 65 enemy.stats['SIZ'] = 65 enemy._calculate_damage_modifier() self.assertEquals(enemy.attributes['damage_modifier'], '+2D10+1D4')
def test_hit_locations(self): et = get_enemy_template() enemy = _Enemy(et).generate() self.assertTrue(isinstance(enemy.hit_locations, list)) self.assertEquals(enemy.hit_locations[0]['name'], 'Right leg') self.assertEquals(enemy.hit_locations[0]['range'], '01-03') HITPOINTS = { 1: (1, 3, 2, 1, 1), 6: (2, 4, 3, 1, 2), 11: (3, 5, 4, 2, 3), 31: (7, 9, 8, 6, 7), 41: (9, 11, 10, 8, 9) }
def test_enemy_get_stats(self): et = get_enemy_template() enemy = _Enemy(et).generate() self.assertEquals(enemy.get_stats[0]['name'], 'STR') self.assertEquals(enemy.get_stats[1]['name'], 'CON') self.assertTrue(isinstance(enemy.get_stats[0]['value'], int))