Skip to content

Commit

Permalink
Merge pull request #26420 from Muffindrake/flippist_galore
Browse files Browse the repository at this point in the history
Add Magic 8-Ball and coin
  • Loading branch information
ZhilkinSerg authored Nov 5, 2018
2 parents c3fc0f6 + 9a4f572 commit de68419
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
8 changes: 8 additions & 0 deletions data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
"type" : "item_action",
"id" : "CLEAR_RUBBLE",
"name" : "Clear rubble"
},{
"type" : "item_action",
"id" : "COIN_FLIP",
"name" : "Flip"
},{
"type" : "item_action",
"id" : "COKE",
Expand Down Expand Up @@ -443,6 +447,10 @@
"type" : "item_action",
"id" : "LADDER",
"name" : "Place"
},{
"type" : "item_action",
"id" : "MAGIC_8_BALL",
"name" : "Ask"
},{
"type" : "item_action",
"id" : "MARLOSS",
Expand Down
12 changes: 9 additions & 3 deletions data/json/item_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -4385,7 +4385,9 @@
["katana", 2],
["rapier", 3],
["cavalry_sabre", 2],
["sf_watch", 5]
["sf_watch", 5],
["magic_8_ball", 1],
["coin_quarter", 1]
]
},{
"type" : "item_group",
Expand Down Expand Up @@ -4835,7 +4837,9 @@
["l-stick", 1],
["solarpack", 5],
["tourist_table", 10],
["thermos", 25]
["thermos", 25],
["magic_8_ball", 2],
["coin_quarter", 2]
]
},{
"type" : "item_group",
Expand Down Expand Up @@ -8561,7 +8565,9 @@
["straw_doll", 1],
["pitchfork", 1],
["straw_sandals", 1],
["holy_symbol", 10]
["holy_symbol", 10],
["magic_8_ball", 1],
["coin_quarter", 1]
]
},{
"type" : "item_group",
Expand Down
32 changes: 32 additions & 0 deletions data/json/items/fluff.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"id": "magic_8_ball",
"type": "GENERIC",
"category": "other",
"name": "Magic 8-Ball",
"name_plural": "Magic 8-Balls",
"description": "A fortune-telling device from the 1950s. The kind of moral support you didn't know you needed.",
"weight": 40,
"volume": 1,
"price": 1000,
"material": [ "plastic" ],
"symbol": "o",
"color": "white",
"use_action": "MAGIC_8_BALL"
},
{
"id": "coin_quarter",
"type": "GENERIC",
"category": "other",
"name": "coin",
"name_plural": "coins",
"description": "A now-ancient form of currency. Stripped of its original purpose, it now serves, faithfully, flippant Flippists for free.",
"weight": 6,
"volume": 0,
"price": 25,
"material": [ "silver" ],
"symbol": "o",
"color": "light_gray",
"use_action": "COIN_FLIP"
}
]
2 changes: 2 additions & 0 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ void Item_factory::init()
add_iuse( "CAFF", &iuse::caff );
add_iuse( "CAMERA", &iuse::camera );
add_iuse( "CAN_GOO", &iuse::can_goo );
add_iuse( "COIN_FLIP", &iuse::coin_flip );
add_iuse( "DIRECTIONAL_HOLOGRAM", &iuse::directional_hologram );
add_iuse( "CAPTURE_MONSTER_ACT", &iuse::capture_monster_act );
add_iuse( "CAPTURE_MONSTER_VEH", &iuse::capture_monster_veh );
Expand Down Expand Up @@ -609,6 +610,7 @@ void Item_factory::init()
add_iuse( "JET_INJECTOR", &iuse::jet_injector );
add_iuse( "LADDER", &iuse::ladder );
add_iuse( "LUMBER", &iuse::lumber );
add_iuse( "MAGIC_8_BALL", &iuse::magic_8_ball );
add_iuse( "MAKEMOUND", &iuse::makemound );
add_iuse( "MARLOSS", &iuse::marloss );
add_iuse( "MARLOSS_GEL", &iuse::marloss_gel );
Expand Down
45 changes: 45 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7851,3 +7851,48 @@ int iuse::magnesium_tablet( player *p, item *it, bool, const tripoint & )
p->add_effect( effect_magnesium_supplements, 16_hours );
return it->type->charges_to_use();
}

int iuse::coin_flip( player *p, item *it, bool, const tripoint & )
{
p->add_msg_if_player( m_info, _( "You flip a %s." ), it->tname().c_str() );
p->add_msg_if_player( m_info, one_in( 2 ) ? _( "Heads!" ) : _( "Tails!" ) );
return 0;
}

int iuse::magic_8_ball( player *p, item *it, bool, const tripoint & )
{
enum {
BALL8_GOOD,
BALL8_UNK = 10,
BALL8_BAD = 15
};
const static std::array<const char *, 20> tab = {{
translate_marker( "It is certain." ),
translate_marker( "It is decidedly so." ),
translate_marker( "Without a doubt." ),
translate_marker( "Yes - definitely." ),
translate_marker( "You may rely on it." ),
translate_marker( "As I see it, yes." ),
translate_marker( "Most likely." ),
translate_marker( "Outlook good." ),
translate_marker( "Yes." ),
translate_marker( "Signs point to yes." ),
translate_marker( "Reply hazy, try again." ),
translate_marker( "Ask again later." ),
translate_marker( "Better not tell you now." ),
translate_marker( "Cannot predict now." ),
translate_marker( "Concentrate and ask again." ),
translate_marker( "Don't count on it." ),
translate_marker( "My reply is no." ),
translate_marker( "My sources say no." ),
translate_marker( "Outlook not so good." ),
translate_marker( "Very doubtful." )
}
};

p->add_msg_if_player( m_info, _( "You ask the %s, then flip it." ), it->tname().c_str() );
int rn = rng( 0, tab.size() - 1 );
auto color = ( rn >= BALL8_BAD ? m_bad : rn >= BALL8_UNK ? m_info : m_good );
p->add_msg_if_player( color, _( "The %s says: %s" ), it->tname().c_str(), _( tab[rn] ) );
return 0;
}
2 changes: 2 additions & 0 deletions src/iuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class iuse
int instant_antibiotic( player *, item *, bool, const tripoint & );
int panacea( player *, item *, bool, const tripoint & );
int magnesium_tablet( player *, item *, bool, const tripoint & );
int coin_flip( player *, item *, bool, const tripoint & );
int magic_8_ball( player *, item *, bool, const tripoint & );

// MACGUFFINS

Expand Down

0 comments on commit de68419

Please sign in to comment.