-
Notifications
You must be signed in to change notification settings - Fork 280
/
melee_balance_test.cpp
80 lines (68 loc) · 2.34 KB
/
melee_balance_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "catch/catch.hpp"
#include <cstddef>
#include <sstream>
#include <string>
#include "creature.h"
#include "game_constants.h"
#include "item.h"
#include "item_factory.h"
#include "monattack.h"
#include "monster.h"
#include "npc.h"
#include "player.h"
#include "point.h"
#include "string_formatter.h"
#include "type_id.h"
static constexpr tripoint dude_pos( HALF_MAPSIZE_X, HALF_MAPSIZE_Y, 0 );
static std::vector<const itype *> find_weapons()
{
std::vector<const itype *> result;
for( const itype *it : item_controller->all() ) {
if( it->melee[DT_BASH] + it->melee[DT_CUT] + it->melee[DT_STAB] >= 10 ) {
result.push_back( it );
}
}
return result;
}
static void print_stats( const player &p, const std::vector<const itype *> &weapons,
const monster &m )
{
std::vector<std::pair<std::string, double>> weapon_stats;
for( const itype *w : weapons ) {
item &wp = *item::spawn_temporary( w );
weapon_stats.emplace_back( wp.tname( 1, false ), wp.effective_dps( p, m ) );
}
std::sort( weapon_stats.begin(), weapon_stats.end(), []( const auto & l, const auto & r ) {
return l.second < r.second;
} );
for( const auto &pr : weapon_stats ) {
cata_printf( "%-30s : %.1f\n", pr.first.c_str(), pr.second );
}
}
TEST_CASE( "Weak character using melee weapons against a brute", "[.][melee][slow]" )
{
monster zed( mtype_id( "mon_zombie_brute" ) );
auto weapons = find_weapons();
SECTION( "8/8/8/8, no skills" ) {
standard_npc dude( "TestCharacter", dude_pos, {}, 0, 8, 8, 8, 8 );
print_stats( dude, weapons, zed );
}
}
TEST_CASE( "Average character using melee weapons against a hulk", "[.][melee][slow]" )
{
monster zed( mtype_id( "mon_zombie_hulk" ) );
auto weapons = find_weapons();
SECTION( "12/10/8/8, 3 in all skills" ) {
standard_npc dude( "TestCharacter", dude_pos, {}, 3, 12, 10, 8, 8 );
print_stats( dude, weapons, zed );
}
}
TEST_CASE( "Strong character using melee weapons against a kevlar zombie", "[.][melee][slow]" )
{
monster zed( mtype_id( "mon_zombie_kevlar_1" ) );
auto weapons = find_weapons();
SECTION( "12/10/8/8, 3 in all skills" ) {
standard_npc dude( "TestCharacter", dude_pos, {}, 3, 12, 10, 8, 8 );
print_stats( dude, weapons, zed );
}
}