-
Notifications
You must be signed in to change notification settings - Fork 107
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
Update FillPlayerTradeModal.tsx #403
base: main
Are you sure you want to change the base?
Update FillPlayerTradeModal.tsx #403
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. However, I have substantial concerns w.r.t the quality of the PR:
- There are lots of opaque mechanisms and magic values in the code, that should be avoided
- There are lots of debug/develop code that should be cleaned before merging
- The implementation is essentially a "workaround" and doesn't address the fundamental problem
- Localization is not provided
- The PR does not pass code quality checks
@@ -35,6 +35,12 @@ export function FillPlayerTradeModal({ tradeId, xy }: { tradeId: string; xy?: Ti | |||
const allTradeBuildings = Tick.current.playerTradeBuildings; | |||
const [fills, setFills] = useState(new Map<Tile, number>()); | |||
|
|||
const DEFAULT_HINTS = "greedy"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why DEFAULT_HINTS
is needed here. Having an opaque variable should generally be avoided
// major changes 2025-02-xx | ||
// param "hint" can be "greedy" or "fast" to tweak some limits | ||
// param "maxError" reserved for future use, to set tolerance for fluctuating, erronous or invalid values | ||
const calculateMaxFill = (hints = "auto", maxError = 0.03) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, hints
should not be included. Also the magic number 0.03
should not be included
amountLeft -= amount; | ||
|
||
// enable some tweaks only in large trades | ||
const isLargeTrade = trade.buyAmount >= 10000000; // 10 million |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10000000
magic number should be avoided
// todo: localize | ||
let tradeStr = `${total} / ${fills.size}`; | ||
let resourceStr = `${formatNumber(fillAmount)} ${trade.buyResource}`; | ||
let str1 = `Filling trades ${tradeStr}, sending: ${resourceStr}...`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All strings should be localized
No description provided.