Skip to content

Commit

Permalink
Add Deck of cards to gain morale with a game of solitaire activity (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpwbrown authored and ZhilkinSerg committed Nov 30, 2019
1 parent 246e5f9 commit 20e8354
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 1 deletion.
5 changes: 5 additions & 0 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@
"id": "MAGIC_8_BALL",
"name": "Ask"
},
{
"type": "item_action",
"id": "PLAY_GAME",
"name": "Play"
},
{
"type": "item_action",
"id": "MARLOSS",
Expand Down
6 changes: 6 additions & 0 deletions data/json/itemgroups/item_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
[ "dnd_handbook", 1 ],
[ "RPG_die", 1 ],
[ "metal_RPG_die", 1 ],
[ "deck_of_cards", 1 ],
[ "milkshake_fastfood", 3 ]
]
},
Expand Down Expand Up @@ -330,6 +331,7 @@
[ "mp3", 18 ],
[ "portable_game", 8 ],
[ "game_watch", 2 ],
[ "deck_of_cards", 2 ],
[ "usb_drive", 5 ],
[ "beer", 35 ],
[ "european_pilsner", 25 ],
Expand Down Expand Up @@ -933,6 +935,7 @@
[ "mp3", 18 ],
[ "portable_game", 8 ],
[ "game_watch", 2 ],
[ "deck_of_cards", 2 ],
[ "usb_drive", 5 ],
[ "firecracker_pack", 5 ],
[ "firecracker", 5 ],
Expand Down Expand Up @@ -1309,6 +1312,7 @@
[ "mp3", 18 ],
[ "portable_game", 8 ],
[ "game_watch", 2 ],
[ "deck_of_cards", 2 ],
[ "roadmap", 40 ],
[ "trailmap", 20 ],
[ "file", 10 ],
Expand Down Expand Up @@ -3482,6 +3486,7 @@
[ "mp3", 18 ],
[ "portable_game", 8 ],
[ "game_watch", 2 ],
[ "deck_of_cards", 2 ],
[ "vibrator", 5 ],
[ "string_36", 40 ],
[ "chain", 20 ],
Expand Down Expand Up @@ -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 ],
Expand Down
15 changes: 15 additions & 0 deletions data/json/items/fluff.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion data/json/morale_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{
"id": "morale_game",
"type": "morale_type",
"text": "Played Video Game"
"text": "Played Game"
},
{
"id": "morale_marloss",
Expand Down
8 changes: 8 additions & 0 deletions data/json/player_activities.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/activity_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
10 changes: 10 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( 1_hours ), -1,
p->get_item_position( it ), "gaming" );
}
return 0;
}

int iuse::magic_8_ball( player *p, item *it, bool, const tripoint & )
{
enum {
Expand Down
1 change: 1 addition & 0 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 & );
Expand Down

0 comments on commit 20e8354

Please sign in to comment.