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 playing generic game not spending battery charges #46693

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
22 changes: 13 additions & 9 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,14 +1705,8 @@ void activity_handlers::forage_finish( player_activity *act, player *p )
here.maybe_trigger_trap( bush_pos, *p, true );
}

void activity_handlers::generic_game_do_turn( player_activity * /*act*/, player *p )
{
if( calendar::once_every( 1_minutes ) ) {
p->add_morale( MORALE_GAME, 4, 60 );
}
}

void activity_handlers::game_do_turn( player_activity *act, player *p )
void activity_handlers::generic_game_turn_handler( player_activity *act, player *p,
int morale_bonus, int morale_max_bonus )
{
item &game_item = *act->targets.front();

Expand All @@ -1728,14 +1722,24 @@ void activity_handlers::game_do_turn( player_activity *act, player *p )

if( !fail ) {
//1 points/min, almost 2 hours to fill
p->add_morale( MORALE_GAME, 1, 100 );
p->add_morale( MORALE_GAME, morale_bonus, morale_max_bonus );
} else {
act->moves_left = 0;
add_msg( m_info, _( "The %s runs out of batteries." ), game_item.tname() );
}
}
}

void activity_handlers::generic_game_do_turn( player_activity *act, player *p )
{
generic_game_turn_handler( act, p, 4, 60 );
}

void activity_handlers::game_do_turn( player_activity *act, player *p )
{
generic_game_turn_handler( act, p, 1, 100 );
}

void activity_handlers::longsalvage_finish( player_activity *act, player *p )
{
static const std::string salvage_string = "salvage";
Expand Down
3 changes: 3 additions & 0 deletions src/activity_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ namespace activity_handlers
{

bool resume_for_multi_activities( player &p );
void generic_game_turn_handler( player_activity *act, player *p, int morale_bonus,
int morale_max_bonus );

/** activity_do_turn functions: */
void fill_liquid_do_turn( player_activity *act, player *p );
void pickaxe_do_turn( player_activity *act, player *p );
Expand Down
1 change: 1 addition & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4581,6 +4581,7 @@ int iuse::portable_game( player *p, item *it, bool active, const tripoint & )
if( loaded_software == "null" ) {
p->assign_activity( ACT_GENERIC_GAME, to_moves<int>( 1_hours ), -1,
p->get_item_position( it ), "gaming" );
p->activity.targets.push_back( item_location( *p, it ) );
return 0;
}
p->assign_activity( ACT_GAME, moves, -1, 0, "gaming" );
Expand Down