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

Require denomination pricing for price and price_postapoc #78905

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

RenechCDDA
Copy link
Member

@RenechCDDA RenechCDDA commented Jan 2, 2025

Summary

Infrastructure "Item price and price_postapoc must be denominated (cents/USD/kUSD). Integer values no longer used"

Purpose of change

#78901 (comments)

Describe the solution

Throw error if an integer is found

Print list of valid denominations, so that the cent/cents conundrum is clearly communicated to our contributors . Pulls directly from money_units, so should be future proofed.

Also the following units are now accepted as subsitutes:
cents--->cent
dollar--->USD
dollars--->USD

Describe alternatives you've considered

Also accept cents as a valid unit which converts to 1_cent. Single line change in units.h, but not sure if it's a good idea doing that.

Testing

image

image

Additional context

In draft until I do all the JSON stuff

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Jan 2, 2025
@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Items: Food / Vitamins Comestibles and drinks Mods: Aftershock Anything to do with the Aftershock mod Items: Armor / Clothing Armor and clothing labels Jan 2, 2025
@github-actions github-actions bot added Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Mods: Magiclysm Anything to do with the Magiclysm mod Mods: No Hope Relating to the mod No Hope Mods: Mind Over Matter labels Jan 3, 2025
@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [Markdown] Markdown issues and PRs labels Jan 4, 2025
@RenechCDDA
Copy link
Member Author

RenechCDDA commented Jan 4, 2025

Ooooooooooh okay, I don't think we can do the aliasing without some really nasty stuff.

So if both "cent" and "cents" are valid, it reads cent and assumes the unit will be "cent". Then it throws an error, because the value it ends up reading is "cents", which is one character too many! The program can read, .e.g. 2 dollar 40 cent. It does this by finishing reading the 2 dollar portion, then reading the next character to see if there is anything else.

If our input is instead 2 dollars 40 cents (notice the dollars, plural) then it encounters an s. It expected to read either a space(which it would skip) or another number value (the 40 cent) which it would add to the existing value. But it found an s instead, so it doesn't know what to do.

We could maybe, maybe, change the order of units in units::money so that dollars is before dollar and cents is before cent, so that it always reads the longer one first. But that seems nasty!

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style <Documentation> Design documents, internal info, guides and help. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Items: Armor / Clothing Armor and clothing Items: Food / Vitamins Comestibles and drinks [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs Mods: Aftershock Anything to do with the Aftershock mod Mods: Magiclysm Anything to do with the Magiclysm mod Mods: Mind Over Matter Mods: No Hope Relating to the mod No Hope
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants