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

[CR]Add "calories" field to it_comest #14613

Merged
merged 6 commits into from Jan 16, 2016

Conversation

Projects
None yet
2 participants
@Coolthulhu
Copy link
Contributor

commented Dec 25, 2015

As discussed in #13857
Conflicts with #14597

This is mostly to allow starting the migration, there are no in-game effects here.

Calorie field is used only if the nutrition field is unset (or set to a negative value - not used in game, because nutr was unsigned before).
I assumed 1 unit of nutrition is ~8.7 kcal because:

  • Average survivor consumes 1 nutrition per 5 minutes
  • There are 12 * 24 = 288 hunger "ticks" per day
  • I assumed average active person consumes 2500 kcal/day
  • 2500 / 288 ~= 8.7

Both nutrition and calorie fields are kept. They are accessed through get_nutrition() and get_calories(). Made nutr field private.

@@ -607,11 +607,18 @@ struct itype {

// Includes food drink and drugs
struct it_comest : itype {
friend class Item_factory;

This comment has been minimized.

Copy link
@kevingranade

kevingranade Jan 10, 2016

Member

Friends are bad, can we just replace this with a constructor? (I'm assuming that's why it's needed.)

This comment has been minimized.

Copy link
@Coolthulhu

Coolthulhu Jan 15, 2016

Author Contributor

I went with friend class because currently all itypes use only the default constructor and because itype (the base class) already has Item_factory as a friend. It looked like a convention, so I tried not to break it.

I could add a setter or make the field public as it was before. Constructor alone would work now, but it would require either a setter or public field later if we wanted to add mod override for individual item fields (as opposed to overriding the entire item at once).

This comment has been minimized.

Copy link
@kevingranade

kevingranade via email Jan 15, 2016

Member

This comment has been minimized.

Copy link
@kevingranade

kevingranade Jan 16, 2016

Member

However I'm looking at merging this, I'll follow up with a PR of my own doing what I'm suggesting, and we can discuss the general issue there, this is a long term thing, and the nutrition thing is short-term.

This comment has been minimized.

Copy link
@kevingranade

kevingranade Jan 16, 2016

Member

You know, I'm wrong, friendship on a factory is perfectly reasonable.

@kevingranade

This comment has been minimized.

Copy link
Member

commented Jan 10, 2016

Seems like a great idea, why CR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.