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

Update FillPlayerTradeModal.tsx #403

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lilianne-Blaze
Copy link

No description provided.

Copy link
Contributor

@insraq insraq left a 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";
Copy link
Contributor

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) => {
Copy link
Contributor

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
Copy link
Contributor

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}...`;
Copy link
Contributor

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

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.

2 participants