From 20e83548b6a303bb4affe95c675e9bd0c7ef14b8 Mon Sep 17 00:00:00 2001 From: davidpwbrown <39344466+davidpwbrown@users.noreply.github.com> Date: Sat, 30 Nov 2019 22:25:13 +0000 Subject: [PATCH] Add Deck of cards to gain morale with a game of solitaire activity (#35780) --- data/json/item_actions.json | 5 +++++ data/json/itemgroups/item_groups.json | 6 ++++++ data/json/items/fluff.json | 15 +++++++++++++++ data/json/morale_types.json | 2 +- data/json/player_activities.json | 8 ++++++++ src/activity_handlers.cpp | 9 +++++++++ src/activity_handlers.h | 1 + src/item_factory.cpp | 1 + src/iuse.cpp | 10 ++++++++++ src/iuse.h | 1 + 10 files changed, 57 insertions(+), 1 deletion(-) diff --git a/data/json/item_actions.json b/data/json/item_actions.json index e0d14f221888f..e5f96e95a57fe 100644 --- a/data/json/item_actions.json +++ b/data/json/item_actions.json @@ -604,6 +604,11 @@ "id": "MAGIC_8_BALL", "name": "Ask" }, + { + "type": "item_action", + "id": "PLAY_GAME", + "name": "Play" + }, { "type": "item_action", "id": "MARLOSS", diff --git a/data/json/itemgroups/item_groups.json b/data/json/itemgroups/item_groups.json index 8cf9a4499ed88..640a571ae91e3 100644 --- a/data/json/itemgroups/item_groups.json +++ b/data/json/itemgroups/item_groups.json @@ -51,6 +51,7 @@ [ "dnd_handbook", 1 ], [ "RPG_die", 1 ], [ "metal_RPG_die", 1 ], + [ "deck_of_cards", 1 ], [ "milkshake_fastfood", 3 ] ] }, @@ -330,6 +331,7 @@ [ "mp3", 18 ], [ "portable_game", 8 ], [ "game_watch", 2 ], + [ "deck_of_cards", 2 ], [ "usb_drive", 5 ], [ "beer", 35 ], [ "european_pilsner", 25 ], @@ -933,6 +935,7 @@ [ "mp3", 18 ], [ "portable_game", 8 ], [ "game_watch", 2 ], + [ "deck_of_cards", 2 ], [ "usb_drive", 5 ], [ "firecracker_pack", 5 ], [ "firecracker", 5 ], @@ -1309,6 +1312,7 @@ [ "mp3", 18 ], [ "portable_game", 8 ], [ "game_watch", 2 ], + [ "deck_of_cards", 2 ], [ "roadmap", 40 ], [ "trailmap", 20 ], [ "file", 10 ], @@ -3482,6 +3486,7 @@ [ "mp3", 18 ], [ "portable_game", 8 ], [ "game_watch", 2 ], + [ "deck_of_cards", 2 ], [ "vibrator", 5 ], [ "string_36", 40 ], [ "chain", 20 ], @@ -6451,6 +6456,7 @@ [ "bb", 30 ], [ "portable_game", 60 ], [ "game_watch", 15 ], + [ "deck_of_cards", 25 ], [ "atomic_light", 1 ], [ "manual_dodge_kid", 5 ], [ "inflatable_boat", 10 ], diff --git a/data/json/items/fluff.json b/data/json/items/fluff.json index 00199fd6afb81..8ab793fe26a5f 100644 --- a/data/json/items/fluff.json +++ b/data/json/items/fluff.json @@ -14,6 +14,21 @@ "color": "white", "use_action": "MAGIC_8_BALL" }, + { + "id": "deck_of_cards", + "type": "GENERIC", + "category": "other", + "name": { "str": "deck of cards", "str_pl": "decks of cards" }, + "description": "A deck of 52 playing cards.", + "weight": "50 g", + "volume": "100 ml", + "price": 2000, + "material": [ "paper" ], + "symbol": ",", + "color": "red", + "flags": [ "NO_REPAIR" ], + "use_action": "PLAY_GAME" + }, { "id": "coin_quarter", "type": "GENERIC", diff --git a/data/json/morale_types.json b/data/json/morale_types.json index 9809242c5e788..dcdd65a704b0d 100644 --- a/data/json/morale_types.json +++ b/data/json/morale_types.json @@ -37,7 +37,7 @@ { "id": "morale_game", "type": "morale_type", - "text": "Played Video Game" + "text": "Played Game" }, { "id": "morale_marloss", diff --git a/data/json/player_activities.json b/data/json/player_activities.json index c1ef8f74b07ff..465dc03b5b104 100644 --- a/data/json/player_activities.json +++ b/data/json/player_activities.json @@ -99,6 +99,14 @@ "verb": "fishing", "based_on": "neither" }, + { + "id": "ACT_GENERIC_GAME", + "type": "activity_type", + "activity_level": "NO_EXERCISE", + "verb": "playing", + "rooted": true, + "based_on": "time" + }, { "id": "ACT_GAME", "type": "activity_type", diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index d35feef9804bb..9aef65e34e5ac 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -130,6 +130,7 @@ activity_handlers::do_turn_functions = { { activity_id( "ACT_STASH" ), stash_do_turn }, { activity_id( "ACT_PULP" ), pulp_do_turn }, { activity_id( "ACT_GAME" ), game_do_turn }, + { activity_id( "ACT_GENERIC_GAME" ), generic_game_do_turn }, { activity_id( "ACT_START_FIRE" ), start_fire_do_turn }, { activity_id( "ACT_VIBE" ), vibe_do_turn }, { activity_id( "ACT_HAND_CRANK" ), hand_crank_do_turn }, @@ -1532,6 +1533,14 @@ void activity_handlers::forage_finish( player_activity *act, player *p ) act->set_to_null(); } +void activity_handlers::generic_game_do_turn( player_activity *act, player *p ) +{ + ( void )act; + if( calendar::once_every( 1_minutes ) ) { + p->add_morale( MORALE_GAME, 4, 60 ); + } +} + void activity_handlers::game_do_turn( player_activity *act, player *p ) { item &game_item = p->i_at( act->position ); diff --git a/src/activity_handlers.h b/src/activity_handlers.h index 75bad87150875..7dc75f5f06cea 100644 --- a/src/activity_handlers.h +++ b/src/activity_handlers.h @@ -136,6 +136,7 @@ void drop_do_turn( player_activity *act, player *p ); void stash_do_turn( player_activity *act, player *p ); void pulp_do_turn( player_activity *act, player *p ); void game_do_turn( player_activity *act, player *p ); +void generic_game_do_turn( player_activity *act, player *p ); void churn_do_turn( player_activity *act, player *p ); void start_fire_do_turn( player_activity *act, player *p ); void vibe_do_turn( player_activity *act, player *p ); diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 9ce1452f922ac..fa3cf6b2a2106 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -687,6 +687,7 @@ void Item_factory::init() add_iuse( "LADDER", &iuse::ladder ); add_iuse( "LUMBER", &iuse::lumber ); add_iuse( "MAGIC_8_BALL", &iuse::magic_8_ball ); + add_iuse( "PLAY_GAME", &iuse::play_game ); add_iuse( "MAKEMOUND", &iuse::makemound ); add_iuse( "DIG_CHANNEL", &iuse::dig_channel ); add_iuse( "MARLOSS", &iuse::marloss ); diff --git a/src/iuse.cpp b/src/iuse.cpp index e3dff33366689..f3c44a0309747 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -9718,6 +9718,16 @@ int iuse::coin_flip( player *p, item *it, bool, const tripoint & ) return 0; } +int iuse::play_game( player *p, item *it, bool, const tripoint & ) +{ + if( query_yn( _( "Play a game with the %s?" ), it->tname() ) ) { + p->add_msg_if_player( _( "You start playing." ) ); + p->assign_activity( activity_id( "ACT_GENERIC_GAME" ), to_moves( 1_hours ), -1, + p->get_item_position( it ), "gaming" ); + } + return 0; +} + int iuse::magic_8_ball( player *p, item *it, bool, const tripoint & ) { enum { diff --git a/src/iuse.h b/src/iuse.h index 65da0dd735278..e35a639a8f920 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -205,6 +205,7 @@ class iuse int panacea( player *, item *, bool, const tripoint & ); int magnesium_tablet( player *, item *, bool, const tripoint & ); int coin_flip( player *, item *, bool, const tripoint & ); + int play_game( player *, item *, bool, const tripoint & ); int magic_8_ball( player *, item *, bool, const tripoint & ); int gobag_normal( player *, item *, bool, const tripoint & ); int gobag_personal( player *, item *, bool, const tripoint & );