-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Magic 8-Ball and coin #26420
Add Magic 8-Ball and coin #26420
Conversation
The warning preventing the gorgon build from going through is a LLVM bug. |
870b4d8
to
88d8416
Compare
@@ -7781,3 +7781,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 & ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a sense in returning int
for these new functions when we don't use returned value at all? Isn't returning void
better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, there's no reason for them to have a return type of int. I don't know about returning void, but I do know about not returning a value. Lots of existing iuse functions have a return type of int for no particular reason, not that it hurts any other part of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would involve writing another overload for add_iuse
in item_factory.h
, as the current one only accepts use_function_pointer
, which is defined as:
typedef int ( iuse::*use_function_pointer )( player *, item *, bool, const tripoint & );
Probably some other architectural changes required I don't know about. I'm not too familiar with the code beyond that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a sense in returning int for these new functions when we don't use returned value at all? Isn't returning void better?
It's strange you complain about the apparently unused return value, but you do not complain about the unused parameters.
The function has to follow a specific interface definition which requires exactly those parameters and that return type (C++ is a statically typed language).
Fixing this would require actions indicated by Muffindrake, which would also make the whole interface much more complicated with little to no gain.
src/iuse.cpp
Outdated
_( "My reply is no." ), | ||
_( "My sources say no." ), | ||
_( "Outlook not so good." ), | ||
_( "Very doubtful." ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to change the _
into translate_marker
and apply the translation in the add_msg
line below. Currently those strings are translated (and stored) when the function is first called. Changing the language will not affect them after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently those strings are translated (and stored) when the function is first called.
const static std::array<const char *, 20> tab
Are you sure that's how it works? I am not too familiar with this i18n thing with this code base, so I'll take your word for it.
Summary
SUMMARY: Content "Added Magic 8-Ball and coin"
Purpose of change
It's fluff content. Flip a coin to decide whether to ask the Magic 8-Ball, or ask the Magic 8-Ball to flip a coin, or ask a zombie (not actually a feature) to flip a coin. You could also (gasp) use these items to make more meaningful decisions, like "Do I go into this city and die horribly?". The possibilities are endless!
Additional context
Also added to item groups for pawn shop, art gallery and non-rare antique store at low weight. Provides no bonuses for using (or not using) these items.