Skip to content

Commit

Permalink
Implement point cost calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
hexagonrecursion committed Aug 14, 2021
1 parent e0ad76e commit 805c0a0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/newcharacter.cpp
Expand Up @@ -4,6 +4,7 @@
#include <climits>
#include <cstdlib>
#include <functional>
#include <initializer_list>
#include <iosfwd>
#include <iterator>
#include <list>
Expand Down Expand Up @@ -123,6 +124,55 @@ enum struct tab_direction {
QUIT
};

//const int stat_point_pool = 4 * 8 + 6;
int stat_points_used( const avatar &u )
{
int used = 0;
for( int stat : {
u.str_max, u.dex_max, u.int_max, u.per_max
} ) {
used += stat + std::max( 0, stat - HIGH_STAT );
}
return used;
}

//const int trait_point_pool = 0;
int trait_points_used( const avatar &u )
{
int used = 0;
for( trait_id cur_trait : u.get_mutations( true ) ) {
bool locked = get_scenario()->is_locked_trait( cur_trait )
|| u.prof->is_locked_trait( cur_trait );
for( const profession *hobby : u.hobbies ) {
locked = locked || hobby->is_locked_trait( cur_trait );
}
if( locked ) {
// The starting traits granted by scenarios, professions and hobbies cost nothing
continue;
}
const mutation_branch &mdata = cur_trait.obj();
used += mdata.points;
}
return used;
}

//const int skill_point_pool = 2;
int skill_points_used( const avatar &u )
{
int scenario = get_scenario()->point_cost();
int profession_points = u.prof->point_cost();
int hobbies = 0;
for( const profession *hobby : u.hobbies ) {
hobbies += hobby->point_cost();
}
int skills = 0;
for( const Skill &sk : Skill::skills ) {
std::vector<int> costs = {0, 1, 1, 2, 4, 6, 9, 12, 16, 20, 25};
skills += costs.at( u.get_skill_level( sk.ident() ) );
}
return scenario + profession_points + hobbies + skills;
}

struct points_left {
int stat_points;
int trait_points;
Expand Down

0 comments on commit 805c0a0

Please sign in to comment.