Skip to content
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

Merged
merged 8 commits into from
Nov 5, 2018
Merged

Conversation

Muffindrake
Copy link
Contributor

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.

src/iuse.cpp Outdated Show resolved Hide resolved
@Muffindrake
Copy link
Contributor Author

Muffindrake commented Oct 27, 2018

The warning preventing the gorgon build from going through is a LLVM bug.

https://bugs.llvm.org/show_bug.cgi?id=21629

@@ -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 & )
Copy link
Contributor

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?

Copy link
Contributor Author

@Muffindrake Muffindrake Oct 28, 2018

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Night-Pryanik

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." )
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mlangsdorf mlangsdorf added [JSON] Changes (can be) made in JSON [C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact labels Nov 1, 2018
@ZhilkinSerg ZhilkinSerg self-assigned this Nov 5, 2018
@ZhilkinSerg ZhilkinSerg merged commit de68419 into CleverRaven:master Nov 5, 2018
@ZhilkinSerg ZhilkinSerg removed their assignment Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Items / Item Actions / Item Qualities Items and how they work and interact [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants