-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a page to get the suggestions for what to throw into the crib #89
base: master
Are you sure you want to change the base?
Conversation
const updateValue=(_) => { | ||
// TODO figure out how to get scroll capturing to work | ||
// TODO update the value of this card in the state | ||
console.log(`scrolled: ${card}`); | ||
}; | ||
const updateSuit=(_) => { | ||
// TODO update the state so that this card increments suits | ||
console.log(`clicked: ${card}`); | ||
}; |
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.
These are the next things I'd like to do
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.
Looks like scrolling --> change number, clicking --> change suit? Nice.
<TableRow> | ||
<TableCell>Hand Points (avg)</TableCell> | ||
<TableCell>Hand Points (median)</TableCell> | ||
<TableCell>Crib Points (avg)</TableCell> | ||
<TableCell>Crib Points (median)</TableCell> | ||
<TableCell>Throw</TableCell> | ||
</TableRow> |
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.
It would be awesome if we could get a table that has "merged cells" for the first header row, then has sub columns in the second header row so that we put | hand points | crib points | throw |
in the first row and have avg | median | max
as "sub columns" under each hand and crib. I haven't been able to figure that out yet, but it seems like this page should be able to help?
Codecov Report
@@ Coverage Diff @@
## master #89 +/- ##
==========================================
+ Coverage 70.07% 70.13% +0.06%
==========================================
Files 80 80
Lines 3465 3465
==========================================
+ Hits 2428 2430 +2
+ Misses 819 818 -1
+ Partials 218 217 -1
Continue to review full report at Codecov.
|
<Grid | ||
item | ||
container | ||
spacing={1} | ||
><GridList> | ||
{handCards.map((card, index) => ( | ||
<ChoosingCard | ||
key={`handcard${index}`} | ||
card={card} | ||
/> | ||
))} | ||
</GridList> | ||
</Grid> |
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 could probably be split out into its own component?
handCards: [ | ||
'AH', 'KH', '5H', 'JH', '8C', '3D', | ||
], |
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 need a way to update this array
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.
Write a reducer below that takes a string and an index to update?
setSuggestionResult: { | ||
reducer: (state, action) => { | ||
state.suggestedHands = action.payload.suggestions; | ||
}, | ||
}, |
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 is currently unused.
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'd like to have the client-side set up to just be using dummy data. Once I can edit the input hand adequately and see things update acceptably, I'd like to implement a REST endpoint on the server to accept the input and spit out the suggestions. Someday, it'd be neat if the client would just do all of the calculations
onScroll={updateValue} | ||
onClick={updateSuit} | ||
className={classes.root}> |
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.
Why is our formatting messed up? I guess I need to revisit our tooling to see if we're formatting on commit
Reading through this code again makes me sorely miss TypeScript. I think we're going to want that ASAP |
@@ -6,6 +6,7 @@ import ListItem from '@material-ui/core/ListItem'; | |||
import ListItemIcon from '@material-ui/core/ListItemIcon'; | |||
import ListItemText from '@material-ui/core/ListItemText'; | |||
import AddCircleOutlineIcon from '@material-ui/icons/AddCircleOutline'; | |||
import SearchIcon from '@material-ui/icons/Search'; |
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.
It's kinda cool and all that our linter comments on PRs but...
Can we just
- Run lint on commit (with husky and lint-staged)
- Run lint on PR builds
Number 1 should realistically prevent 99% of these lint comments from showing up.
import Card from '@material-ui/core/Card'; | ||
import CardContent from '@material-ui/core/CardContent'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Typography from '@material-ui/core/Typography'; |
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.
🌵 These should prolly just use the named imports from '@material-ui/core'
height: 160, | ||
}, | ||
value: { | ||
fontSize: 14, |
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.
We should keep font sizes in rem
so they stay relative to a single reference size. Root font size is probably 16, so this would become '0.875rem'
// TODO figure out how to get scroll capturing to work | ||
// TODO update the value of this card in the state |
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.
For managing state, you could do:
// near the top of your component
const [index, setIndex] = useState(0);
// ...
const updateValue = () => setIndex(prev => prev + 1); // or - 1, depending on scroll direction
I'm not sure what data onScroll
feeds back to you, but that's at least the state management part
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 wait, you want to update it in redux probably...
const SuggestionsTable = () => { | ||
const sugs = useSelector(selectSuggestions); | ||
|
||
if (!Array.isArray(sugs)) { |
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.
cries in typescript
spacing={1} | ||
> | ||
<GridList> | ||
{sug.throw.map((card, index) => ( |
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.
we should probably not name things throw
since that's a keyword in JS
Glad to see cribbage is alive again 😎 |
…uggest Conflicts: logic/strategy/calculated_crib.go logic/strategy/calculated_hand.go logic/suggestions/utils.go network/suggest.go server/server.go
…uggest Conflicts: client/src/app/containers/LeftDrawer/LoggedInDrawer.jsx client/src/app/index.jsx
What broke / What you're adding
It'd be neat if we had a page that would show the calculated hand/crib pts for throwing different cards.
How you did it
Add a new directory for Suggestions. Currently, it will only suggest what to throw into the crib, but it'd also be neat to suggest what to peg next.
How to test it and how to try to break it