Skip to content

Commit

Permalink
Fix playing generic game not spending battery charges (#46693)
Browse files Browse the repository at this point in the history
Co-authored-by: Milos Rasic <[email protected]>
  • Loading branch information
MilosRasic and Milos Rasic authored Jan 14, 2021
1 parent fd0e59e commit 4ab911e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
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

0 comments on commit 4ab911e

Please sign in to comment.