joshprzybyszewski / cribbage

A cribbage scorer and game
MIT License
2 stars 1 forks source link

implement the suggestion hand logic only on the server #91

Closed joshprzybyszewski closed 3 years ago

joshprzybyszewski commented 3 years ago

What broke / What you're adding

I'd like to have the server logic for suggesting what to toss into the crib so that we can use it on the client (which should be https://github.com/joshprzybyszewski/cribbage/pull/89). Putting the server logic in first will compartmentalize the changes and allow for iteration on UI.

How you did it

Take the "calculated NPC" logic and consolidate it. Then provide an exported func to access it in a consumable way. Then hook up a rest endpoint that will return the list of results.

How to test it and how to try to break it

You can hit the endpoint with something like this: curl localhost:8080/suggest/hand?dealt=5h,5c,5d,js,6s,6h

codecov[bot] commented 3 years ago

Codecov Report

Merging #91 (4515c6d) into master (d9399dc) will increase coverage by 0.81%. The diff coverage is 92.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #91      +/-   ##
==========================================
+ Coverage   69.32%   70.13%   +0.81%     
==========================================
  Files          73       80       +7     
  Lines        3354     3465     +111     
==========================================
+ Hits         2325     2430     +105     
- Misses        813      818       +5     
- Partials      216      217       +1     
Impacted Files Coverage Δ
logic/strategy/toss_evaluator.go 76.47% <76.47%> (ø)
logic/strategy/calculated_toss.go 84.62% <84.62%> (ø)
logic/suggestions/tossStats.go 89.47% <89.47%> (ø)
model/card.go 93.68% <90.91%> (-4.07%) :arrow_down:
logic/suggestions/handToss.go 95.00% <95.00%> (ø)
logic/strategy/calculated_crib.go 100.00% <100.00%> (+11.76%) :arrow_up:
logic/strategy/calculated_hand.go 100.00% <100.00%> (+18.75%) :arrow_up:
logic/suggestions/utils.go 95.56% <100.00%> (ø)
model/test_utils.go 100.00% <100.00%> (ø)
network/suggest.go 100.00% <100.00%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d9399dc...4515c6d. Read the comment docs.

cszczepaniak commented 3 years ago

:thinking: can we fix golangci-lint?

cszczepaniak commented 3 years ago

Didn't look super closely on the first round of comments; I'll take a closer look at the meatier parts of the logic a bit later.

cszczepaniak commented 3 years ago

Left my initial round of comments. Cool PR!

Btw, golangci-lint isn't failing; it seems to be the action itself using things that used to be allowed but have since been disallowed by default for security:

Error: Unable to process command '::set-env name=GOROOT::/opt/hostedtoolcache/go/1.15.8/x64' successfully.
  Error: The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
  Error: Unable to process command '::add-path::/opt/hostedtoolcache/go/1.15.8/x64/bin' successfully.
  Error: The `add-path` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/