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

Player State Endpoint/Game Start #34

Merged
merged 15 commits into from
Sep 9, 2019
Merged

Conversation

BrennanAyers
Copy link
Owner

Description

This PR brings in the endpoint for the Frontend to receive an individual Players current State. A Player State contains the information of their Deck, their collection of GameCards that have not been discarded yet, and their Discard, their collection of GameCards that have been discarded in the course of the game so far. We decided to start with the easy solution of a Player having a Deck at the beginning of a Game.
For the GameCards to be added to a Players deck, the Game the Player is a part of needs to be started, which begins a process of creating GameCards that are assigned to the Players, and then also creating GameCards that are in the general pool of cards for the Game. This functionality is required, as stubbing a Player GameCards does not directly reflect the beginning Game State.
The instance methods of deck and discard on a Player model help organize GameCards based on their discarded status. The cards method required a Joins with the Cards table to enable easy testing and rendering of the GameCard objects for the Frontend.
GameCards now have default values in the DB for trashed and discarded of false.
The GameCard factory now correctly creates estates, duchys, and provinces with a spending_power of nil, instead of 0. This is how the Frontend needs those values to avoid false positives when rendering.

Resolves #27 #33

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Player State Endpoint spec
  • Game #start Unit spec
  • Player #deck Unit spec
  • Player #discard Unit spec

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Brennan Ayers and others added 14 commits September 7, 2019 14:42
Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
… GameCards to Players

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…th GameCards

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
Co-Authored-By: Chris Davis <davisc1014@gmail.com>
…ayer GameCards, and adds Coppers and Estates to pool of GameCards

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…available for testing/display

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
… in migration and schema

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…#show

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
… #discard methods to serialize Player State

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…ings

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
Co-Authored-By: Chris Davis <davisc1014@gmail.com>
Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…osseses are discarded or not

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…ow convention of Card attributes with no value

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
…follow convention

Co-Authored-By: Patrick Duvall <duvallp208@gmail.com>
Copy link
Collaborator

@DavisC0801 DavisC0801 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on fully testing the endpoint, and corrections on the factory.

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.

Add GET api/v1/games/:game_id/players/:id endoint
2 participants