Permalink
Browse files

Add placeholder zone harvest activity

  • Loading branch information...
prutschman committed Dec 21, 2018
1 parent 4d00511 commit 79026f1e535dfaf9644060b61feead47f5145680
Showing with 42 additions and 4 deletions.
  1. +8 −0 data/json/player_activities.json
  2. +7 −0 src/activity_handlers.cpp
  3. +1 −0 src/activity_handlers.h
  4. +11 −1 src/handle_action.cpp
  5. +14 −2 src/iexamine.cpp
  6. +1 −1 src/iexamine.h
@@ -222,6 +222,14 @@
"based_on": "neither",
"no_resume": true
},
{
"id": "ACT_HARVEST_PLOT",
"type": "activity_type",
"stop_phrase": "Stop harvesting plots?",
"suspendable": false,
"based_on": "neither",
"no_resume": true
},
{
"id": "ACT_ADV_INVENTORY",
"type": "activity_type",
@@ -88,6 +88,7 @@ activity_handlers::do_turn_functions = {
{ activity_id( "ACT_DIG" ), dig_do_turn },
{ activity_id( "ACT_FILL_PIT" ), fill_pit_do_turn },
{ activity_id( "ACT_TILL_PLOT" ), till_plot_do_turn },
{ activity_id( "ACT_HARVEST_PLOT" ), harvest_plot_do_turn },
{ activity_id( "ACT_PLANT_PLOT" ), plant_plot_do_turn },
{ activity_id( "ACT_TRY_SLEEP" ), try_sleep_do_turn }
};
@@ -3001,6 +3002,12 @@ static void cleanup_tiles( std::unordered_set<tripoint> &tiles, fn &cleanup )
}
}

void activity_handlers::harvest_plot_do_turn( player_activity *, player *p )
{
p->activity = player_activity();
add_msg( m_info, _( "Harvesting is just a placeholder for now." ) );
}

void activity_handlers::till_plot_do_turn( player_activity *, player *p )
{
const auto &mgr = zone_manager::get_manager();
@@ -81,6 +81,7 @@ void dig_do_turn( player_activity *act, player *p );
void fill_pit_do_turn( player_activity *act, player *p );
void till_plot_do_turn( player_activity *act, player *p );
void plant_plot_do_turn( player_activity *act, player *p );
void harvest_plot_do_turn( player_activity *act, player *p );
void try_sleep_do_turn( player_activity *act, player *p );

// defined in activity_handlers.cpp
@@ -817,7 +817,8 @@ static void loot()
None = 1,
SortLoot = 2,
TillPlots = 4,
PlantPlots = 8
PlantPlots = 8,
HarvestPlots = 16
};

auto just_one = []( int flags ) {
@@ -836,6 +837,7 @@ static void loot()
if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) {
flags |= TillPlots;
flags |= PlantPlots;
flags |= HarvestPlots;
}

if( flags == 0 ) {
@@ -869,6 +871,11 @@ static void loot()
_( "Plant seeds into nearby Farm: Plot zones. Farm plot has to be set to specific plant seed and you must have seeds in your inventory." ) );
}

if( flags & HarvestPlots ) {
menu.addentry_desc( HarvestPlots, true, 'h', _( "Harvest plots" ),
_( "Harvest any full-grown plants from nearby Farm: Plot zones" ) );
}

menu.query();
flags = ( menu.ret >= 0 ) ? menu.ret : None;
}
@@ -896,6 +903,9 @@ static void loot()
u.assign_activity( activity_id( "ACT_PLANT_PLOT" ) );
}
break;
case HarvestPlots:
u.assign_activity( activity_id( "ACT_HARVEST_PLOT" ) );
break;
default:
debugmsg( "Unsupported flag" );
break;
@@ -1801,8 +1801,20 @@ std::list<item> iexamine::get_harvest_items( const itype &type, const int plant_
/**
* Actual harvesting of selected plant
*/
void iexamine::harvest_plant(player &p, const tripoint &examp, const item &seed )
void iexamine::harvest_plant(player &p, const tripoint &examp)
{
if( g->m.i_at( examp ).empty() ) {
g->m.i_clear( examp );
g->m.furn_set( examp, f_null );
debugmsg( "Missing seed in plant furniture!" );
return;
}
const item &seed = g->m.i_at( examp ).front();
if( !seed.is_seed() ) {
debugmsg( "The seed item %s is not a seed!", seed.tname().c_str() );
return;
}

const std::string &seedType = seed.typeId();
if (seedType == "fungal_seeds") {
fungus(p, examp);
@@ -1862,7 +1874,7 @@ void iexamine::aggie_plant(player &p, const tripoint &examp)
const std::string pname = seed.get_plant_name();

if (g->m.furn(examp) == f_plant_harvest && query_yn(_("Harvest the %s?"), pname.c_str() )) {
harvest_plant(p, examp, seed);
harvest_plant(p, examp);
} else if (g->m.furn(examp) != f_plant_harvest) {
if (g->m.i_at(examp).size() > 1) {
add_msg(m_info, _("This %s has already been fertilized."), pname.c_str() );
@@ -118,7 +118,7 @@ std::list<item> get_harvest_items( const itype &type, int plant_count,
std::vector<seed_tuple> get_seed_entries( const std::vector<item *> &seed_inv );
int query_seed( const std::vector<seed_tuple> &seed_entries );
void plant_seed( player &p, const tripoint &examp, const itype_id &seed_id );
void harvest_plant( player &p, const tripoint &examp, const item &seed );
void harvest_plant( player &p, const tripoint &examp );

} //namespace iexamine

0 comments on commit 79026f1

Please sign in to comment.