Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[CR]Add "calories" field to it_comest #14613
Conversation
Coolthulhu
added some commits
Dec 25, 2015
kevingranade
reviewed
Jan 10, 2016
| @@ -607,11 +607,18 @@ struct itype { | |||
|
|
|||
| // Includes food drink and drugs | |||
| struct it_comest : itype { | |||
| friend class Item_factory; | |||
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
kevingranade
via email
Jan 15, 2016
Member
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
kevingranade
Jan 16, 2016
Member
You know, I'm wrong, friendship on a factory is perfectly reasonable.
This comment has been minimized.
This comment has been minimized.
|
Seems like a great idea, why CR? |
Coolthulhu commentedDec 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
nutrwasunsignedbefore).I assumed 1 unit of nutrition is ~8.7 kcal because:
12 * 24 = 288hunger "ticks" per dayBoth nutrition and calorie fields are kept. They are accessed through
get_nutrition()andget_calories(). Madenutrfield private.