Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New characters start with basic life skills #67663

Merged
merged 9 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions data/json/hobbies.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
[
{
"type": "profession",
"subtype": "hobby",
"id": "driving_license",
"name": "Driving License",
"description": "You got your driving license and know how to drive a car.",
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
"points": 0,
"skills": [ { "level": 1, "name": "driving" } ]
},
{
"type": "profession",
"subtype": "hobby",
"id": "simple_home_cooking",
"name": "Simple Home Cooking",
"description": "You've been living on your own long enough that you know how to cook basic dishes and feed yourself.",
"points": 0,
"skills": [ { "level": 1, "name": "cooking" } ],
"proficiencies": [ "prof_food_prep" ]
},
{
"type": "profession",
"subtype": "hobby",
"id": "computer_literate",
"name": "Computer Literate",
"description": "Either through school, your job, or from your family, you've learned the basics of how to use a computer.",
"points": 0,
"skills": [ { "level": 1, "name": "computer" } ]
},
{
"type": "profession",
"subtype": "hobby",
"id": "socially_adequate",
"name": "Socially Adequate",
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved
"description": "You've spent a significant portion of your life living among other people and are familiar with social norms. You know how to talk with other people, and how to convey your emotions and understand those of others.",
"points": 0,
"skills": [ { "level": 1, "name": "speech" } ]
},
{
"type": "profession",
"subtype": "hobby",
"id": "high_school_graduate",
"name": "High School Graduate",
"description": "You've graduated from high school and thus know a little bit about applied science and electronics.",
"points": 0,
"skills": [ { "level": 1, "name": "chemistry" }, { "level": 1, "name": "electronics" } ]
},
{
"type": "profession",
"subtype": "hobby",
"id": "mundane_survival",
"name": "Mundane Survival",
"description": "You've managed to survive modern life in a first world country. Through your ordeals you've learned how to treat scraps and bruises and how to assemble basic furniture.",
"points": 0,
"skills": [ { "level": 1, "name": "fabrication" }, { "level": 1, "name": "firstaid" } ]
},
{
"type": "profession",
"subtype": "hobby",
Expand Down
3 changes: 3 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
#include "overmap_location.h"
#include "path_info.h"
#include "profession.h"
#include "profession_group.h"
#include "proficiency.h"
#include "recipe_dictionary.h"
#include "recipe_groups.h"
Expand Down Expand Up @@ -266,6 +267,7 @@ void DynamicDataLoader::initialize()
add( "bionic", &bionic_data::load_bionic );
add( "bionic_migration", &bionic_data::load_bionic_migration );
add( "profession", &profession::load_profession );
add( "profession_group", &profession_group::load_profession_group );
add( "profession_item_substitutions", &profession::load_item_substitutions );
add( "proficiency", &proficiency::load_proficiencies );
add( "proficiency_category", &proficiency_category::load_proficiency_categories );
Expand Down Expand Up @@ -815,6 +817,7 @@ void DynamicDataLoader::check_consistency( loading_ui &ui )
{ _( "Constructions" ), &check_constructions },
{ _( "Crafting recipes" ), &recipe_dictionary::check_consistency },
{ _( "Professions" ), &profession::check_definitions },
{ _( "Profession groups" ), &profession_group::check_profession_group_consistency },
{ _( "Scenarios" ), &scenario::check_definitions },
{ _( "Martial arts" ), &check_martialarts },
{ _( "Mutations" ), &mutation_branch::check_consistency },
Expand Down
50 changes: 50 additions & 0 deletions src/profession_group.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "profession_group.h"

#include "assign.h"
#include "generic_factory.h"

namespace
{
generic_factory<profession_group> profession_group_factory( "profession_group" );
} // namespace

template<>
const profession_group &string_id<profession_group>::obj() const
{
return profession_group_factory.obj( *this );
}

template<>
bool string_id<profession_group>::is_valid() const
{
return profession_group_factory.is_valid( *this );
}

void profession_group::load_profession_group( const JsonObject &jo, const std::string &src )
{
profession_group_factory.load( jo, src );
}

void profession_group::load( const JsonObject &jo, const std::string & )
{
assign( jo, "id", id );
assign( jo, "professions", professions );

}

const std::vector<profession_group> &profession_group::get_all()
{
return profession_group_factory.get_all();
}

void profession_group::check_profession_group_consistency()
{
for( const profession_group &prof_grp : get_all() ) {
for( const profession_id prof : prof_grp.professions ) {
if( !prof.is_valid() ) {
debugmsg( "profession_group %s contains invalid profession_id %s", prof_grp.id.c_str(),
prof.c_str() );
}
}
}
}
21 changes: 21 additions & 0 deletions src/profession_group.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#ifndef CATA_SRCPROFESSION_GROUP_H
#define CATA_SRCPROFESSION_GROUP_H

#include "type_id.h"
#include "json.h"

class profession_group
{
public:
static void load_profession_group( const JsonObject &jo, const std::string &src );
void load( const JsonObject &jo, const std::string & );
static const std::vector<profession_group> &get_all();
static void check_profession_group_consistency();
bool was_loaded;
Fris0uman marked this conversation as resolved.
Show resolved Hide resolved

profession_group_id id;
std::vector<profession_id> professions;

};
#endif
3 changes: 3 additions & 0 deletions src/type_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ using overmap_special_migration_id = string_id<overmap_special_migration>;
class profession;
using profession_id = string_id<profession>;

class profession_group;
using profession_group_id = string_id<profession_group>;

class recipe;
using recipe_id = string_id<recipe>;

Expand Down