-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fighter II checkbox #3
Conversation
frontend/src/Calculator.tsx
Outdated
<Checkbox | ||
label="Fighter II" | ||
checked={isFighterUpgraded} | ||
onChange={() => | ||
setIsFighterUpgraded(!isFighterUpgraded) | ||
} |
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 was on the fence about putting the checkbox inside BudgetModeInputs
rather than adjacent, but I could foresee wanting to use the checkbox in both modes if we get fancier, and putting it here makes it easier to move around if that happens. Not married to it either way though!
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 think I lean (slightly) the other way, but that's because I only really imagine using this in the budget mode. Doesn't really make a difference to me as this is easy to refactor if we guess wrong.
💭 One thing I am considering though - I think with all this functionality, budget mode is getting a little complex. I like the functionality, but it's a lot of paperwork to do. What would you think about (in the future, not this PR) hiding some of the more complex options like capacity management or off-planet (read: Saar) production, under a dropdown tab for "advanced mode"? That way the options are there for anyone who wants to deal with them, and hidden (+inactive) for anyone who can't be bothered?
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.
Another example in support of an "advanced mode" - isn't the "Space Dock Fighter Bonus" the same value for almost every faction?
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.
Done, moved firmly into budget mode 👌
That's a great idea, all the form fields are making my eyes glaze over!
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.
Oh dang didn't know that about the space dock bonus - the only two factions I've drafted have been different so I just assumed it varied! Should definitely make that a static number which you can change in advanced mode
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.
Solid stuff!!! Looks fantastic 😍
frontend/src/data.ts
Outdated
@@ -87,20 +87,36 @@ export function getTotalCost(unitCounts: UnitCounts): number { | |||
); | |||
} | |||
|
|||
function sumUnitCountEntries(unitCountEntries: [Unit, number][]): number { |
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.
The weirdness of dealing directly with a [Unit, number][]
type struck me. Try playing around with this function signature and see if you like what falls out!
function sumUnitCounts(
unitCounts: UnitCounts,
unitFilter: (unit: Unit) => boolean = () => true): number
)
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.
Sooo much cleaner, thank you, updated! I love this 🔥
frontend/src/data.ts
Outdated
} | ||
|
||
export function getFleetSupplyRemaining( | ||
currentFleetSupply: number, | ||
maxFleetSupply: number, | ||
unitCounts: UnitCounts | ||
unitCounts: UnitCounts, | ||
airborneFighterCount: number |
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.
⛏️ Took just a sec to realize what this name meant. Maybe unsupportedFighters
? What do you think?
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.
That's perfect, I was so stuck on this name and could only think of nonTransportedFighters
but didn't like the negation. And airborne isn't even correct because they're in space? Lol, fixed now
frontend/src/Calculator.tsx
Outdated
<Checkbox | ||
label="Fighter II" | ||
checked={isFighterUpgraded} | ||
onChange={() => | ||
setIsFighterUpgraded(!isFighterUpgraded) | ||
} |
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 think I lean (slightly) the other way, but that's because I only really imagine using this in the budget mode. Doesn't really make a difference to me as this is easy to refactor if we guess wrong.
💭 One thing I am considering though - I think with all this functionality, budget mode is getting a little complex. I like the functionality, but it's a lot of paperwork to do. What would you think about (in the future, not this PR) hiding some of the more complex options like capacity management or off-planet (read: Saar) production, under a dropdown tab for "advanced mode"? That way the options are there for anyone who wants to deal with them, and hidden (+inactive) for anyone who can't be bothered?
frontend/src/Calculator.tsx
Outdated
<Checkbox | ||
label="Fighter II" | ||
checked={isFighterUpgraded} | ||
onChange={() => | ||
setIsFighterUpgraded(!isFighterUpgraded) | ||
} |
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.
Another example in support of an "advanced mode" - isn't the "Space Dock Fighter Bonus" the same value for almost every faction?
frontend/src/BudgetModeDisplay.tsx
Outdated
}: Props) { | ||
const shipCapacityRemaining = |
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.
⛏️ This variable name kinda bothers me, only because elsewhere you're careful to distinguish between "ship capacity" and the "space dock fighter bonus" (I'm guessing to later account for ground forces, which can't be supported by space docks?). But here it's all lumped together and called "ship capacity".
A few alternate proposals:
totalCapacityRemaining
capacityRemaining
fighterCapacityRemaining
(I think maybe I dislike this one the least)
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.
Right guess on the future ground forces problem, and yes good point - I like fighterCapacityRemaining
since that's the least ambiguous, and can handle renaming it when we add advanced mode!
frontend/src/BudgetModeDisplay.tsx
Outdated
value: capacityBudget - getTotalCapacity(unitCounts), | ||
}, | ||
{ | ||
label: "Fleet Supply Remaining", | ||
value: getFleetSupplyRemaining( | ||
currentFleetSupply, | ||
maxFleetSupply, | ||
unitCounts | ||
unitCounts, | ||
isFighterUpgraded ? Math.max(0 - shipCapacityRemaining, 0) : 0 |
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.
Had to puzzle over this, and see it work in action, before I could convince myself it was correct (it is!). Probably just sleep-deprived ☕
But consider:
isFighterUpgraded && shipCapacityRemaining < 0 ? shipCapacityRemaining : 0
Neither is wrong, so pick your fave.
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.
Honestly same, and I'm the one that wrote it 🤦♀️ yours is definitely easier on the brain! Updated to that with a teeny adjustment to flip the sign
frontend/src/BudgetModeDisplay.tsx
Outdated
), | ||
}, | ||
{ | ||
label: "Ship Capacity Remaining", | ||
value: isFighterUpgraded |
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.
As above, check if you prefer:
isFighterUpgraded && shipCapacityRemaining < 0 ? 0 : shipCapacityRemaining
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.
Prefer yours, updated! I was playing around with a zeroFloor(num: number) { return Math.max(num, 0); }
util to abstract out the Math.max(x, 0)
s everywhere but it still ended up being hard to digest, I give up 🥲
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.
Oooh and, did one more thing, the latest commit reduces the confusion even more - 47d71a6
@sirrus233 Aaah been out all day and just had time to check this out, these review comments are so on point, dude thank you!! Gonna see if I can get a jump on these before we call tomorrow! |
a5fa6c6
to
bac7863
Compare
@sirrus233 I think I got everything, you want to take one more look? Each time I change any of the math I wish for unit tests, and yet am too lazy to set up Jest. I will simply complain about it endlessly |
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.
🚢
@@ -87,20 +87,34 @@ export function getTotalCost(unitCounts: UnitCounts): number { | |||
); | |||
} | |||
|
|||
export function getTotalCapacity(unitCounts: UnitCounts): number { |
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.
Nice catch! I missed the equivalency.
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.
🎉
Took a stab at this, check my logic though!
New budget inputs:
shipCapacityUsed
maxShipCapacity
spaceDockFighterBonus
New budget display field:
shipCapacityRemaining
:maxShipCapacity
+spaceDockFighterBonus
-shipCapacityUsed
- fighters added with the calculatorshipCapacityRemaining
shipCapacityRemaining
until it reaches 0, then they begin to count againstfleetSupplyRemaining
I realized there should also be a checkbox for "I'm building in a space-only system" for Saar (maybe others?), which would trigger ground forces to be subtracted from
shipCapacityRemaining
, but leaving that for another PR!