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

Implement a version of ShadowTheAge#181, allowing XXb to specify XX belts of production. #128

Merged
merged 2 commits into from
May 14, 2024

Conversation

DaleStan
Copy link
Collaborator

Also look for /s, /m, or /h suffixes. If present, use that suffix regardless of the current display settings.

The objectives I developed over the course of implementing this, re-implementing it, and remembering I needed to write tests, were:

  • Allow specifying a certain number of belts of production or consumption, by typing "XXb"
  • Correctly parse /s, /m, and /h suffixes, regardless of the current display preferences.
  • Preserve existing behavior with regards to case sensitivity and bare-number input:
    • Preserve mW == MW for now
    • "100" still means 100 of whatever unit is normally displayed in that box.
  • Be as permissive as reasonable about whitespace. (More permissive than I intended, to allow parsing the "10 000" output from calling FormatValue(..., precise: true))
  • Correctly parse any string YAFC can display:
    • Allow p and /t suffixes when they have meanings in the preferences. (That said, /t always has a meaning.)
    • Fix the bug that "10W" is parsed as ten megawatts instead of ten watts.
  • Prevent use of non-applicable units or garbage input:
    • No reporting you built "5/m" buildings or "30%" beacons, and no sticking a "?" anywhere in your input.
    • On the other hand, do allow "+15e+4", which is valid formatting for a float.

I'm not opposed to repurposing m for milli- instead of mega-, but I didn't want to do that here.

@shpaass
Copy link
Owner

shpaass commented May 12, 2024

remembering I needed to write tests

Tests would be very welcome, especially as this function can be tested without a set-up because it's public static.

Edit: alright, now I see them. Apologies :D

@shpaass
Copy link
Owner

shpaass commented May 12, 2024

SIck tests! The most thorough I've seen so far.

shpaass
shpaass previously approved these changes May 12, 2024
Copy link
Owner

@shpaass shpaass left a comment

Choose a reason for hiding this comment

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

I approved, but someone else needs to take a look at it too, just to be sure.

Copy link
Collaborator

@veger veger left a comment

Choose a reason for hiding this comment

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

Nice to see you are back at YAFC/Factorio 😄

I'm not opposed to repurposing m for milli- instead of mega-, but I didn't want to do that here.

Same, having the correct letters for the correct 'factors' is less confusing (and players might even learn a thing or two 😉 )

Yafc.Model.Tests/Data/DataUtils.cs Show resolved Hide resolved
Yafc.Model/Data/DataUtils.cs Show resolved Hide resolved
Yafc/Data/Tips.txt Outdated Show resolved Hide resolved
@shpaass
Copy link
Owner

shpaass commented May 13, 2024

@veger

having the correct letters for the correct 'factors' is less confusing

I think it was done for convenience. Sometimes you want mega (10^6) for megawatts, but you almost never want to enter milli (10^-3), and you don't want to press Shift all the time for mega.

@veger
Copy link
Collaborator

veger commented May 13, 2024

Just giving my thoughts on the matter. I don't use either one of them as I let YAFC calculate all the needs, and I do not have 'end products' in either 'milli' or 'mega' range 😉

But from a standardization point of view: I like standards and YAFC does not implement them correctly, so it triggers me (a little).

DaleStan added 2 commits May 14, 2024 10:58
…elts of production.

Also look for /s, /m, or /h suffixes. If present, use that suffix regardless of the current display settings.
@shpaass shpaass force-pushed the implement-181-ce branch from fc01cfe to a3b991d Compare May 14, 2024 08:58
@shpaass shpaass merged commit 6a28abf into shpaass:master May 14, 2024
1 check passed
@DaleStan DaleStan deleted the implement-181-ce branch May 16, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants