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

Fix dark craftable PR #38243

Merged
merged 3 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 21 additions & 10 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,15 @@ construction_id construction_menu( const bool blueprint )
}
if( !blueprint ) {
if( player_can_build( g->u, total_inv, constructs[select] ) ) {
place_construction( constructs[select] );
uistate.last_construction = constructs[select];
if( !player_can_see_to_build( g->u, constructs[select] ) ) {
add_msg( m_info, _( "It is too dark to construct right now." ) );
} else {
place_construction( constructs[select] );
uistate.last_construction = constructs[select];
}
exit = true;
} else {
popup( _( "You can't build that!" ) );
draw_grid( w_con, w_list_width + w_list_x0 );
update_info = true;
}
Expand Down Expand Up @@ -733,7 +738,6 @@ bool player_can_build( player &p, const inventory &inv, const std::string &desc

bool player_can_build( player &p, const inventory &inv, const construction &con )
{

if( p.has_trait( trait_DEBUG_HS ) ) {
return true;
}
Expand All @@ -742,14 +746,21 @@ bool player_can_build( player &p, const inventory &inv, const construction &con
return false;
}

const bool can_build = con.requirements->can_make_with_inventory( inv, is_crafting_component );
if( !can_build ) {
popup( _( "You can't build that!" ) );
} else if( g->u.fine_detail_vision_mod() > 4 && !con.dark_craftable ) {
popup( _( "It is too dark to construct right now." ) );
return false;
return con.requirements->can_make_with_inventory( inv, is_crafting_component );
}

bool player_can_see_to_build( player &p, const std::string &desc )
{
if( p.fine_detail_vision_mod() < 4 || p.has_trait( trait_DEBUG_HS ) ) {
return true;
}
std::vector<construction *> cons = constructions_by_desc( desc );
for( construction *&con : cons ) {
if( con->dark_craftable ) {
return true;
}
}
return can_build;
return false;
}

bool can_construct( const std::string &desc )
Expand Down
1 change: 1 addition & 0 deletions src/construction.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ construction_id construction_menu( bool blueprint );
void complete_construction( player *p );
bool can_construct( const construction &con, const tripoint &p );
bool player_can_build( player &p, const inventory &inv, const construction &con );
bool player_can_see_to_build( player &p, const std::string &desc );
void check_constructions();
void finalize_constructions();

Expand Down